Commit Graph

9 Commits

Author SHA1 Message Date
Hugo Holgersson
86aab16ea4 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>
2018-05-03 13:43:16 +00:00
Ivan Donchevskii
ce032552c0 Clang: Support old-style SIGNAL/SLOT macro
Color types and enable Ctrl+click for the functions
and types inside SIGNAL/SLOT macros.

Change-Id: Ic1c0b7372fe9a73c5607b1973d75a6656c75ef0e
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-03 13:34:21 +00:00
Hugo Holgersson
142ae0cdf9 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>
2018-04-30 15:10:12 +00:00
Ivan Donchevskii
f9d95c9205 Clang: Optimize clang overview model
Build the tree in only one loop.

clangbackend generates tokens almost as fast as it
did before (about 10% slower in general).
Broken documents are more affected and take much more
time (about 300%) but it's better to have this time spent
on backend side then in QtC itself.

Task-number: QTCREATORBUG-20205
Change-Id: I34c58bca30c4494005a029abd82c7e612ecd6fb9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-12 09:15:12 +00:00
Ivan Donchevskii
84b983617f Clang: Support anonymous types in tokens
Add extra data to Keyword tokens.
Does not affect highlighting.

Change-Id: I206499ea35ee4ece5fe442665c904090cf5d90fc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-12 06:51:07 +00:00
hjk
cf4dbb4bb6 ClangSupport: Use simpler structures in some cases
The patch is mostly mechanical, but contains also a few spurious changes
from values references for some local variables, foreach -> ranged for
etc that I coulnd't resist.

Change-Id: I58f0bd972546895eb318607cbfbd7ac35caf3f23
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-06 12:55:23 +00:00
Ivan Donchevskii
8ffae6a08c Clang: Add cursor range to extra token information
Change-Id: Id410c94c79d61b8f4d5b53f937827356272b9f65
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-02-21 06:55:39 +00:00
Ivan Donchevskii
66c7629814 Clang: Properly handle Q_PROPERTY in TokenInfo
Transform Q_PROPERTY into unique AST node.
Mark different parts with types and search for parent
in FullTokenInfos.

Change-Id: Iaa1ec0c73d34773edf5605d3682bd6a290d195de
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-02-20 06:49:47 +00:00
Ivan Donchevskii
d01b474b46 Clang: Refactor TokenInfos
Remove code duplication.

Change-Id: Ib1859f2c3a04f66d0f0b669b4e93a7fc06ab8e61
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-02-12 08:03:47 +00:00