Commit Graph

24 Commits

Author SHA1 Message Date
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
Nikolai Kosjar
f1290da3cd Clang: Avoid running pointless UpdateDocumentJobs
Opening a document (without typing in it), switching away and back to it
resulted in running UpdateDocumentJobs for that document for nothing.

As for documents we are going to reset, simply set opened documents
initially dirty.

Change-Id: I8edc2d1fb8f6f92950b4e2067f60609176bd5b26
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-24 12:52:14 +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
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
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
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
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
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
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
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
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
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
Ivan Donchevskii
11d002968e Clang: add more data to TokenInfo class
Add token name, usr, isDefinition and isDeclaration.

Change-Id: If67bf78c999cb9edd397d0b553b33e5f5f378f8a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-12-11 15:18:52 +00:00
Ivan Donchevskii
affc652b7b Clang: Rename HighlightingMark to TokenInfo
Before adding additional members into that class it
makes sense to rename it to better represent its content.

Other classes serving the same purpose are also renamed
to keep the names consistent.

Change-Id: I3c8517e42aae29779d71ec9c85b713cff581a473
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-12-11 15:00:24 +00:00
Hugo Holgersson
bf3c67e0d0 TextEditor: Implement highlighting of function definitions
This allows users to style function names at their definitions.

Once set, the XML-style token "FunctionDefinition" will
highlight all function definitions: the style option is a
mixin to Function and Virtual Function.

TEST=Default themes and locally hacked themes that lack Function,
FunctionDefinition, Declaration-styling look as they did before
this patch.

Requires Clang.

Task-number: QTCREATORBUG-16625
Change-Id: I49d8e401211bdf28ff74699feac16fe98f6d64ce
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-11-28 12:54:29 +00:00
Ivan Donchevskii
bea6a3dc9f Clang: Fix ClangCodeModelServerSlowTest.RequestDocumentAnnotations
Add missing HighlightingMark parameter in test.

Change-Id: I7b2661152bebf038a3da650ee20b253fa18b471f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-29 09:08:04 +00:00
Ivan Donchevskii
9c9baaac04 Clang: add unit-tests for follow symbol
Change-Id: I336fe29052237ede6f5c578daf01557400d9027c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-08-18 12:10:02 +00:00
Nikolai Kosjar
b869f02f72 Clang: Introduce headers for client/server messages
This reduces the overhead when a new message needs to be added.

Change-Id: I5bb2833af2f06f2a8e101cfb03f75ffc2927bf68
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-19 11:08:39 +00:00
Nikolai Kosjar
a570614f3c Clang: Fix test file name
Change-Id: I27b25e4b8521aabab804812c4cc27cd41c23b46e
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-15 08:00:34 +00:00