Commit Graph

34 Commits

Author SHA1 Message Date
Eike Ziller
3d1ad9db60 Merge remote-tracking branch 'origin/4.15'
Change-Id: I1d13f3543ab4bb17f0cbfe26bbea3f154f856ca6
2021-04-20 10:42:55 +02:00
Christian Kandeler
f307c55eac ClangBackEnd: Fix mis-detection of operator<
Inside the body of a function template, clang reports a different cursor
type for operators in some cases. Make sure we don't mistake such
operator< or operator> as opening or closing a template, respectively.

Fixes: QTCREATORBUG-25596
Change-Id: Ifc357e199ea13e44ac501613639e667c333d48e3
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-04-19 07:51:24 +00:00
Christian Kandeler
c80c724b52 ClangCodeModel: Fix template highlighting bug
We need to take into account that the ">>" in constructs such as
std::vector<std::pair<int, int>> is only one token on the clang side.

Change-Id: I90f002ca56f236032f6d39c338593a2ff7590061
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-04-16 07:02:19 +00:00
Christian Stenger
98ac237b7f Unittest: Rename test cases to reflect their content
Amends b746a3e562.

Change-Id: I96e37d31be7efc72533c767c882ffa62967e7a6c
Reviewed-by: Tom Praschan <tom@praschan.de>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2021-03-22 19:59:35 +00:00
Christian Stenger
b746a3e562 Unittest: Fix expectations
Amends 5fcd52fe83.

Change-Id: I68ce291176ab8e095b09ae6f0d64d2564e52cf0f
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-03-18 10:49:48 +00:00
Christian Kandeler
5f5f38e028 ClangCodeModel: Support "parentheses" matching for ternary operator
That is, show which ":" belongs to which "?" when the cursor is on one
of them.

Fixes: QTCREATORBUG-1410
Change-Id: Ie19360b3dfc82d92c264d99a5aa1864eda66e5c8
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-02-11 08:52:17 +00:00
Christian Kandeler
d8c1e51bfe ClangCodeModel: Support highlighting angle brackets
... in template declarations and instantiations.

Fixes: QTCREATORBUG-16799
Change-Id: I82bc6411ca980ecbe2a6c70ae37580166a4b89e9
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-22 10:48:33 +00:00
Christian Kandeler
aabdbb7d9e clangbackend: More libclang cursor adjustments
Fixes: QTCREATORBUG-21856
Change-Id: I034b463238b4b8da4c36f95cacab79adf94c11eb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-30 11:35:24 +00:00
Christian Kandeler
0d12c8cba8 clangbackend: More cursor adjustments
Fixes: QTCREATORBUG-21534
Change-Id: Ia8a6f277b186bd6decdfec26bfca30b36802c1c2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-23 13:03:34 +00:00
Christian Kandeler
b0dd6b748f clangbackend: Try harder to get the proper cursor
... in cases where it appears that clang_annotateTokens() did not do
what we wanted.

Fixes: QTCREATORBUG-21522
Change-Id: I272061cb6c4b51a5d779ace5b4e06912c0a386e5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-23 09:59:27 +00:00
Christian Kandeler
e35dfd592f clangbackend: Fix highlighting for #include directives
These were falsely categorized as string literals. No one ever noticed,
because highlighting information for string literals was ignored until
baf25e4cdb.

Change-Id: Ib59fde04359aecb6da3995de1a9febbbf41b12c8
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-11-02 16:03:11 +00:00
Christian Kandeler
2b32b2e440 clangbackend: Provide highlighting for structured bindings
These are reported by libclang as "unexposed declarations".

Fixes: QTCREATORBUG-24769
Change-Id: I7a74b707f4203becabaa74b90758a7b396ee23bd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-27 11:07:44 +00:00
Christian Kandeler
ed292f3f9b clangbackend: Categorize non-const pointer arguments as output arguments
Fixes: QTCREATORBUG-24550
Change-Id: Iac4f3b133a632d7272bfe4253f8a0740e51b0952
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-21 08:08:29 +00:00
Christian Kandeler
2287def85e clangbackend: Fix crash
We cannot assume that a Q_PROPERTY name is on the same line as the
keyword.

Fixes: QTCREATORBUG-24746
Change-Id: Ic2e02291e24c1abbaf72881b540a26c82899cb2c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-09 08:06:56 +00:00
Christian Kandeler
d14be7493f ClangBackEnd: Support highlighting of alias templates
Fixes: QTCREATORBUG-24552
Change-Id: I80d2b16114234cf896173cd4104e6a5f12009f69
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-14 11:42:09 +00:00
Marco Bubke
2d520140d0 Clang: Fix system pre include search path
We now get the resource path from creator. The -fPIC case is working now
too.

Change-Id: Id191e89e6d46706748d50440038a06a349972cc9
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-04-29 12:52:05 +00:00
Ivan Donchevskii
53c407bc0c Clang: Fix build with clang-8
Clang-Tidy checks and Clazy flags updated.
CLANG-UPGRADE-CHECK done.

Change-Id: I1ca585c5c3c77a7f183719df9c262603150914e8
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-04-17 12:13:36 +00:00
Ivan Donchevskii
1b0cba38dd Clang: Fix access specifier for variables
Static members have a variable declaration kind so
we need to check their access specifiers in order to
provide proper information about tokens.

Fixes: QTCREATORBUG-22082
Change-Id: If455174bd346398a2df3499fa6cf1ea2b4e26965
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-03-12 14:19:48 +00:00
Nikolai Kosjar
4cc32d411a Clang: Fix highlighting lambda captures
This fixes the basic case, but e.g. captures with initializers, e.g.
[foo=bar] are not properly reported by libclang and thus "bar" is still
not highlighted for this case.

Task-number: QTCREATORBUG-15271
Change-Id: I1a2d465f71b0ae1a0406ef9e77d88898e8637958
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-01-03 10:31:05 +00:00
Marco Bubke
15df73a8ba Clang: Fix output arguments highlighting for constructor parameters
The are not any more shown but they are still not shown for constructor
arguments because libClang is providing the wrong argument count.

Task-number: QTCREATORBUG-21543
Change-Id: If9b6140ed4b2dedf71bd94aae0a97669cdd04e67
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-11-27 08:51:35 +00:00
Nikolai Kosjar
d52ac9a708 Clang: Fix unresolved #includes for ui_*.h headers
...with an extra parse.

Previously, the creation of an e.g. "Qt Widgets Application" from the
wizard could show code model errors in mainwindow.cpp. Depending on
timing issues, the first error is either

  1. 'ui_mainwindow.h' file not found (QTCREATORBUG-15187)
    The parse happened before the in-memory ui_mainwindow.h was
    generated by uic. The file system watcher can't help here as the
    #include was not resolved successfully. And libclang's reparse does
    not handle this case (it would need to remember all failed #include
    stats...).
    ==> Detect this case with the help of the include paths and trigger
    a full parse.

  2. or: allocation of incomplete type... (QTCREATORBUG-15187)
    The parse happened after the generation of the in-memory
    ui_mainwindow.h, but before the clangbackend received the unsaved
    file.
    ==> Fix this by also writing the content of the unsaved file to our
    behind-the-scenes-created ui_mainwindow.h.

Fixes: QTCREATORBUG-15187
Fixes: QTCREATORBUG-17002
Change-Id: I4f3a81adaa3d604746977a402c29f83fbc5b0e44
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-31 10:38:27 +00:00
Ivan Donchevskii
83a63c7914 Clang: Go through CLANG-UPGRADE-CHECK
Change-Id: Iaaaea598d020a44bcdc60a8d06ee28a1f28386bb
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-10-25 10:34:18 +00:00
Nikolai Kosjar
aa290912b8 Clang: Remove project tracking on clangbackend side
...as it is not needed. Just provide the compilation arguments as part
of the Document.

As a side effect, re-initializing the backend after a crash is cheaper
and will not freeze the UI anymore (referenced bug).

Task-number: QTCREATORBUG-21097
Change-Id: I866e25ef1fd5e4d318df16612a7564469e6baa11
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-26 10:45:41 +00:00
Ivan Donchevskii
50e5aacb02 Highlighting: Add highlighting style for punctuation
Currently only operators have their own style but not
punctuation tokens. Make possible to highlight both.

Task-number: QTCREATORBUG-20666
Change-Id: I9533e0f1bef65b86c4e4f5c9756571103584124b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-13 11:15:05 +00:00
Ivan Donchevskii
391c68cddc Unit-tests: Fix compilation and failing tests
Change-Id: I061dbd01e3838721e259df619016be1fc66987b0
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-07-11 10:25:47 +00:00
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