forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user