Commit Graph

827 Commits

Author SHA1 Message Date
Marco Bubke
3abaf647d0 Add system include path to HeaderPath and merge ProjectPartHeaderPath
System include paths are appended after other includes by the compiler. So
we should set them as system includes and not as normal includes. Otherwise
we change the include order. Headers in system include paths are not
cluttering the screen with unwanted warning and by the way improve
performance too.

ProjectPartHeaderPath was a dopperganger of HeaderPath, so we merged them.

Change-Id: I7c394b4098b697de79761499ffcd5913cc02d652
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-09-10 09:31:32 +00:00
Marco Bubke
2a30f0e5d6 Clang: Improve generated files handling
Generated files are referenced by the system collector directly to set the
unsaved files.

Change-Id: I24be3ee544b7824b8b0e518eafd409f32bd002ab
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-06 11:26:00 +00:00
Marco Bubke
3d9974db95 Utils: Fix small string
Change-Id: I6a746eb28c6c803b9ade9f626a950cf93ba6fe99
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-03 14:26:05 +00:00
Marco Bubke
7cac843343 ClangRefactoring: Remove unused code
Change-Id: I752d688039e8bb85654fd54b61a0c8a4e6677954
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-03 12:14:24 +00:00
Marco Bubke
a86867eb8a Clang: Introduce parallel indexing
Change-Id: I522cb18e6d24b7dbed5d5dfa3a732e5b3b5113bb
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-03 12:13:10 +00:00
Marco Bubke
2f41886c4b ClangRefactoring: Process tasks after a task has been finished
It could be that processTasks is executed before the future is finished
but in that case there are other tasks which will be called later.

Change-Id: I9b1bfb6fdd642f23842b9c70d60d5b1552193b99
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-03 09:40:03 +00:00
Ivan Donchevskii
8b6a16c95b Clang: Fix completion after '{'
Follow-up fix for 8d0391a4f9.

Do not complete after '{' coming not after an identifier.
Take constructor completions only for '{' and function
completions only for '('. Filter constructor completions by
class/struct type.

Task-number: QTCREATORBUG-21004
Change-Id: I7ae2d6bee23cf907648c42b93eb12742942833f6
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-30 13:36:52 +00:00
Marco Bubke
b2c3e683cf ClangRefactoring: Add SymbolIndexerTaskScheduler
The scheduler is managing the asynchronous tasks by using the symbols
collector manager. Every symbols collector can be used by only one thread,
so the we have to pass the symbols collector around by the future interface
to make the available again after a task is finished.

Change-Id: Ic2eeaa986c2d93978d043216c46e8cb38cea769f
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-27 13:46:34 +00:00
Marco Bubke
5bd7af7a90 ClangRefactoring: Add SymbolIndexerTaskQueue
A first step for concurrent index task.

Change-Id: I9a0dba9f4a67ee605281516785697045b34e2694
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-27 09:17:39 +00:00
Marco Bubke
6fba0be280 ClangRefactoring: Improve symbol parsing
Declarations are only indexed if their file has been changed and references
has to be indexed if the file or any included file has been changed.

Change-Id: I07c6de1379bce2462c1e0fad34d4378a3da4397b
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-27 08:51:29 +00:00
Marco Bubke
aca14a36e9 Clang: Use only filePathId for comparison
The filePathId is already unique and the directoryId is there only to
improve the access time for the directory. So it is already strongly
ordered if we compare only filePathId.

Change-Id: I67255bea1d36d41a59421eeb51964440c053b1e3
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-23 08:42:10 +00:00
Marco Bubke
d02d9b0f43 ClangRefactoring: Remove FileCache from SymbolStorage
It is not used.

Change-Id: Iaff5a34dfe613f0a627e0a3a727af1130ad2b522
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-23 08:11:29 +00:00
Marco Bubke
876d068011 UnitTests: Move printing functions to creator printing file
Change-Id: I09043347370d4fad623f8e803d4ef0f147fffa21
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-23 08:06:25 +00:00
Ivan Donchevskii
8c21a7a396 Clang: Fix local references for operator arguments
Workaround for wrong cursor annotated by Clang.

Use clang_getCursor in case of the variable used as
operator argument to get the proper cursor.

Task-number: QTCREATORBUG-20966
Change-Id: Idb195bffc2296f3fae27595cf9c43c9e6b2c5cd0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-21 10:41:30 +00:00
Ivan Donchevskii
8d0391a4f9 Clang: Treat brace initialization as constructor completion
Try to complete constructor after left brace with fallback
to normal completion.

Task-number: QTCREATORBUG-20957
Change-Id: I6c33790a3ee1e623a3d8abe9a44cfd821b6f3106
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-21 10:40:04 +00:00
Marco Bubke
39e78bd3f6 Clang: Don't index already indexed symbols
We don't index system headers any more and introduce a first step to
decrease double indexing. For that we introduces the SourcesManager which
so far tells you only if a file was already indexed for a certain time
stamp.

Change-Id: Icde54465693ca84a622764c595635cac365c0111
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-20 13:16:52 +00:00
Marco Bubke
cc0db43c34 Clang: Extent sources manager with dependency
For many index cases such a function call it is needed to check if
any of the included files are changed because the function which is called
could be changed too.

Change-Id: Ibe0f43426c735d39072f284cad075dd4dc6f99c0
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-20 13:16:19 +00:00
Marco Bubke
6a541fd692 Clang: Add sources manager
Indexing source files multiple times is unneeded overhead in many cases.
The source manager is a support class to handle that cases.

Change-Id: Id737eaa9a691c54563279562833493a221eb3431
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-20 08:57:28 +00:00
Marco Bubke
b592339b4d Clang: Don't parse system headers
Change-Id: I6474fbe4f43daaac930ad6ba49fd9cb3145a3bbd
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-14 15:03:41 +00:00
Marco Bubke
4195fce68f ClangRefactoring: Integrate generated files
This is an intermediate step to handle the indexing of the project parts
completely. The generated files are now independently handled from the
project parts. We still not handle the case the a file is indexed but the
generated file is not provided. This will be done in a different patch.
All provided data is now sorted too to improve merging.

Change-Id: I09712b99217a881ec0a233d09aea8659fb787324
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-14 12:47:03 +00:00
Ivan Donchevskii
62e776aa8e Clang: Provide include directory only for libclang
Only libclang has issues with the include directory
search therefore undefining include folders makes sense
only for libclang options builder.

Change-Id: Ie3f62f5f3a89503e6e0ab59e18889e92425c3abc
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-08 14:07:13 +00:00
Ivan Donchevskii
44b931f7f5 Unit: Fix unit-tests
Since we now destinguish FunctionDefinitionCompletionKind from
FunctionCompletionKind use the proper enum in some tests.

Change-Id: Ia3a47c4632ce4d2a1e42de87289dd08d4cac6ef7
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-08 14:06:10 +00:00
Marco Bubke
19b0d837e5 Clang: Add GeneratedFiles
To manage generated files it is very useful to have a class which adds,
updates and remove them.

Change-Id: Ifc842400e17d1a51adf723c32996a080f0348f57
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-08 13:15:11 +00:00
Marco Bubke
0bef7610a1 ClangRefactoring: Move generated files to own messages
There must be a management about it but this will be added in a different
change set.

Change-Id: I47b6ce7f671f1c8ae07083d6d99c534069e3cc1a
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-08 13:13:35 +00:00
Marco Bubke
613db15cea ClangRefactoring: Add project part queue
Change-Id: Id137233a042181553ff7bb766c9dafa6eb9cf046
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-08 13:07:26 +00:00
Orgad Shaneh
8654677015 UnitTest: Remove unused function
This amends commit da4be3fdb7.

Change-Id: Iffdf4581b7f29fc846c944e24f33e27e003f1b3b
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-07-31 10:10:19 +00:00
Ivan Donchevskii
da4be3fdb7 Clang: Use new libclang code completion fix-its feature
Each completion coming from libclang now has it's own
list of fix-its which are required to be applied before
completion itself.

This saves one extra reparse cycle and gives an ability
to provide both kinds of completion (initial and corrected
one) for cases like shared_ptr, unique_ptr or any other
class with overloaded arrow operator.

Each of these extra fix-its is applied together with
corresponding completion dircetly before completion itself.

Change-Id: Ide37e45bb15fa2f1375cd6b86ecd43ced3593046
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-07-27 07:34:44 +00:00
Orgad Shaneh
993f893a9c UnitTest: Add missing highlighting enums display
Change-Id: Id35c328cf98896a39c9c6c0e641b1046720d78ad
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-07-25 07:57:30 +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
Ivan Donchevskii
e1111d4570 Clang: Use built-in follow symbol for virtual methods
ClangCodeModel currently does not provide a list of overrides.
Therefore it makes sense to use ClangCodeModel result for
virtual method only if built-in code model does not find anything.

Task-number: QTCREATORBUG-20584
Change-Id: I5b4fac7974f990e741d3438ab61827670a8ce8d8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-15 12:15:22 +00:00
Nikolai Kosjar
cbd4d05423 Clang: Fix processing documents if multiple are opened at once
Reproducable with
 1. $ ./qtcreator a.cpp b.cpp
 2. Switch to a.cpp => no highlighting

Because ClangEditorDocumentProcessor does asynchronous processing, the
backend might receive a DocumentsOpenedMessage where the document is not
the current editor (happens for a.cpp in the example). When switching to
that document, the initial jobs were not processed as the document was
not dirty.

Address this case by also checking for documents that have a revision of
1 and are not dirty. Unify adding the annotations jobs to ensure that
not more than needed are run.

Change-Id: I14030260842f97d58280235e763c8d7490705f8d
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-06-08 06:32:40 +00:00
Nikolai Kosjar
f01fbcb789 Clang: Clean up some IPC names
This is long overdue since some names were simply wrong and/or
misleading. Also, some of the old names were long enough to almost get
crazy.

The renaming starts from ClangCodeModelServerInterface and
ClangCodeModelClientInterface and affects usages and related functions.

For the ClangCodeModelServerInterface, categorize the messages in
 - messages that require a response (request*)
 - notification messages (the remaining ones)

Change-Id: I5342ed8e0d87404ee72f3c3766fd8ef7505defb1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-06-04 09:54:01 +00:00
Ivan Donchevskii
4e4bd4909a Clang: Use follow symbol result from clang when global fails
When built-in code model fails to follow symbol under cursor
fall back to the clang result even if it only follows
to the decalration.

Change-Id: I22d8c5fee6ab7594b1d1b7ce8104414db28383c7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-06-04 08:48:33 +00:00
Nikolai Kosjar
69dec8a9f8 Clang: Create preamble on first parse
...now that parsing and creating the preamble is faster due to the
skipped function bodies.

As a consequence, we can remove all the extra jobs that were needed to
get an initial AST faster.

Change-Id: I79a66b8a0e8a180850af6daf353d9a679089bbb1
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-24 12:33:55 +00:00
Ivan Donchevskii
e92b46073e Clang: Fix unit-test failures caused by Clang update
Failing tests:
TokenProcessor.TemplateFunctionCall
TokenProcessor.TemplateClassDeclaration

Do not introduce fatal error in test source file.
Otherwise template function is not recognized anymore.

Such template calls were also broken before but could
provide a valid Cursor kind. So it's a minor regression
in Clang but does not change anything for Qt Creator user.
Bug is reported: https://bugs.llvm.org/show_bug.cgi?id=37550

Change-Id: I788e8d9f88141cfefc6bbde77f36c459d91aff0b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-24 09:44:30 +00:00
Ivan Donchevskii
da2e6b982b Unit tests: Fix undefined behavior in NativeFilePathView tests
Do not counstruct NativeFilePathView from temporary object.

Change-Id: Ifcd6bc4878f6949e98de44089a2c2b3feca4795a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-05-22 09:23:31 +00:00
Nikolai Kosjar
319daa2612 Clang: Require LLVM/Clang >= 6.0.0
Adapt versions and tests, remove code assuming clang < 6.0.

Switch also to our custom repositories instead of dealing with patch
files.

LLVM/Clang 6 was released on 09 Mar 2018.

Task-number: QTCREATORBUG-18535
Task-number: QTCREATORBUG-18552
Change-Id: I0ec2c2f56265e161ae7cbb5b03e7b8a182ba6cc6
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-17 12:46:37 +00:00
Nikolai Kosjar
2dde82112e Clang: Fix -Wswitch warning regarding OverloadedOperator
gtest-creator-printing.cpp:493:12: warning: enumeration value
   'OverloadedOperator' not handled in switch [-Wswitch]

Change-Id: Ic28dcbcc402a8f5c0f2bd284cc9b6fd560221208
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-08 11:32:20 +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
7b2774dea1 Clang: Use current TranslationUnit follow symbol based on clang code model
It might be quite a safe replacement which can fix builtin
code model issues.

If clang code model fails to follow symbol or does not find
a definition when it's required we fall back to the built-in
code model to proceed with project-wide follow symbol.

To make it almost a full replacement tweak include paths underline
on cursor hover to match what we have in built-in code model.

SIGNAL/SLOTS macros are not yet supported but can be handled
in follow up patch.

Task-number: QTCREATORBUG-19477
Change-Id: Id1611511d661a8aaf3e93502b4e03e1792c7c1d3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-26 10:27:42 +00:00
Ivan Donchevskii
ef660d8bd0 Clang: Simplify name and type in FullTokenInfo for functions
Take Cursor displayName instead of token name.
From now on type spelling can serve the return type
role for functions because together with 'token' member
they form the full type.

Change-Id: Ic8eec533f4a11458f99f070b6a6aa80714097b4d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-23 07:59:40 +00:00
Eike Ziller
428fcb476b Merge remote-tracking branch 'origin/4.6'
Conflicts:
	src/libs/utils/settingsaccessor.cpp
	src/plugins/autotest/autotestplugin.cpp
	src/plugins/git/gitclient.cpp
	src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
	src/plugins/qbsprojectmanager/qbsrunconfiguration.h

Change-Id: I65f143cad18af509a2621d6c5925abbd038ea70f
2018-04-13 10:54:42 +02:00
Marco Bubke
438b5736d5 UnitTests: fix spelling
Change-Id: Ib6a94c0fac5fe6ead62a440dbe8c6368cfd7dd57
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-04-12 14:38:51 +00:00
Marco Bubke
4b0bcbdcb6 Clang: Locator filter for the symbol database
There are no symbol queries for the locator filters. The signature
generation is still not implemented but for simple cases it should work.

Change-Id: Ic6b04fbe1e7e057892f194ac139615c47d6ec33f
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-12 13:12:24 +00:00
Marco Bubke
ee85cf4518 Clang: Store the symbol kind in the database
It is cleaning up some other stuff too.

Change-Id: I75274356fd35f2ee8c84aedf8839c67506ab2355
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-12 13:12:08 +00:00
Marco Bubke
b0fd6c30ce Clang: Distinguish between Enum and Records
Creator is distinguishing enumerations and records, so we should do too.

Change-Id: I114cfd207464abd9afd96c26c7504cf8a3a1cb8c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-04-12 13:11:51 +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