aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/3rdparty/cplusplus/Parser.cpp
diff options
context:
space:
mode:
authorHugo Holgersson <hugo.holgersson@logikbyran.se>2018-02-17 21:12:15 +0100
committerIvan Donchevskii <ivan.donchevskii@qt.io>2018-05-03 13:43:16 +0000
commit86aab16ea4a45b1c67637f4504afdcbd7adfd261 (patch)
tree9f5ca37597099e551390ba2b81c25860476cd22e /src/libs/3rdparty/cplusplus/Parser.cpp
parentce032552c0df8306eefa55bc049b694762e334fa (diff)
TextEditor: Highlight punctuators as Text
This change limits the set of tokens that fall under Token::isOperator(). That allows cpphighlighter.cpp to distinguish operator tokens from punctuator tokens (without changing any logic in cpphighlighter.cpp). This change moves punctuators from "Operator" to the "Text" style category where they belong. Punctuators are not operators. Punctuators are dumb text tokens. Why don't we let the clang backend alone separate these tokens for us? 1. Clang is slow on big files. Sometimes the highlighting dictated by clang is painted _seconds_ after cpphighlighter.cpp runs. CppHighlighter is way faster so we use it to "prepaint" code while clang is busy in the background. 2. Secondly, clang cannot yet handle all operator types. In particular, none if its "operator cursors" CXCursor_UnaryOperator: CXCursor_BinaryOperator: CXCursor_CompoundAssignOperator: CXCursor_ConditionalOperator: includes the -> and . operators. We still need CppHighlighter to paint those tokens. However, once clang has finished processing the file some operator tokens will be repainted. We need clang to get all operators' semantics. In particular, we need clang to tell us if < is a "smaller than"-operator or part of a template parameter like set<int>. Task-number: QTCREATORBUG-19659 Change-Id: I952cb58f7c79134b3281e2a8221425cc1d0ad263 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/libs/3rdparty/cplusplus/Parser.cpp')
-rw-r--r--src/libs/3rdparty/cplusplus/Parser.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp
index 250576edcf..05ac110245 100644
--- a/src/libs/3rdparty/cplusplus/Parser.cpp
+++ b/src/libs/3rdparty/cplusplus/Parser.cpp
@@ -4998,7 +4998,7 @@ bool Parser::parseNameId(NameAST *&name)
return parseName(name, false);
default:
- if (tok().isLiteral() || tok().isOperator()) {
+ if (tok().isLiteral() || tok().isPunctuationOrOperator()) {
rewind(start);
return parseName(name, false);
}