diff --git a/doc/qtcreator/images/qtcreator-build-steps-conan-install.png b/doc/qtcreator/images/qtcreator-build-steps-conan-install.png new file mode 100644 index 00000000000..09ab3549aa2 Binary files /dev/null and b/doc/qtcreator/images/qtcreator-build-steps-conan-install.png differ diff --git a/doc/qtcreator/images/qtcreator-project-kits.png b/doc/qtcreator/images/qtcreator-project-kits.png index 08e8085de8d..569425e742b 100644 Binary files a/doc/qtcreator/images/qtcreator-project-kits.png and b/doc/qtcreator/images/qtcreator-project-kits.png differ diff --git a/doc/qtcreator/src/conan/creator-projects-conan-building.qdocinc b/doc/qtcreator/src/conan/creator-projects-conan-building.qdocinc new file mode 100644 index 00000000000..c4d8ff26e52 --- /dev/null +++ b/doc/qtcreator/src/conan/creator-projects-conan-building.qdocinc @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Creator documentation. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** +****************************************************************************/ + +/*! +//! [conan build steps] + \section1 Specifying Build Settings for Conan + + To configure a project to be built using the Conan package manager, select + \uicontrol {Add Build Step} > \uicontrol {Run Conan Install}. + + \image qtcreator-build-steps-conan-install.png "Conan Install build step" + + In the \uicontrol {Conan file} field, enter the location of the + \e conanfile.txt file for the project. + + The \uicontrol {Conan install} field displays the effective + build command. You can add arguments for the command in the + \uicontrol {Additional arguments} field. + + For more information about configuring Conan, see \l{Setting Up Conan}. +//! [conan build steps] +*/ diff --git a/doc/qtcreator/src/conan/creator-projects-conan.qdoc b/doc/qtcreator/src/conan/creator-projects-conan.qdoc new file mode 100644 index 00000000000..a846c252047 --- /dev/null +++ b/doc/qtcreator/src/conan/creator-projects-conan.qdoc @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt Creator documentation. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** +****************************************************************************/ + +/*! + \page creator-project-conan.html + \previouspage creator-project-incredibuild.html + \nextpage creator-cli.html + + \title Setting Up Conan + + \l {https://conan.io}{Conan} is a C/C++ package manager that speeds up the + integration of C or C++ libraries into your own project. It's available on + all the \l{Supported Platforms}{supported development platforms}. + + Conan can be integrated into most build systems that are integrated into + \QC: + + \list + \li \l{https://docs.conan.io/en/latest/integrations/cmake.html}{CMake} + \li \l{https://docs.conan.io/en/latest/integrations/qbs.html}{Qbs} + \li \l{https://docs.conan.io/en/latest/integrations/qmake.html}{qmake} + \li \l{https://docs.conan.io/en/latest/integrations/meson.html}{Meson} + \endlist + + The client-server architecture of Conan enables the client to fetch packages + from and upload them to remote servers that act as package storage. The + client creates the packages, and if necessary, handles building them from + sources. Because the client has a local cache for package storage, you can + work offline, as long as no new packages are needed from remote servers. + + To use Conan, install it by using the Qt installer. + + To enable the experimental Conan plugin, select \uicontrol Help > + \uicontrol {About Plugins} > \uicontrol Utilities > \uicontrol Conan. + Then select \uicontrol {Restart Now} to restart \QC and load the plugin. + + For each project, you must write a + \l{https://docs.conan.io/en/latest/reference/conanfile.html}{conanfile.py} + or \l{https://docs.conan.io/en/latest/reference/conanfile_txt.html} + {conanfile.txt} file that specifies the needed libraries and packages. + Then, you must edit the build settings of the project to specify the + location of the file and the contents of the Conan install command. + For more information, see \l {Specifying Build Settings for Conan}. +*/ diff --git a/doc/qtcreator/src/howto/creator-only/creator-cli.qdoc b/doc/qtcreator/src/howto/creator-only/creator-cli.qdoc index d81a3e6443e..f8356b86d5b 100644 --- a/doc/qtcreator/src/howto/creator-only/creator-cli.qdoc +++ b/doc/qtcreator/src/howto/creator-only/creator-cli.qdoc @@ -30,7 +30,7 @@ // ********************************************************************** /*! - \previouspage creator-project-incredibuild.html + \previouspage creator-project-conan.html \page creator-cli.html \nextpage creator-keyboard-shortcuts.html diff --git a/doc/qtcreator/src/incredibuild/creator-projects-incredibuild.qdoc b/doc/qtcreator/src/incredibuild/creator-projects-incredibuild.qdoc index 91cde5ab277..5791b49b491 100644 --- a/doc/qtcreator/src/incredibuild/creator-projects-incredibuild.qdoc +++ b/doc/qtcreator/src/incredibuild/creator-projects-incredibuild.qdoc @@ -26,7 +26,7 @@ /*! \previouspage creator-project-meson.html \page creator-project-incredibuild.html - \nextpage creator-cli.html + \nextpage creator-project-conan.html \title Setting Up IncrediBuild diff --git a/doc/qtcreator/src/projects/creator-only/creator-projects-other.qdoc b/doc/qtcreator/src/projects/creator-only/creator-projects-other.qdoc index 3e373c7952a..635fbd19ba4 100644 --- a/doc/qtcreator/src/projects/creator-only/creator-projects-other.qdoc +++ b/doc/qtcreator/src/projects/creator-only/creator-projects-other.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2020 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Creator documentation. @@ -82,6 +82,13 @@ IncrediBuild decreases the time it takes to build C++ code. + \li \l{Setting Up Conan} + + The experimental Conan plugin integrates the Conan package manager + that speeds up the integration of C or C++ libraries into your + project. You can use Conan with most build systems integrated into + \QC. + \endlist */ diff --git a/doc/qtcreator/src/projects/creator-only/creator-projects-settings-build.qdoc b/doc/qtcreator/src/projects/creator-only/creator-projects-settings-build.qdoc index 4d13904606f..1acaa51a7cc 100644 --- a/doc/qtcreator/src/projects/creator-only/creator-projects-settings-build.qdoc +++ b/doc/qtcreator/src/projects/creator-only/creator-projects-settings-build.qdoc @@ -46,7 +46,7 @@ If you selected CMake as the build system for the project, you can use a \e {minimum size release} build configuration to create the - final installation file. It is a release build that makes the size + final installation file. It is a release build that makes the size of the binary package as small as possible, even if this makes the application slower. @@ -182,6 +182,7 @@ \include creator-projects-settings-build-qbs.qdocinc qbs build steps \include creator-projects-meson-building.qdocinc meson build steps \include creator-projects-incredibuild-building.qdocinc incredibuild build steps + \include creator-projects-conan-building.qdocinc conan build steps \section2 Adding Custom Build Steps diff --git a/doc/qtcreator/src/projects/creator-only/creator-projects-settings-overview.qdoc b/doc/qtcreator/src/projects/creator-only/creator-projects-settings-overview.qdoc index f70f1d6db3f..2d24ffcd4cb 100644 --- a/doc/qtcreator/src/projects/creator-only/creator-projects-settings-overview.qdoc +++ b/doc/qtcreator/src/projects/creator-only/creator-projects-settings-overview.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Creator documentation. @@ -64,9 +64,17 @@ To view the warning and error messages, move the mouse pointer over the kit name. - To modify kit configuration or to add kits to the list, select - \uicontrol {Manage Kits}. For more information about managing kits, see - \l{Adding Kits}. + In the list of kits, you may see entries described as \e {Replacement for + }. \QC generates them to save your project-specific settings, + such as custom build flags or run configuration arguments that would + disappear if the corresponding kits were simply removed when you remove + Qt versions while updating your Qt installation. You can modify the kit + configuration to use a currently installed Qt version and save the kit + under a new name. + + To modify kit configuration or to add kits to the list or to remove + them from it, select \uicontrol {Manage Kits}. For more information + about managing kits, see \l{Adding Kits}. Each kit consists of a set of values that define one environment, such as a \l{glossary-device}{device}, compiler, and Qt version. For more information, diff --git a/doc/qtcreator/src/qtcreator-toc.qdoc b/doc/qtcreator/src/qtcreator-toc.qdoc index edaf3bad4e4..85ae72493a5 100644 --- a/doc/qtcreator/src/qtcreator-toc.qdoc +++ b/doc/qtcreator/src/qtcreator-toc.qdoc @@ -277,6 +277,7 @@ \li \l{Setting Up Nimble} \li \l{Setting Up Meson} \li \l{Setting Up IncrediBuild} + \li \l{Setting Up Conan} \endlist \li \l{Using Command Line Options} \li \l{Keyboard Shortcuts} diff --git a/doc/qtcreator/src/qtquick/library/qtquick-controls.qdoc b/doc/qtcreator/src/qtquick/library/qtquick-controls.qdoc index 1f1f7162f10..8e98df94d7a 100644 --- a/doc/qtcreator/src/qtquick/library/qtquick-controls.qdoc +++ b/doc/qtcreator/src/qtquick/library/qtquick-controls.qdoc @@ -293,7 +293,7 @@ \image qtquickcontrols2-button-flat.gif "Flat button" - \if definded(qtdesignstudio) + \if defined(qtdesignstudio) To create a button that contains an icon, use the wizard template to \l{Creating Custom Controls}{create a custom button} and drag-and-drop the icon to the button background item. For an example of using the @@ -399,7 +399,7 @@ \section2 Round Button \uicontrol {Round Button} is a clickable control that starts an action, - or opens or closes a popup. A round button with a square image icon or + or opens or closes a popup. A round button with a square image icon or one-letter font icon is circular. A circular round button takes less space than a normal button, and can also be used as a floating action button. @@ -492,7 +492,7 @@ \uicontrol {Progress Bar} indicates the progress of an operation. You can specify the initial value in the \uicontrol Value field, but it - should be updated regularly. Specify the range in the \uicontrol From + should be updated regularly. Specify the range in the \uicontrol From and \uicontrol To fields, which can both contain any value. \image qtquick-designer-progressbar-properties.png "Progress Bar properties" diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index f4fa4d6319f..6d92a7c05df 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -34,9 +34,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -353,16 +355,41 @@ void Client::closeDocument(TextEditor::TextDocument *document) } } +void Client::updateCompletionProvider(TextEditor::TextDocument *document) +{ + bool useLanguageServer = m_serverCapabilities.completionProvider().has_value(); + auto clientCompletionProvider = static_cast( + m_clientProviders.completionAssistProvider.data()); + if (m_dynamicCapabilities.isRegistered(CompletionRequest::methodName).value_or(false)) { + const QJsonValue &options = m_dynamicCapabilities.option(CompletionRequest::methodName); + const TextDocumentRegistrationOptions docOptions(options); + useLanguageServer = docOptions.filterApplies(document->filePath(), + Utils::mimeTypeForName(document->mimeType())); + + const ServerCapabilities::CompletionOptions completionOptions(options); + if (completionOptions.isValid(nullptr)) + clientCompletionProvider->setTriggerCharacters(completionOptions.triggerCharacters()); + } + + if (document->completionAssistProvider() != clientCompletionProvider) { + if (useLanguageServer) { + m_resetAssistProvider[document].completionAssistProvider + = document->completionAssistProvider(); + document->setCompletionAssistProvider(clientCompletionProvider); + } + } else if (!useLanguageServer) { + document->setCompletionAssistProvider( + m_resetAssistProvider[document].completionAssistProvider); + } +} + void Client::activateDocument(TextEditor::TextDocument *document) { auto uri = DocumentUri::fromFilePath(document->filePath()); m_diagnosticManager.showDiagnostics(uri); SemanticHighligtingSupport::applyHighlight(document, m_highlights.value(uri), capabilities()); // only replace the assist provider if the language server support it - if (m_serverCapabilities.completionProvider()) { - m_resetAssistProvider[document].completionAssistProvider = document->completionAssistProvider(); - document->setCompletionAssistProvider(m_clientProviders.completionAssistProvider); - } + updateCompletionProvider(document); if (m_serverCapabilities.signatureHelpProvider()) { m_resetAssistProvider[document].functionHintProvider = document->functionHintAssistProvider(); document->setFunctionHintAssistProvider(m_clientProviders.functionHintProvider); @@ -524,6 +551,11 @@ void Client::documentContentsChanged(TextEditor::TextDocument *document, void Client::registerCapabilities(const QList ®istrations) { m_dynamicCapabilities.registerCapability(registrations); + if (Utils::anyOf(registrations, + Utils::equal(&Registration::method, QString(CompletionRequest::methodName)))) { + for (auto document : m_openedDocument.keys()) + updateCompletionProvider(document); + } } void Client::unregisterCapabilities(const QList &unregistrations) @@ -1119,7 +1151,7 @@ void Client::handleMethod(const QString &method, const MessageId &id, const ICon } else if (method == RegisterCapabilityRequest::methodName) { auto params = dynamic_cast(content)->params().value_or(RegistrationParams()); if (params.isValid(&error)) - m_dynamicCapabilities.registerCapability(params.registrations()); + registerCapabilities(params.registrations()); else logError(params); } else if (method == UnregisterCapabilityRequest::methodName) { @@ -1260,8 +1292,7 @@ void Client::initializeCallback(const InitializeRequest::Response &initResponse) completionProvider->setTriggerCharacters( m_serverCapabilities.completionProvider() .value_or(ServerCapabilities::CompletionOptions()) - .triggerCharacters() - .value_or(QList())); + .triggerCharacters()); } if (auto functionHintAssistProvider = qobject_cast( m_clientProviders.functionHintProvider)) { diff --git a/src/plugins/languageclient/client.h b/src/plugins/languageclient/client.h index dd445cf3aa2..ae5c7887242 100644 --- a/src/plugins/languageclient/client.h +++ b/src/plugins/languageclient/client.h @@ -205,6 +205,8 @@ private: void resetAssistProviders(TextEditor::TextDocument *document); void sendPostponedDocumentUpdates(); + void updateCompletionProvider(TextEditor::TextDocument *document); + using ContentHandler = std::function; diff --git a/src/plugins/languageclient/languageclientcompletionassist.cpp b/src/plugins/languageclient/languageclientcompletionassist.cpp index 950b58e6549..a0a9abd6cf1 100644 --- a/src/plugins/languageclient/languageclientcompletionassist.cpp +++ b/src/plugins/languageclient/languageclientcompletionassist.cpp @@ -451,10 +451,12 @@ bool LanguageClientCompletionAssistProvider::isActivationCharSequence(const QStr }); } -void LanguageClientCompletionAssistProvider::setTriggerCharacters(QList triggerChars) +void LanguageClientCompletionAssistProvider::setTriggerCharacters( + const Utils::optional> triggerChars) { - m_triggerChars = triggerChars; - for (const QString &trigger : triggerChars) { + m_activationCharSequenceLength = 0; + m_triggerChars = triggerChars.value_or(QList()); + for (const QString &trigger : qAsConst(m_triggerChars)) { if (trigger.length() > m_activationCharSequenceLength) m_activationCharSequenceLength = trigger.length(); } diff --git a/src/plugins/languageclient/languageclientcompletionassist.h b/src/plugins/languageclient/languageclientcompletionassist.h index 828a33ec758..34bf7b209ac 100644 --- a/src/plugins/languageclient/languageclientcompletionassist.h +++ b/src/plugins/languageclient/languageclientcompletionassist.h @@ -27,6 +27,8 @@ #include +#include + namespace LanguageClient { class Client; @@ -45,7 +47,7 @@ public: bool isActivationCharSequence(const QString &sequence) const override; bool isContinuationChar(const QChar &) const override { return true; } - void setTriggerCharacters(QList triggerChars); + void setTriggerCharacters(const Utils::optional> triggerChars); private: QList m_triggerChars; diff --git a/src/plugins/languageclient/languageclienthoverhandler.cpp b/src/plugins/languageclient/languageclienthoverhandler.cpp index b0ff1c28644..e95760b8b27 100644 --- a/src/plugins/languageclient/languageclienthoverhandler.cpp +++ b/src/plugins/languageclient/languageclienthoverhandler.cpp @@ -59,9 +59,7 @@ void HoverHandler::identifyMatch(TextEditor::TextEditorWidget *editorWidget, { if (m_currentRequest.has_value()) abort(); - if (m_client.isNull() - || !m_client->documentOpen(editorWidget->textDocument()) - || !m_client->capabilities().hoverProvider().value_or(false)) { + if (m_client.isNull() || !m_client->documentOpen(editorWidget->textDocument())) { report(Priority_None); return; } diff --git a/src/plugins/languageclient/languageclientmanager.cpp b/src/plugins/languageclient/languageclientmanager.cpp index 43213e4de1c..b25d570b9c2 100644 --- a/src/plugins/languageclient/languageclientmanager.cpp +++ b/src/plugins/languageclient/languageclientmanager.cpp @@ -65,6 +65,8 @@ LanguageClientManager::LanguageClientManager(QObject *parent) JsonRpcMessageHandler::registerMessageProvider(); JsonRpcMessageHandler::registerMessageProvider(); JsonRpcMessageHandler::registerMessageProvider(); + JsonRpcMessageHandler::registerMessageProvider(); + JsonRpcMessageHandler::registerMessageProvider(); connect(EditorManager::instance(), &EditorManager::editorOpened, this, &LanguageClientManager::editorOpened); connect(EditorManager::instance(), &EditorManager::documentOpened, diff --git a/src/plugins/qmldesigner/designercore/include/annotation.h b/src/plugins/qmldesigner/designercore/include/annotation.h index 681c5ee0236..e00481d57ab 100644 --- a/src/plugins/qmldesigner/designercore/include/annotation.h +++ b/src/plugins/qmldesigner/designercore/include/annotation.h @@ -100,8 +100,9 @@ public: friend QDebug &operator<<(QDebug &stream, const Comment &comment); - friend QDataStream &operator<<(QDataStream &stream, const Comment &comment); - friend QDataStream &operator>>(QDataStream &stream, Comment &comment); + QMLDESIGNERCORE_EXPORT friend QDataStream &operator<<(QDataStream &stream, + const Comment &comment); + QMLDESIGNERCORE_EXPORT friend QDataStream &operator>>(QDataStream &stream, Comment &comment); private: QString m_title; @@ -132,8 +133,10 @@ public: friend QDebug &operator<<(QDebug &stream, const Annotation &annotation); - friend QDataStream &operator<<(QDataStream &stream, const Annotation &annotation); - friend QDataStream &operator>>(QDataStream &stream, Annotation &annotation); + QMLDESIGNERCORE_EXPORT friend QDataStream &operator<<(QDataStream &stream, + const Annotation &annotation); + QMLDESIGNERCORE_EXPORT friend QDataStream &operator>>(QDataStream &stream, + Annotation &annotation); private: QVector m_comments; @@ -142,12 +145,11 @@ private: QDebug &operator<<(QDebug &stream, const Comment &comment); QDebug &operator<<(QDebug &stream, const Annotation &annotation); -QDataStream &operator<<(QDataStream &stream, const Comment &comment); -QDataStream &operator>>(QDataStream &stream, Comment &comment); -QDataStream &operator<<(QDataStream &stream, const Annotation &annotation); -QDataStream &operator>>(QDataStream &stream, Annotation &annotation); - -} +QMLDESIGNERCORE_EXPORT QDataStream &operator<<(QDataStream &stream, const Comment &comment); +QMLDESIGNERCORE_EXPORT QDataStream &operator>>(QDataStream &stream, Comment &comment); +QMLDESIGNERCORE_EXPORT QDataStream &operator<<(QDataStream &stream, const Annotation &annotation); +QMLDESIGNERCORE_EXPORT QDataStream &operator>>(QDataStream &stream, Annotation &annotation); +} // namespace QmlDesigner Q_DECLARE_METATYPE(QmlDesigner::Comment); Q_DECLARE_METATYPE(QmlDesigner::Annotation); diff --git a/src/tools/clangbackend/source/codecompletionsextractor.cpp b/src/tools/clangbackend/source/codecompletionsextractor.cpp index 09bae479fd4..c2386149be8 100644 --- a/src/tools/clangbackend/source/codecompletionsextractor.cpp +++ b/src/tools/clangbackend/source/codecompletionsextractor.cpp @@ -362,7 +362,11 @@ void CodeCompletionsExtractor::extractAvailability() currentCodeCompletion_.availability = CodeCompletion::NotAvailable; break; case CXAvailability_NotAccessible: - currentCodeCompletion_.availability = CodeCompletion::NotAccessible; + // QTCREATORBUG-25244 + if (currentCodeCompletion_.completionKind == CodeCompletion::FunctionDefinitionCompletionKind) + currentCodeCompletion_.availability = CodeCompletion::Available; + else + currentCodeCompletion_.availability = CodeCompletion::NotAccessible; break; } } diff --git a/tests/unit/unittest/codecompletionsextractor-test.cpp b/tests/unit/unittest/codecompletionsextractor-test.cpp index 509dfd49dc4..25c83cd14ca 100644 --- a/tests/unit/unittest/codecompletionsextractor-test.cpp +++ b/tests/unit/unittest/codecompletionsextractor-test.cpp @@ -158,6 +158,7 @@ protected: Document constructorDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_constructor.cpp"), compilationArguments, {}, documents}; Document constructorMemberInitDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_constructorMemberInitialization.cpp"), compilationArguments, {}, documents}; Document briefCommentDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_brief_comment.cpp"), compilationArguments, {}, documents}; + Document privateFunctionDefinitionDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_private_function_definition.cpp"), compilationArguments, {}, documents}; }; using CodeCompletionsExtractorSlowTest = CodeCompletionsExtractor; @@ -602,9 +603,12 @@ TEST_F(CodeCompletionsExtractorSlowTest, NotAccessibleFunction) unsavedFiles.unsavedFile(functionDocument.filePath()), completeResults.data()); + // Availability should be NotAccessible, but see QTCREATORBUG-25244. + // It's better to offer completion for some non-accessible functions than + // not to offer completion for some accessible ones. ASSERT_THAT(extractor, HasCompletion(Utf8StringLiteral("NotAccessibleFunction"), CodeCompletion::FunctionDefinitionCompletionKind, - CodeCompletion::NotAccessible)); + CodeCompletion::Available)); } TEST_F(CodeCompletionsExtractorSlowTest, NotAvailableFunction) @@ -824,6 +828,19 @@ TEST_F(CodeCompletionsExtractorSlowTest, ExtractAll) ASSERT_THAT(codeCompletions.empty(), false); } +TEST_F(CodeCompletionsExtractorSlowTest, PrivateFunctionDefinition) +{ + ClangCodeCompleteResults completeResults(getResults(privateFunctionDefinitionDocument, 5, 12)); + + ::CodeCompletionsExtractor extractor( + unsavedFiles.unsavedFile(privateFunctionDefinitionDocument.filePath()), + completeResults.data()); + + ASSERT_THAT(extractor, HasCompletion(Utf8StringLiteral("method"), + CodeCompletion::FunctionDefinitionCompletionKind, + CodeCompletion::Available)); +} + ClangCodeCompleteResults CodeCompletionsExtractor::getResults(const Document &document, uint line, uint column, diff --git a/tests/unit/unittest/data/complete_extractor_private_function_definition.cpp b/tests/unit/unittest/data/complete_extractor_private_function_definition.cpp new file mode 100644 index 00000000000..c2dd9e3daba --- /dev/null +++ b/tests/unit/unittest/data/complete_extractor_private_function_definition.cpp @@ -0,0 +1,5 @@ +class Foo { + void method(); +}; + +void Foo::m