Commit Graph

98 Commits

Author SHA1 Message Date
Marco Bubke
e571220663 Clang: Add top system includes to include collector
If we want to split the project part we have to filter out the top system
includes.

Task-number: QTCREATORBUG-21345
Change-Id: I258fa33ac39bd94b4699f4f39923d6ad274c1dc7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-25 13:34:52 +00:00
Marco Bubke
391cfab5d7 Clang: Add progress bars for creating PCHs and indexing
Task-number: QTCREATORBUG-21112
Change-Id: Ie0c00a58f479a2fe7cbc7322490808509733ff0f
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-08 08:20:22 +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
Marco Bubke
4e6d09d8e1 Clang: Reuse thread based pipeline for pch creation
The pch creation so far used signal and slots but there was no explicit
pipeline. This patch is introducing the same architecture like the
refactoring plugin. It is filtering out older project parts from the
pipeline.

Change-Id: Iaa6bd2ca1272231b97ebe1f5f7b2ce8e43bc590c
Task-number: QTCREATORBUG-21111
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-24 14:33:05 +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
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
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
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
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
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
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
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
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
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
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
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
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
Marco Bubke
de4f6301e6 Clang: Process SymbolKind and SymbolTags with the indexer
We add the infrastructure to compute the SymbolKind and SymbolTags in the
indexer. Later we have to add more for templates, virtual functions etc..

Change-Id: I9203c5cfbfffed3065337292010de5fce5736453
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-03-27 14:45:58 +00:00
Marco Bubke
53454b0f79 Clang: Use PCHs for indexing
As generating the AST is quite expensive it would be very useful to cache
the not changed include. So we generate PCHs for include outside of a
project part. With this change this PCHs are used by the indexer.

For that they are save to the symbol database by the PCH manager and when
fetched by the symbol indexer.

Change-Id: I7a5b07cfb32d72d50dc52d2b108cd41727a7bfc7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-03-22 13:26:24 +00:00
Marco Bubke
1f0562742e Clang: Add lastModified to the precompiled header
It is important to know then the PCH generation started, so we can compare
the header file time stamps against it.

Change-Id: Id8ee91e886c153d9d4a37cc0438c682f2098f7fa
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-03-20 14:04:00 +00:00
Marco Bubke
b5c3d5a40d Clang: Improve ProjectPartArtefact
Empty strings were only handled by accident and wrongly formatted ones
were never handled. Now we do nothing for empty strings and throw an
exception from wrongly formatted strings. The exceptions are very helpful
in the test code because the show errors the the testing data.

Change-Id: I87d1678eda7502fdc3f74f51fad491803d28582b
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-21 14:17:09 +00:00
Ivan Donchevskii
dacfc611c5 Clang: Add highlighting types for ObjectiveC
Builtin code model supports ObjectiveC classes,
properties, etc. We can easily get the same
information from clang.

Change-Id: Iede5e177d4932f404e4ccb81ae356eee8faffb71
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-02-20 13:34:37 +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
Marco Bubke
56f79feebf Clang: Introduce CompilerMacro
We want not only the name but the value of the macro too. So we can
compare if anything has changed.

Change-Id: Ie59caf8cbf54d108f9e15299d25306a406b5c40d
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-15 09:58:53 +00:00
Marco Bubke
29a4419c07 Clang: Update symbol database if file has changed
The code in the symbol indexer is quite similar, but still different
enough to prevent easy reuse of the function.

Change-Id: I47907d90066da922eafe8ff3cce124ea47ea4a0a
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-14 15:06:58 +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
Marco Bubke
c4220041a6 Clang: Rename FileInformation in FileStatus
It's more near to the Unix convention and it has a plural too.

Change-Id: I53f85911d8fcbaadba9947c70e9a375dc6995ed5
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-08 16:49:43 +00:00
Marco Bubke
6976341e4b UnitTests: Fix printing warning for not handled enumeration
Change-Id: Ie590fff1d7a18552fadb34319a1423a6e0855df3
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-08 16:49:33 +00:00
Ivan Donchevskii
d81580b7a3 Clang: extra clangbackend job to collect full token info
Limit document annotations job to only highlighting data
collection and move more expensive calls into separate job
that runs after it.

Change-Id: Ie792a3f741ac45c81033dd5b3a20ed061604f927
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-02-02 07:01:59 +00:00
Ivan Donchevskii
bdd5066665 Clang: introduce more data in TokenInfo
Data added:
- return type spelling for functions
- parent spelling
- access specifier for class fields and methods
- storage class

New highlighting types are added, therefore
types are now categorized by class, struct, etc.

Change-Id: I1739b94a6f777045fde655060d8b9a12b6e0889b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-02-02 07:01:28 +00:00
Marco Bubke
048224bef1 Clang: Collect source dependencies
It is quite easy because we track the include directives in the
preprocessor callbacks.

Change-Id: I2d7bd67b31f50c0d8d4a46c57e83dffa0c558dc7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 15:06:09 +00:00
Marco Bubke
70ab43ca62 Clang: Get file informations from symbols collector
We need the same information like file size and the last modification time
to check if a file has changed. This information will be saved to the
database.

Change-Id: Icf8eb9b6553945a563887e11aff9539c9b300b66
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 15:03:56 +00:00
Marco Bubke
8b85b095b2 Clang: Rename defineName in macroName
Change-Id: Iaf8da991032e5ed4726384c051290a77887351fa
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 14:57:34 +00:00
Marco Bubke
0f8befacd3 Clang: On the road to update and preprocessor support
This patch has grown in a quite big change set and it is really hard to
divide it in different parts.
V2::ProjectPartContainer is now using FileIds instead of file paths. This
cleans code up because it is a big step in the direction that internally
only file ids are used. But it is depending on the file cache, so the
file cache has to be provided as an argument. There is now an interface for
transactions too which are ease the testing of them and enables the support
of preprocessor. It adds macros as symbols and is saving used macros. The
used macro support is enabling update improvements because only if a
changed macro is used it needs to be recompiled. This is still in flux
and can be changed in later patches.

Change-Id: I492a2c9af1201d40fdd9f46a0045f7878bbbaa3d
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-29 13:47:09 +00:00
Marco Bubke
fb0b5d9d9b Clang: Make it more clear that the FilePathId.filePathId is not shared
The name fileNameId could imply that the id shared for the same file name
which is not the case.

Change-Id: I27310a8994c2d9e9bb0f0aed2094bd988309c710
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-22 13:22:30 +00:00
Eike Ziller
115afed94b Merge remote-tracking branch 'origin/4.6'
Conflicts:
	tests/unit/unittest/gtest-creator-printing.cpp
	tests/unit/unittest/gtest-creator-printing.h

Change-Id: I43d2571617bfbf41c0fcf23502ab77975540eba4
2018-01-17 09:30:57 +01:00
Nikolai Kosjar
76c25bcd6a Clang: Provide tooltips
This includes also the query data for the help system (F1) for an
identifier under cursor.

Regressions (libclang changes necessary):
 - Function signatures do not contain default values.
 - Aliases are not resolved for/at:
   - template types
   - qualified name of a type

Fixes/Improvements:
 - Resolve "auto"
 - On a template type, show also the template parameter.
 - For a typedef like
     typedef long long superlong;
   the tooltip was "long long superlong", which was confusing.
   Now, "long long" is shown.

New:
 - Show first or \brief paragraph of a documentation comment.
 - Show size of a class at definition.
 - Show size of a field member in class definition.

Task-number: QTCREATORBUG-11259
Change-Id: Ie1a07930d0e882015d07dc43e35bb81a685cdeb8
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-01-16 15:32:15 +00:00
Marco Bubke
15ed2691bf UnitTests: Fix printing of text
Change-Id: I7e8ebc2932be6e01d7776e58e462935ff857b0e5
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-16 14:01:01 +00:00
Marco Bubke
5d088e9df5 UnitTests: Cleanup unit tests
There was still unneeded PrintTo functions and gtest includes.
It is now possible to use MockFunction for callbacks.

Change-Id: Ie5875c3697069a37b48c2f2022f1f8c21f1c794f
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-16 14:00:28 +00:00
Ivan Donchevskii
7a7123b1bc Clang: add globalFollowSymbol to RefactoringEngine
Allows to follow outside of current TU.

Change-Id: Ieea2fd72bfdf6d60a988b40efcf2f41c5a71d045
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-12-14 14:25:14 +00:00
Marco Bubke
bb62fd3e56 Clang: Move printing functions in clang support to unit tests
The printing functions are only used by the unit tests and they use an
external API. So we can easily move them to the printing functions in
the unit test project. We have to move the TokenInfo print functions too
because the depend on other print functions. The rest of the print
functions will be moved in other patches.

Change-Id: I87c452f8ca40687ec47de675ba6bee13efa5655b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-12-13 17:24:59 +00:00
Marco Bubke
b9d268977e Clang: Add usage functions to symbol query
Change-Id: If68a5119c863e616fea40275136d028abcf441f3
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-10-23 18:13:44 +00:00
Marco Bubke
d2e15e5f1e Clang: Add file cache
The database is using file path integer ids to handle file paths because
otherwise we would save many redundant data. This patch is improving it
further with the introduction of a database based file path cache. The
entries are now divided in a directory path and file name. This is quite
handy for directory based file watching.

Change-Id: I03f2e388e43f3d521d6bf8e39dfb95eb2309dc73
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-10-05 17:36:37 +00:00
Marco Bubke
b6e12f4a1c Convert macros from plain QByteArray to a vector of structs
The old code model expected the macros as C++ formatted text
("#define Foo 42) but newer targets like the Clang codemodel expect key
value arguments like "-DFoo=42". So instead of parsing the text again and
again we use an abstract data description.

Task-number: QTCREATORBUG-17915
Change-Id: I0179fd13c48a581e91ee79bba9d42d501c26f19f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-09-14 15:23:56 +00:00
Tim Jenssen
6fe90532dc Utils: Add offset to search results
Offset are better to compute the length of a text range. The only problem
is that we get them for utf8 because that is the text representation of
source file. QTextDocument is Utf16 based, so it can not binary represent
the source file. Actually I do not see a simple performing workaround for
it.

Change-Id: Id615e1ee6a6e85c6ecc4f8044e275142409d9b46
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-23 12:33:34 +00:00