Commit Graph

853 Commits

Author SHA1 Message Date
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
497900eb3f Clang: Handle source dependencies in symbol indexer
Get the source dependencies from the collector and save them in the
symbol storage.

Change-Id: Ibc141970a100625398c1526f5bc644cc14d25c0c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 15:06:20 +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
b2d3951bde Clang: Clear used macros and file information for symbol collection
We have to clear them too otherwise we will collect them which can lead
to wrong data in the symbol database.

Change-Id: Iad7b87344caec0f27a5f8f24c214573a274db911
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 15:06:00 +00:00
Marco Bubke
89b9dfed84 Clang: Add source dependency saving to the symbol storage
The source dependencies are simply a table which connects the include file
with the included file.

Change-Id: I5454e81a2b5b98f05c7ff3f6740a6d45e01772c3
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 15:05:52 +00:00
Marco Bubke
490523fdbb Clang: Fix index for project part sources
The index has to be unique so that the inserting will be fail. We have to
add integration tests if everything is finished.

Change-Id: I4e20b90f1865d548572d2e634ac934f81da957c2
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 15:05:39 +00:00
Marco Bubke
c6f65e94c8 Sqlite: Add unique index to table
Some times we need the constraint for an index.

Change-Id: I81332238d36b88196ef03e26b4edcc1307de46e0
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 15:05:30 +00:00
Marco Bubke
c29ae225c5 Clang: Add source dependencies table
We want to track which source is dependent on which source.

Change-Id: I4b3c14be540974d69cc5026a5d081be1baceb133
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 15:05:20 +00:00
Marco Bubke
5dd24110f5 Clang: SymbolIndexer is saving the file information to the symbol storage
Change-Id: Id34ce9901c1a938e7ea14da444a9ef1b052286e5
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 15:05:10 +00:00
Marco Bubke
95ce58cf32 Clang: Add insert file information to symbol storage
We use INSERT OR REPLACE because it is simpler than the insert and update
and we provide the primary key by our self.

Change-Id: I868e040918cc6c2ed183cecc746c89bec136f974
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 15:04:51 +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
8aef667ad7 Clang: Add file informations table
We could add this properties to the sources table but then we have to
handle null values which makes the SQL statements much more complicated
and most probably slower too.

Change-Id: Ie2a1e4862b0517825292213567725d6c18abfb30
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 14:59:03 +00:00
Marco Bubke
c0b771f99c Clang: Add macro names the to project part
So we can compare later if the macro names have changed.

Change-Id: I65c5f76e07fced8df6cc7282c03430adffcf5fa8
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 14:57:44 +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
22b5bbbff3 Clang: Add defineName to ProjectPart
We need them later to find out if the defines have changes.

Change-Id: Iaaa14df3dc6f50cb286c2dac37db13c975063c1e
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 14:54:49 +00:00
Marco Bubke
8beb205ee0 Clang: Fix statement names for symbol storage
Change-Id: Ieb242baf70ffedbdcfdbdbff2b780a1ffb810cc2
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 14:52:16 +00:00
Marco Bubke
b247c4fdeb Clang: Store UsedDefines in the symbol database
We write the new defines in a temporary table and then write every new
entry in the usedDefines table, followed by remove of every entry in
usedDefines which are not in the temporary table but have a file entry in
common with one of the entries in the temporary table. At last we clean up
the temporary table.

Change-Id: Idf11ce8d17ad9ccef490578059fac08409fcc5d9
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 14:51:06 +00:00
Marco Bubke
5cd64e8049 Clang: Add usedDefines table
Change-Id: Icbffb8a0450cfdff5d4958b5cc890114aeb0d794
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 14:50:29 +00:00
Marco Bubke
5877342123 Clang: Fix typo
Change-Id: I525459bd9e28b34912960bc43eca1b776da98344
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 14:50:17 +00:00
Marco Bubke
8a280129ff Clang: Update or insert used defines in the storage by the symbol indexer
Change-Id: Id8af85976be391e17886c9947863b81d206bb575
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 14:49:44 +00:00
Marco Bubke
4f0c17bc5d Clang: Improve Macro collection
Now undefined macros are added to used macros but we filter out header
guards and dynamic libraries export. The export is quite simple but
without we would think that exports change the AST.

Change-Id: Ic16f60a6675e397dfd769c53caf77056708d8459
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 14:47:46 +00:00
Nikolai Kosjar
4f20c0d4ed Clang: Highlight invalid declarations as text
...instead of the corresponding declaration color.

Task-number: QTCREATORBUG-18686
Change-Id: Ice4d84816351af79efa286f49516c392bd80da86
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-01 14:12:58 +00:00
Eike Ziller
ecb9fae785 Merge remote-tracking branch 'origin/4.6'
Conflicts:
	share/qtcreator/qml-type-descriptions/qmlproject.qmltypes
	src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp

Change-Id: I35fb652f29a98a798be7c8b4b4c2e581eb175fb6
2018-02-01 09:58:36 +01: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
Ivan Donchevskii
d3b11926d3 Clang: fix unit-test build
Remove unit-test dependency from project.

Change-Id: I1abdbea08648c292d5c98a0c88a211c8c897cc71
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-01-29 10:20:46 +00:00
Ivan Donchevskii
2daa5c7280 Clang: Locator: Add filters for classes, includes, functions
Filters are based on symbol query where they are
not implemented yet.

Change-Id: Id826beaf6bb47a81363c36780d7254a85a9a3cc9
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-01-24 11:49:13 +00:00
Ivan Donchevskii
88c3e27722 Clang: Add locator specific methods to SymbolQuery
... and implement LocatorFilter using these methods.

Change-Id: Ie3e3ebb3a547e2b2bda49e76a199a3ccd8fe6403
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-01-24 11:49:04 +00:00
Ivan Donchevskii
92cdfc0c2a Clang: new empty locator filter classes
Introduce classes to replace builtin locator filters.

Change-Id: I5cc6f15fb0f59ea8a51b14a86301cf219cc0d6d6
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-01-24 11:48:42 +00:00
Eike Ziller
437590a999 Merge remote-tracking branch 'origin/4.6'
Change-Id: I49e8b8442e2b5edffbea19cb2bba97443ebc3d2a
2018-01-23 17:06:59 +01:00
Nikolai Kosjar
30c95c937b Clang: Take over jobs if document gets new project part
We could loose jobs if e.g. the user switched to another parse context
or shuffled project files between targets/products/project-parts while
there were still jobs in the queue.

Previously, changing the project part id of a document was a two step
process:
  1) Unregister document with old project part id
  2) Register document with new project part id
On 1), we have thrown the document processors (and thus the job queue)
away. On 2), we have created a new document. Due to this separation the
backend could not take over jobs to the new document (processor) - it
could not know that these commands belong together.

Now, we avoid the explicit unregister command. On a register command the
backend has enough context to find out what to do, it can take over
relevant jobs.

Task-number: QTCREATORBUG-18856
Change-Id: Ib68a8e62140fcfdb2de58dcd2ae955b4c2e15166
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-22 14:00:03 +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
Marco Bubke
a572b2db6a Utils: Change SmallString::toView to SmallString::toStringView
This improves the readability of the code.

Change-Id: Ifccbaaa6003636848ea48e00d92abc44f5c2e0f1
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-22 13:22:00 +00:00
Nikolai Kosjar
608e7ec245 Clang: Fix tooltips for constructors
Constructors were not handled yet, so the tooltip for e.g. the
"QString()" constructor was "void ()".

Also, since the help system has problems with overloads, show the
function signature as clang sees it and provide a help system query that
will show the documentation for the class instead of the wrong overload.

Change-Id: Idc0cf9dce6a50c323e6fd945f277c7816b0f9b34
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-22 12:33:21 +00:00
Nikolai Kosjar
2d7f1d6c8c Clang: Take over jobs if document's project changes
On registerProjectPartsForEditor() we recreated the affected
DocumentProcessors, but did not take care of the jobs that were in the
queue, which effectively could led to lost jobs. Catch up on this.

Task-number: QTCREATORBUG-18856
Change-Id: I4184e5dc6480667953f2d2081ccf39a28c092186
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-19 13:16:07 +00:00
Nikolai Kosjar
fdc88939d6 Clang: Fix ToolTipInfo.IncludeDirective test on Windows
Change-Id: I8a6d7c6d46474db4455cb9e2bc90e2e7e527e474
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-17 14:38:31 +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
640575640c UnitTests: Use MockFunction instead of home grown mock class
Change-Id: Ic0cd2fb7d073e8cf962d98b850719f4311e9f35a
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-16 14:00:34 +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
Marco Bubke
e5d1fe6620 Sqlite: Add setter for last row id
Change-Id: I15dfb997b04e285a8dfa0e2979de8457817bce3e
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-16 11:10:27 +00:00
Marco Bubke
f233f2d26d Clang: Add project parts table
Change-Id: Id2525b6664c6dc0e9d19f8d58cd26b515ae5640c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-16 11:10:21 +00:00
Orgad Shaneh
6285a6e50f CppTools: Fix build
Broke by e51683412b.

Change-Id: I68d1457931f2237a63da4ac2e34f1650b9ff6ea6
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-11 06:46:15 +00:00
Marco Bubke
2c08ddcd5a Clang: Add path notifier to symbol indexer
Change-Id: I2a605a5a5ac2511566edd9c069e84b5ec9d95279
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-10 12:38:47 +00:00
Marco Bubke
e94d88c172 Clang: Cleanup symbol indexer test
Change-Id: I1cfa70d092d27949e0cf9466b190afbc40c1a591
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-10 12:38:39 +00:00
Marco Bubke
6f8f8d0cbf Clang: Extend ClangPathWatcher to communicate path changes
Change-Id: Iad2d6adc53fbc2ee32fd63b9ccdc8999d41a89da
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-10 12:38:16 +00:00
Marco Bubke
98fa7cbb3f Clang: Use FilePathId in ChangedFilePathCompressor
Change-Id: I622d9196ec12c6fe6e07ef9c953586f2f40b9a5c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-10 12:37:37 +00:00
Nikolai Kosjar
5f8ac59ef8 Clang: Fix tests without any ASSERTs
Change-Id: I3148cb85271ab021832caa5bd09dedb6aeeef49f
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-08 15:21:23 +00:00
Nikolai Kosjar
e3b1259004 Clang: Introduce DocumentParsed as job requirement
This is in prepration for a follow-up change, which introduces a state
where the Document is not yet parsed (it was reset) but the queue has
jobs.

All jobs get this requirement except those that generate an AST.

Change-Id: Ifcbb704e54108b40797180514c5ad3f3768ef10b
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-08 13:18:54 +00:00
Nikolai Kosjar
063b327097 Clang: Clean up clangjobqueue-test.cpp
Change-Id: If10deb858bbf0ec725c029d5e914c5109de7b5ee
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-08 13:18:47 +00:00