forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/7.0'
Conflicts: cmake/QtCreatorIDEBranding.cmake qbs/modules/qtc/qtc.qbs qtcreator_ide_branding.pri Change-Id: Ic02df53b880d0861d9d9ea0df3e0d381ae99f350
This commit is contained in:
@@ -1416,7 +1416,12 @@ ClangdClient::ClangdClient(Project *project, const Utils::FilePath &jsonDbDir)
|
||||
return new ClangdTextMark(filePath, diag, isProjectFile, this);
|
||||
};
|
||||
const auto hideDiagsHandler = []{ ClangDiagnosticManager::clearTaskHubIssues(); };
|
||||
setDiagnosticsHandlers(textMarkCreator, hideDiagsHandler);
|
||||
static const auto diagsFilter = [](const Diagnostic &diag) {
|
||||
const Diagnostic::Code code = diag.code().value_or(Diagnostic::Code());
|
||||
const QString * const codeString = Utils::get_if<QString>(&code);
|
||||
return !codeString || *codeString != "drv_unknown_argument";
|
||||
};
|
||||
setDiagnosticsHandlers(textMarkCreator, hideDiagsHandler, diagsFilter);
|
||||
setSymbolStringifier(displayNameFromDocumentSymbol);
|
||||
setSemanticTokensHandler([this](TextDocument *doc, const QList<ExpandedSemanticToken> &tokens,
|
||||
int version, bool force) {
|
||||
@@ -2815,7 +2820,8 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
|
||||
if (detail.startsWith("operator")) {
|
||||
return !detail.contains('=')
|
||||
&& !detail.contains("++") && !detail.contains("--")
|
||||
&& !detail.contains("<<") && !detail.contains(">>");
|
||||
&& !detail.contains("<<") && !detail.contains(">>")
|
||||
&& !detail.contains("*");
|
||||
}
|
||||
firstChildTree << n.children().value_or(QList<AstNode>());
|
||||
}
|
||||
@@ -2826,6 +2832,19 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
|
||||
return false;
|
||||
if (it->hasConstType())
|
||||
return false;
|
||||
|
||||
if (it->kind() == "CXXMemberCall") {
|
||||
if (it == path.rbegin())
|
||||
return false;
|
||||
const QList<AstNode> children = it->children().value_or(QList<AstNode>());
|
||||
QTC_ASSERT(!children.isEmpty(), return false);
|
||||
|
||||
// The called object is never displayed as an output parameter.
|
||||
// TODO: A good argument can be made to display objects on which a non-const
|
||||
// operator or function is called as output parameters.
|
||||
return (it - 1)->range() != children.first().range();
|
||||
}
|
||||
|
||||
if (it->kind() == "Member" && it->arcanaContains("(")
|
||||
&& !it->arcanaContains("bound member function type")) {
|
||||
return false;
|
||||
@@ -2911,8 +2930,11 @@ static void semanticHighlighter(QFutureInterface<HighlightingResult> &future,
|
||||
}
|
||||
if (token.modifiers.contains(QLatin1String("declaration")))
|
||||
styles.mixinStyles.push_back(C_DECLARATION);
|
||||
if (token.modifiers.contains(QLatin1String("static")))
|
||||
styles.mixinStyles.push_back(C_STATIC_MEMBER);
|
||||
if (token.modifiers.contains(QLatin1String("static"))) {
|
||||
if (styles.mainStyle != C_FIELD && styles.mainStyle != C_TEXT)
|
||||
styles.mixinStyles.push_back(styles.mainStyle);
|
||||
styles.mainStyle = C_STATIC_MEMBER;
|
||||
}
|
||||
if (isOutputParameter(token))
|
||||
styles.mixinStyles.push_back(C_OUTPUT_ARGUMENT);
|
||||
qCDebug(clangdLogHighlight) << "adding highlighting result"
|
||||
|
||||
@@ -998,6 +998,10 @@ void ClangdTestHighlighting::test_data()
|
||||
<< QList<int>{C_PUNCTUATION} << int(CppEditor::SemanticHighlighter::AngleBracketOpen);
|
||||
QTest::newRow("class template instantiation (closing angle bracket)") << 384 << 22 << 384 << 23
|
||||
<< QList<int>{C_PUNCTUATION} << int(CppEditor::SemanticHighlighter::AngleBracketClose);
|
||||
QTest::newRow("static member function decl") << 395 << 17 << 395 << 30
|
||||
<< QList<int>{C_STATIC_MEMBER, C_DECLARATION, C_FUNCTION} << 0;
|
||||
QTest::newRow("static member function call") << 400 << 17 << 400 << 30
|
||||
<< QList<int>{C_STATIC_MEMBER, C_FUNCTION} << 0;
|
||||
QTest::newRow("namespace in declaration") << 413 << 4 << 413 << 26
|
||||
<< QList<int>{C_NAMESPACE} << 0;
|
||||
QTest::newRow("namespaced class in declaration") << 413 << 28 << 413 << 41
|
||||
@@ -1122,9 +1126,9 @@ void ClangdTestHighlighting::test_data()
|
||||
QTest::newRow("local variable captured by lambda") << 442 << 24 << 442 << 27
|
||||
<< QList<int>{C_LOCAL} << 0;
|
||||
QTest::newRow("static protected member") << 693 << 16 << 693 << 30
|
||||
<< QList<int>{C_FIELD, C_DECLARATION, C_STATIC_MEMBER} << 0;
|
||||
<< QList<int>{C_STATIC_MEMBER, C_DECLARATION} << 0;
|
||||
QTest::newRow("static private member") << 696 << 16 << 696 << 28
|
||||
<< QList<int>{C_FIELD, C_DECLARATION, C_STATIC_MEMBER} << 0;
|
||||
<< QList<int>{C_STATIC_MEMBER, C_DECLARATION} << 0;
|
||||
QTest::newRow("alias template declaration (opening angle bracket)") << 700 << 10 << 700 << 11
|
||||
<< QList<int>{C_PUNCTUATION} << int(CppEditor::SemanticHighlighter::AngleBracketOpen);
|
||||
QTest::newRow("alias template declaration (closing angle bracket)") << 700 << 16 << 700 << 17
|
||||
@@ -1308,6 +1312,9 @@ void ClangdTestHighlighting::test_data()
|
||||
<< QList<int>{C_PREPROCESSOR} << 0;
|
||||
QTest::newRow("built-in define 3") << 952 << 21 << 952 << 40
|
||||
<< QList<int>{C_PREPROCESSOR} << 0;
|
||||
QTest::newRow("deref operator (object)") << 960 << 10 << 960 << 11 << QList<int>{C_LOCAL} << 0;
|
||||
QTest::newRow("deref operator (member)") << 960 << 12 << 960 << 13 << QList<int>{C_FIELD} << 0;
|
||||
QTest::newRow("nested call") << 979 << 20 << 979 << 21 << QList<int>{C_LOCAL} << 0;
|
||||
}
|
||||
|
||||
void ClangdTestHighlighting::test()
|
||||
@@ -1395,6 +1402,8 @@ void ClangdTestHighlighting::test()
|
||||
QEXPECT_FAIL("non-final virtual function call via pointer",
|
||||
"clangd < 14 does not send virtual modifier", Continue);
|
||||
}
|
||||
QEXPECT_FAIL("non-const reference via member function call as output argument (object)",
|
||||
"See below", Continue);
|
||||
QEXPECT_FAIL("non-const reference via member function call as output argument (function)",
|
||||
"Without punctuation and comment tokens from clangd, it's not possible "
|
||||
"to highlight entire expressions. But do we really want this? What about nested "
|
||||
|
||||
@@ -27,5 +27,7 @@ SOURCES = \
|
||||
privateFuncDefCompletion.cpp \
|
||||
signalCompletion.cpp
|
||||
|
||||
QMAKE_CXXFLAGS += -ffoo
|
||||
|
||||
HEADERS = mainwindow.h
|
||||
FORMS = mainwindow.ui
|
||||
|
||||
@@ -2,3 +2,4 @@ TEMPLATE = app
|
||||
QT = core
|
||||
HEADERS = defs.h
|
||||
SOURCES = main.cpp
|
||||
QMAKE_CXXFLAGS += -ffoo
|
||||
|
||||
@@ -2,3 +2,4 @@ TEMPLATE = app
|
||||
CONFIG -= qt
|
||||
HEADERS = cursor.h header.h
|
||||
SOURCES = cursor.cpp main.cpp
|
||||
QMAKE_CXXFLAGS += -ffoo
|
||||
|
||||
@@ -951,3 +951,30 @@ void builtinDefines()
|
||||
const auto f2 = __FUNCTION__;
|
||||
const auto f3 = __PRETTY_FUNCTION__;
|
||||
}
|
||||
|
||||
void derefOperator()
|
||||
{
|
||||
struct S { bool operator*(); };
|
||||
struct S2 { S s; };
|
||||
S2 s;
|
||||
if (*s.s)
|
||||
return;
|
||||
}
|
||||
|
||||
struct my_struct
|
||||
{
|
||||
void* method(int dummy);
|
||||
};
|
||||
|
||||
my_struct* get_my_struct();
|
||||
|
||||
struct my_struct2
|
||||
{
|
||||
my_struct2(void* p);
|
||||
};
|
||||
|
||||
void nestedCall()
|
||||
{
|
||||
my_struct* s = get_my_struct();
|
||||
new my_struct2(s->method(0));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
TEMPLATE = app
|
||||
CONFIG -= qt
|
||||
SOURCES = highlighting.cpp
|
||||
QMAKE_CXXFLAGS += -ffoo
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG -= qt
|
||||
|
||||
SOURCES = references.cpp
|
||||
QMAKE_CXXFLAGS += -ffoo
|
||||
|
||||
Reference in New Issue
Block a user