ProjectInfo, ProjectPart and ProjectUpdateInfo used to carry pointers
to Project and/or Toolchain, even though they were used in contexts
where these pointers were either unsafe to access or not guaranteed to
be valid anymore, which made their use difficult and error-prone.
We turn these classes into pure value types by copying in all relevant
information before the first async operation takes place.
Fixes: QTCREATORBUG-25678
Change-Id: I1914b0dbda6c7dfba6c95e5e92f2d69977755590
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Opening a document in the language client while the server is still
initializing will postpone the opening after the server is fully
initialized. So if a document was scheduled for opening by
ClangModelManagerSupport::onEditorOpened while clangd is still
initializing, skip the superfluous opening in the ClangdClient
initialize callback. Clangd seems to have issues if files are opened
twice, resulting in strange diagnostics after editing the file. This is
reproducible for me when starting Qt Creator with a session that
contains open files.
Change-Id: I200d5c8afb685403f0435e0553f5a475f75e8ea2
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
These were still being served by the old code model even when clangd
support was enabled.
Change-Id: I5f01b6a7071b90c374750f93435299755cabe3e9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
... when clangd takes over a document.
This fixes the problem that temporary diagnostics persisted after opening
a session.
Change-Id: Ic781f83747cabb4d15c2c1f8181e36f4343e0394
Reviewed-by: David Schulz <david.schulz@qt.io>
Note that we used to encode the information about symbol visibility and
static-ness in the icons, which we can't do anymore, because clangd does
not provide this information.
On the upside, this change likely fixes a ton of bugs, as our own outline
was rather "quirky".
Change-Id: I099f11ec4e3c6f52cd461fb43080bbdde3bed5e5
Reviewed-by: David Schulz <david.schulz@qt.io>
Users no longer have to re-load a project for settings changes to take
effect.
Change-Id: I86dccccac14a30514c8dac292c7765ee4806f6ba
Reviewed-by: David Schulz <david.schulz@qt.io>
Users might want to use clangd for certain project, but not for others.
Change-Id: Id29ce3349f0acd359cf7c824ece073b147ed2280
Reviewed-by: David Schulz <david.schulz@qt.io>
We plan to add more clangd settings, and it makes sense to have a
dedicated place for them both in the code and the UI.
Change-Id: Ideb92935b7a5a6a98e07980f4011736fb82042d1
Reviewed-by: David Schulz <david.schulz@qt.io>
This is relevant when opening a session, for instance.
Change-Id: Iff3140296edb7b6d2b758f1f8b0b83a52fdd6f56
Reviewed-by: David Schulz <david.schulz@qt.io>
... with "Find Usages", as we do in the built-in code model.
Note 1: This is very slow, so it's for now only enabled if the
search results come from a small number of files.
Possible ways of speeding up the operation
to be investigated.
Note 2: All test cases from the old code model also pass here,
but checking with non-trivial real-world projects
shows a lot of mis-categorizations.
Well will fix them one by one.
Note 3: This functionality requires clangd >= 13.
Change-Id: Ib3500b52996dbbf9d7d9712d729179bcbd3262fc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
No automatic casting to QFuture<void> anymore.
Change-Id: I878975b972799f763f1a29b94f61d4a12c3a6710
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
... and make use of it in the clangd client to be able tell when
background indexing has finished.
Change-Id: I0f3c6f9646fd66ababd08c12b2f347da5f1a3729
Reviewed-by: David Schulz <david.schulz@qt.io>
Makes sense for modularization purposes, and it will soon get additional
functionality.
Change-Id: Ie8163d352fc408b4167ee2ce6147aa1fb19528eb
Reviewed-by: David Schulz <david.schulz@qt.io>
If the user has enabled clangd (default is off), we start up one instance
per project when it is opened/changed (including build config switches),
and trigger background indexing.
So far, the index is used to provide results for locators and "Find
Usages".
Per-document functionality such as semantic highlighting and completion
is still provided by libclang.
Change-Id: I12532fca1b9c6278baab560e7238cba6189cde9f
Reviewed-by: David Schulz <david.schulz@qt.io>
... and support it in the ClangCodeModel.
This allows users to get function signature(s) displayed regardless of
where exactly the cursor is on the function call.
Fixes: QTCREATORBUG-19394
Change-Id: I033e8774db93680bfc3ee52610b817e0ef8ccc76
Reviewed-by: David Schulz <david.schulz@qt.io>
... between semantic re-highlighting and document visibility update.
Make semanticRehighlight() a no-op if the document is not currently
visible, and call it explicitly on an editor change.
Fixes: QTCREATORBUG-24290
Change-Id: Ife61f61d3fb82e8b283bf93ab77d16517f6c6f9c
Reviewed-by: David Schulz <david.schulz@qt.io>
... by the customary ::Internal.
It adds only noise on the user side and conflicts regularly with
the top-level ::Utils namespace.
Remove a (now) duplicated definition of setLastSentDocumentRevision().
Plus minor namespace related fixes.
There are still minor conflicts between Utils::Text and
ClangCodeModel::Text
Change-Id: I2e8df6b3c6c3599192774032822ee7e778355bba
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
The coreplugin/id.h header is kept for downstream for now.
Change-Id: I8c44590f7b988b3770ecdc177c40783e12353e66
(cherry picked from commit 430a33dcd9)
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
There's nothing shared here, only ever one copy. Ideally, this
should be const outside CppToolsPlugin, but some settings
are modified directly.
Change-Id: I775b9151a244b3cc44d28bc992a041c42d234a18
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
More in line with QFileInfo terminonlogy which appears to be
best-of-breed within Qt.
Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Provide the source path to track a generated file source. You can for
example get the modified time stamp for the source file and use it for the
generated file content.
Task-number: QTCREATORBUG-21876
Change-Id: Ia422e128c5cb7a3dce88960f126152c2f65afb41
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Tracks application state, and signals when it is changed.
Supports forcing blocked state with reference counting.
Change-Id: Ic173d42446b1b08bd4a1e7c1acf38c68644d30b3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
...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>
We use "Builtin" and "Clang" as prefixes, not suffixes.
Change-Id: I6926aeb8f005176ef420c4421c257e3df61ee0b7
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
...to reduce file locking on Windows caused by clangbackend's
parse/reparse jobs.
Considering inactive application state should help for external VCS
operations, e.g. on the command line. However, activating Qt Creator
while such a VCS operation runs might still lead to undesired behavior,
but this should be the less common case.
VCS operations started from within Qt Creator should see less locking
conflicts as we know when they start and finish. However, we just avoid
starting new jobs - there might be still jobs running.
Pending or new jobs will be started once Qt Creator is activated again
and all VCS operations finished.
Task-number: QTCREATORBUG-15449
Change-Id: I5f04c34f006e66162368efbdd58bd822a706f35e
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
...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>
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>
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>
If the last editor is closed, "editor" becomes a nullptr, which is valid
value in this case.
Change-Id: Id5f92cb4367199d782e33acc37077103e9986644
Reviewed-by: David Schulz <david.schulz@qt.io>
This helps to deal with many diagnostics.
Error diagnostics precede warning diagnostis to have them on top.
If no CppEditor is active, no diagnostics are displayed.
Previously one had to scroll the document up and down to locate the
diagnostics. Now they are in a list and can be easily navigated with
F6/Shift-F6. Also, at least for some diagnostics "Get Help Online" from
the context menu seems to provide useful results. For example,
triggering the action on clang tidy issues will open the web browser
with some good hits explaining the issues.
Change-Id: Idabe30b0961d893bee39ccee431e92aeeda1cc26
Reviewed-by: David Schulz <david.schulz@qt.io>
Filter is based on full token infos which come
from clang code model after token infos with pure
highlighting information.
Inprovements:
- functions also provide the return type after the signature
- now supports Q_PROPERTY
- all c++ features that clang 5.0 supports
Change-Id: If3e30d238984f39df8d2c3b9ba3ee085c4117f3d
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Move ownership and add the placeholder for future clang based
OverviewModel.
Change-Id: Ia44d2c1d0db59b40239d1f7934bf37a02e4b14e6
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
On diagnostic config change, affected documents are closed behind the
scenes. Visible ones are parsed immediately, invisible ones are tagged
for parse once they become visible.
Task-number: QTCREATORBUG-16263
Change-Id: Id4dcc69f1a4bfccc597e798d6821f8718f86e352
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: David Schulz <david.schulz@qt.io>
So far we've created ClangProjectSettings objects on demand. To get
change notifications there should be only one per project alive (and
accessible).
Change-Id: I757186ceaa642c6864d02946258cc6eb18064a52
Reviewed-by: David Schulz <david.schulz@qt.io>
For unregisterTranslationUnit only the file path and the project part id
is needed.
Change-Id: I882d2fe07af094c07ea42413d6874539535a48ea
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
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>
This is in preparation for clang code model to provide its own hover
handler.
Change-Id: Ifbdd96f427989bd5d1fbc4badb9c38108485c2f2
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Provide refactoring engine for ClangCodeModel and
implement missing methods.
Change-Id: If5c913e0c5a7941cd2ced54d0fcfa4d625eadc93
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>