aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/texteditorsettings.cpp
diff options
context:
space:
mode:
authorHugo Holgersson <hugo.holgersson@logikbyran.se>2016-11-05 15:29:10 +0100
committerHugo Holgersson <hugo.holgersson@logikbyran.se>2018-04-30 15:10:12 +0000
commit142ae0cdf9310ae924b9f92812fe8b2cb3569237 (patch)
tree7ea99ff18f3e742a35835364ee26664fb866bfaa /src/plugins/texteditor/texteditorsettings.cpp
parentbb6eae5c3bda7692f1ad817cc869218df87e7451 (diff)
Clang: Add semantic C++ operator-token styling
We used to style overloaded operators in the same way as C++'s built-in operators. There was no way to tell if a + token would call a operator+() function or not. Now, if an operator is overloaded (redefined), we give it the "Overloaded Operator"-mixin so users can style it differently. Note: Calls to overloaded 'new' and 'delete' are not highlighted by "Overloaded Operator". This is because clang today always maps these to CXCursor_CXXNewExpr and CXCursor_CXXDeleteExpr with cursor.spelling == "" (empty string). So there is no (?) quick way for us to tell if a new/delete-token was overloaded or not. After follow-ups, follow symbol will work for operator overload usages in current translation unit. Commit is appended by Ivan Donchevskii. Task-number: QTCREATORBUG-19659 Change-Id: I157855d482a61ad2059642a1ee982089fcb7d312 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/plugins/texteditor/texteditorsettings.cpp')
-rw-r--r--src/plugins/texteditor/texteditorsettings.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp
index 9ab2bfb98b..64a618f6fb 100644
--- a/src/plugins/texteditor/texteditorsettings.cpp
+++ b/src/plugins/texteditor/texteditorsettings.cpp
@@ -226,7 +226,8 @@ TextEditorSettings::TextEditorSettings()
tr("Reserved keywords of the programming language except "
"keywords denoting primitive types."), Qt::darkYellow);
formatDescr.emplace_back(C_OPERATOR, tr("Operator"),
- tr("Operators (for example operator++ or operator-=)."));
+ tr("Non user-defined language operators.\n"
+ "To style user-defined operators, use Overloaded Operator."));
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,6 +314,10 @@ 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,