diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Token.h | 3 | ||||
-rw-r--r-- | src/libs/clangsupport/clangsupport_global.h | 1 | ||||
-rw-r--r-- | src/libs/clangsupport/tokeninfocontainer.cpp | 1 | ||||
-rw-r--r-- | src/libs/clangsupport/tokeninfocontainer.h | 2 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp | 2 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/clangutils.cpp | 3 | ||||
-rw-r--r-- | src/plugins/cppeditor/cpphighlighter.cpp | 2 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditorconstants.h | 1 | ||||
-rw-r--r-- | src/plugins/texteditor/texteditorsettings.cpp | 13 | ||||
-rw-r--r-- | src/tools/clangbackend/source/fulltokeninfo.cpp | 2 | ||||
-rw-r--r-- | src/tools/clangbackend/source/tokeninfo.cpp | 8 |
11 files changed, 25 insertions, 13 deletions
diff --git a/src/libs/3rdparty/cplusplus/Token.h b/src/libs/3rdparty/cplusplus/Token.h index 9d30911169..e548b9480a 100644 --- a/src/libs/3rdparty/cplusplus/Token.h +++ b/src/libs/3rdparty/cplusplus/Token.h @@ -332,6 +332,9 @@ public: inline bool isOperator() const { return f.kind >= T_FIRST_OPERATOR && f.kind <= T_LAST_OPERATOR; } + inline bool isPunctuation() const + { return f.kind >= T_FIRST_PUNCTUATION && f.kind <= T_LAST_PUNCTUATION; } + inline bool isPunctuationOrOperator() const { return f.kind >= T_FIRST_PUNCTUATION_OR_OPERATOR && f.kind <= T_LAST_PUNCTUATION_OR_OPERATOR; } diff --git a/src/libs/clangsupport/clangsupport_global.h b/src/libs/clangsupport/clangsupport_global.h index 75454a5288..7b2d62ab50 100644 --- a/src/libs/clangsupport/clangsupport_global.h +++ b/src/libs/clangsupport/clangsupport_global.h @@ -86,6 +86,7 @@ enum class HighlightingType : quint8 Preprocessor, PreprocessorDefinition, PreprocessorExpansion, + Punctuation, Label, Declaration, FunctionDefinition, diff --git a/src/libs/clangsupport/tokeninfocontainer.cpp b/src/libs/clangsupport/tokeninfocontainer.cpp index 2744200c60..41c0a69f7e 100644 --- a/src/libs/clangsupport/tokeninfocontainer.cpp +++ b/src/libs/clangsupport/tokeninfocontainer.cpp @@ -53,6 +53,7 @@ static const char *highlightingTypeToCStringLiteral(HighlightingType type) RETURN_TEXT_FOR_CASE(OutputArgument); RETURN_TEXT_FOR_CASE(PreprocessorDefinition); RETURN_TEXT_FOR_CASE(PreprocessorExpansion); + RETURN_TEXT_FOR_CASE(Punctuation); RETURN_TEXT_FOR_CASE(Namespace); RETURN_TEXT_FOR_CASE(Class); RETURN_TEXT_FOR_CASE(Struct); diff --git a/src/libs/clangsupport/tokeninfocontainer.h b/src/libs/clangsupport/tokeninfocontainer.h index d01d0f92eb..2b8e01e769 100644 --- a/src/libs/clangsupport/tokeninfocontainer.h +++ b/src/libs/clangsupport/tokeninfocontainer.h @@ -138,7 +138,7 @@ public: return extraInfo.declaration && types.mainHighlightingType != HighlightingType::LocalVariable - && ((types.mainHighlightingType == HighlightingType::Operator) + && (types.mixinHighlightingTypes.contains(HighlightingType::Operator) == extraInfo.token.startsWith("operator")); } diff --git a/src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp b/src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp index 795941f6ec..125d4405a7 100644 --- a/src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp +++ b/src/plugins/clangcodemodel/clanghighlightingresultreporter.cpp @@ -62,6 +62,8 @@ TextEditor::TextStyle toTextStyle(ClangBackEnd::HighlightingType type) case HighlightingType::PreprocessorDefinition: case HighlightingType::PreprocessorExpansion: return TextEditor::C_PREPROCESSOR; + case HighlightingType::Punctuation: + return TextEditor::C_PUNCTUATION; case HighlightingType::Declaration: return TextEditor::C_DECLARATION; case HighlightingType::FunctionDefinition: diff --git a/src/plugins/clangcodemodel/clangutils.cpp b/src/plugins/clangcodemodel/clangutils.cpp index 725042488b..9638cfa2dd 100644 --- a/src/plugins/clangcodemodel/clangutils.cpp +++ b/src/plugins/clangcodemodel/clangutils.cpp @@ -235,7 +235,8 @@ int clangColumn(const QTextBlock &line, int cppEditorColumn) ClangBackEnd::StorageClass storageClass = extraInfo.storageClass; if (mainType == ClangBackEnd::HighlightingType::VirtualFunction || mainType == ClangBackEnd::HighlightingType::Function - || mainType == ClangBackEnd::HighlightingType::Operator) { + || token.types.mixinHighlightingTypes.contains( + ClangBackEnd::HighlightingType::Operator)) { if (storageClass != ClangBackEnd::StorageClass::Static) { switch (access) { case ClangBackEnd::AccessSpecifier::Public: diff --git a/src/plugins/cppeditor/cpphighlighter.cpp b/src/plugins/cppeditor/cpphighlighter.cpp index 7d5648646c..075791b021 100644 --- a/src/plugins/cppeditor/cpphighlighter.cpp +++ b/src/plugins/cppeditor/cpphighlighter.cpp @@ -203,6 +203,8 @@ void CppHighlighter::highlightBlock(const QString &text) formatForCategory(C_PRIMITIVE_TYPE)); } else if (tk.isOperator()) { setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_OPERATOR)); + } else if (tk.isPunctuation()) { + setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_PUNCTUATION)); } else if (i == 0 && tokens.size() > 1 && tk.is(T_IDENTIFIER) && tokens.at(1).is(T_COLON)) { setFormat(tk.utf16charsBegin(), tk.utf16chars(), formatForCategory(C_LABEL)); } else if (tk.is(T_IDENTIFIER)) { diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 504a6d8ea2..56678f1812 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -60,6 +60,7 @@ enum TextStyle : quint8 { C_PRIMITIVE_TYPE, C_OPERATOR, C_OVERLOADED_OPERATOR, + C_PUNCTUATION, C_PREPROCESSOR, C_LABEL, C_COMMENT, diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index ff6cb70668..8124f4ab43 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -224,9 +224,16 @@ TextEditorSettings::TextEditorSettings() formatDescr.emplace_back(C_KEYWORD, tr("Keyword"), tr("Reserved keywords of the programming language except " "keywords denoting primitive types."), Qt::darkYellow); + formatDescr.emplace_back(C_PUNCTUATION, tr("Punctuation"), + tr("Punctuation excluding operators.")); formatDescr.emplace_back(C_OPERATOR, tr("Operator"), tr("Non user-defined language operators.\n" - "To style user-defined operators, use Overloaded Operator.")); + "To style user-defined operators, use Overloaded Operator."), + Format::createMixinFormat()); + formatDescr.emplace_back(C_OVERLOADED_OPERATOR, + tr("Overloaded Operators"), + tr("Calls and declarations of overloaded (user-defined) operators."), + Format::createMixinFormat()); formatDescr.emplace_back(C_PREPROCESSOR, tr("Preprocessor"), tr("Preprocessor directives."), Qt::darkBlue); formatDescr.emplace_back(C_LABEL, tr("Label"), tr("Labels for goto statements."), @@ -313,10 +320,6 @@ TextEditorSettings::TextEditorSettings() QColor(255, 190, 0), QTextCharFormat::DotLine, FormatDescription::ShowUnderlineControl); - formatDescr.emplace_back(C_OVERLOADED_OPERATOR, - tr("Overloaded Operators"), - tr("Calls and declarations of overloaded (user-defined) operators."), - Format::createMixinFormat()); Format declarationFormat = Format::createMixinFormat(); declarationFormat.setBold(true); formatDescr.emplace_back(C_DECLARATION, diff --git a/src/tools/clangbackend/source/fulltokeninfo.cpp b/src/tools/clangbackend/source/fulltokeninfo.cpp index e850e0495c..1bf265b371 100644 --- a/src/tools/clangbackend/source/fulltokeninfo.cpp +++ b/src/tools/clangbackend/source/fulltokeninfo.cpp @@ -243,7 +243,7 @@ void FullTokenInfo::overloadedOperatorKind() { TokenInfo::overloadedOperatorKind(); - if (m_types.mixinHighlightingTypes.front() != HighlightingType::OverloadedOperator) + if (!m_types.mixinHighlightingTypes.contains(HighlightingType::OverloadedOperator)) return; // Overloaded operator diff --git a/src/tools/clangbackend/source/tokeninfo.cpp b/src/tools/clangbackend/source/tokeninfo.cpp index 68877e4032..62742c2c48 100644 --- a/src/tools/clangbackend/source/tokeninfo.cpp +++ b/src/tools/clangbackend/source/tokeninfo.cpp @@ -529,13 +529,13 @@ void TokenInfo::overloadedOperatorKind() if (inOperatorDeclaration && !isTokenPartOfOperator(declarationCursor, m_cxToken)) return; - if (m_types.mainHighlightingType == HighlightingType::Invalid) - m_types.mainHighlightingType = HighlightingType::Operator; + m_types.mixinHighlightingTypes.push_back(HighlightingType::Operator); m_types.mixinHighlightingTypes.push_back(HighlightingType::OverloadedOperator); } void TokenInfo::punctuationOrOperatorKind() { + m_types.mainHighlightingType = HighlightingType::Punctuation; auto kind = m_originalCursor.kind(); switch (kind) { case CXCursor_CallExpr: @@ -557,9 +557,7 @@ void TokenInfo::punctuationOrOperatorKind() case CXCursor_BinaryOperator: case CXCursor_CompoundAssignOperator: case CXCursor_ConditionalOperator: - m_types.mainHighlightingType = HighlightingType::Operator; - break; - default: + m_types.mixinHighlightingTypes.push_back(HighlightingType::Operator); break; } |