Commit Graph

1332 Commits

Author SHA1 Message Date
Eike Ziller
2531233747 ClangCodeModel: Restrict QtSupport dependency to tests
Amends 6dc3c1f156

Change-Id: Ib907ad9d8922a7fc999659135632f386de346ecb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-19 11:31:46 +00:00
Christian Kandeler
12fd21a880 ClangCodeModel: Implement global renaming via clangd
Note that we do not use the LSP rename functionality. We do "manual"
renaming the same way as in the built-in code model, but based on the
references found by clangd.

Change-Id: Ifa5597efe5c89c8f9204a4f5323bc755544696cf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-05-19 07:58:04 +00:00
Christian Kandeler
78274956d0 ClangCodeModel: Make open C++ files known to newly started clangd client
This is relevant when opening a session, for instance.

Change-Id: Iff3140296edb7b6d2b758f1f8b0b83a52fdd6f56
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-05-19 07:55:40 +00:00
David Schulz
f8ca730121 LanguageClient: Use Utils::FilePath to get file content
Change-Id: Iddb2eb5c02f3e6674f1f71bb61fb1f13dec22794
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-18 12:35:43 +00:00
Christian Kandeler
6dc3c1f156 ClangCodeModel: Support access type categorization
... 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>
2021-05-18 08:42:04 +00:00
Jarek Kobus
91f136ef3a Use Utils::FutureSynchronizer instead of QFutureSynchronizer
Change-Id: Iecfa676f58e5ca82be7c9c94233dcc8d3654c2d7
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-05-12 22:08:02 +00:00
Eike Ziller
eb99d1bc6c Fix build with Qt 6
No automatic casting to QFuture<void> anymore.

Change-Id: I878975b972799f763f1a29b94f61d4a12c3a6710
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-10 14:05:24 +00:00
Jarek Kobus
dc88306983 ClangModelManagerSupport: Add future synchronizer for started tasks
Task-number: QTCREATORBUG-25678
Change-Id: I0031f64b3d80cfcff6b9625bd2d57ea228382c80
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-06 08:22:22 +00:00
Jarek Kobus
0ca487b265 Fix a possible crash in ClangEditorDocumentProcessor
Use QFutureSynchronizer in order to ensure that all
threads have finished on shutdown.

Fixes: QTCREATORBUG-25673
Change-Id: I3a6a808ada389bc51a1f0149dfc112768929a20d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-05 11:13:49 +00:00
hjk
2f593d9db9 LanguageServer: Use Utils::CommandLine in StdIOClientInterface
Change-Id: Ic2516387d7308bfad05cef54467c417cc47a7655
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-05-03 11:31:17 +00:00
David Schulz
1d7e05e6a9 LanguageClient: remove unneeded document actions blocker
Change-Id: Id1f07dbf83fcf7d75aaba6d860fb1556761bbd4b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-04-27 08:38:16 +00:00
Christian Kandeler
91b6c58518 LanguageClient: Add signal to inform about WorkDoneProgressEnd
... 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>
2021-04-27 07:37:25 +00:00
hjk
8e352af0ec Core: Add a default parameter to various ICore::*path functions
Saves some code on the user side.

Change-Id: I32cd220b6e533f5497a1865f9c34ab9db4cfda79
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-04-27 06:52:05 +00:00
Christian Kandeler
90a07eca28 LanguageClient: Add the possibility to override progress messages
... and make use of it in the clangd client.
We want the progress bar for background indexing to have a better title
than the plain (and non-translated) "indexing" that the clangd server
sends.

Change-Id: Ib75eac370e7c22f0c5bd477f4a4c423283b27e1f
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-04-26 08:13:21 +00:00
Eike Ziller
c1f90aeca2 ICore: Change some path API to use FilePath
Change-Id: Id841d6177206a021c9e606ce560b47d1ae6e52b9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2021-04-26 08:03:47 +00:00
hjk
29ac812cf4 Clang: Compile fix for qmake
Change-Id: I88fa2c995a22a2fe3bf3a0aac05c0432e4b3d379
Reviewed-by: hjk <hjk@qt.io>
2021-04-23 02:06:38 +00:00
Christian Kandeler
e27b367bdc ClangCodeModel: Introduce dedicated class for clangd LSP client
Makes sense for modularization purposes, and it will soon get additional
functionality.

Change-Id: Ie8163d352fc408b4167ee2ce6147aa1fb19528eb
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-04-22 12:07:49 +00:00
Christian Kandeler
ecafdb7543 ClangCodeModel: Add experimental clangd support
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>
2021-04-22 07:32:58 +00:00
Eike Ziller
3d1ad9db60 Merge remote-tracking branch 'origin/4.15'
Change-Id: I1d13f3543ab4bb17f0cbfe26bbea3f154f856ca6
2021-04-20 10:42:55 +02:00
Christian Kandeler
c80c724b52 ClangCodeModel: Fix template highlighting bug
We need to take into account that the ">>" in constructs such as
std::vector<std::pair<int, int>> is only one token on the clang side.

Change-Id: I90f002ca56f236032f6d39c338593a2ff7590061
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-04-16 07:02:19 +00:00
Eike Ziller
b213c87cf4 Merge remote-tracking branch 'origin/4.15'
Conflicts:
	src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp

Change-Id: I722a94f37bdd1d78625cfae503ba6d02ff083c63
2021-03-25 11:06:59 +01:00
Eike Ziller
e9bf841dc9 Fix lupdate issues
Some wrong tr calls / missing tr functions.
Some places where we need to bring lupdate to the right track with
regard to namespace resolution.

Change-Id: Idf552054a34e24d9671db68c816bf37f4d403dbc
Reviewed-by: hjk <hjk@qt.io>
2021-03-22 15:00:37 +00:00
Tom Praschan
5fcd52fe83 ClangCodeModel/TextEditor: Add support for highlighting parameters
This is already built into clang, so we just need to expose it to the
highlighter and the UI.

Fixes: QTCREATORBUG-24880
Change-Id: I6d0595af2589a9b69eb954aafad46457ab2c5752
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-03-15 09:48:24 +00:00
Christian Kandeler
dfa24f09ad ClangCodeModel: Show only valid applicable overloads when completing
libclang is smart enough to filter the overloads according to which
arguments have already been entered, so let's make use of that.

Fixes: QTCREATORBUG-650
Change-Id: Ic2711f460c908c6fd9c8efe28c3c63a0ce2d9205
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-02-17 07:09:37 +00:00
Jarek Kobus
6a2088d8ec Provide empty implementation for ILocatorFilter::refresh()
Make this method just virtual, not a pure virtual.
Remove all empty reimplementations of this method.

Change-Id: Idf10e492355e8519172facd421ea0b2b13ce3b80
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-11 13:32:30 +00:00
Christian Kandeler
5f5f38e028 ClangCodeModel: Support "parentheses" matching for ternary operator
That is, show which ":" belongs to which "?" when the cursor is on one
of them.

Fixes: QTCREATORBUG-1410
Change-Id: Ie19360b3dfc82d92c264d99a5aa1864eda66e5c8
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-02-11 08:52:17 +00:00
Christian Kandeler
765f518de3 TextEditor: Support tooltips for buttons in text mark tooltips
In case users don't find the icon self-explanatory.

Task-number: QTCREATORBUG-25150
Change-Id: I481b1ea7f510f065f83badcb91e127ac1c81f5a1
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-02-05 12:43:17 +00:00
Christian Kandeler
3d1b456dab CppTools: Fix parentheses mismatch
... when the ClangCodeModel is disabled.
The built-in highlighter's use of HighlightingResult::kind conflicted
with the ClangCodeModel's.
Amends d8c1e51bfe.

Change-Id: I79784679fd17d88cd543304de726f8576954b29c
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-02-05 08:51:31 +00:00
Eike Ziller
cb96b91dd4 Refactor Locator filter settings saving
Unify setting saving. Do not write settings that stay at the default, so
defaults could change and take effect.

For this we explicitly differentiate between default and user settings.
Make QJsonDocument the basis for saving settings, because QDataStream
cannot really handle structured data where parts could be missing.

Write locator settings to a different settings group, so we do not
destroy reading older settings from older Qt Creator versions.

Task-number: QTCREATORBUG-24762
Change-Id: I5909e2d79313f6fc26159bb644fdfb43781b6c38
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-02-04 07:33:10 +00:00
Jarek Kobus
fe9051c25d ClangCurrentDocumentFilter: make use of prepareSearch function
Since it's guaranteed, that prepareSearch() is always called
from the main thread prior to the call to matchesFor()
from the other thread, we copy the data inside prepareSearch()
which we will operate on when matchesFor() is called later on.

Change-Id: Idf6a8e683356bb524eb4b5b1ce1e05b0ba065c8b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-01-29 08:08:42 +00:00
Eike Ziller
df6967a897 Merge remote-tracking branch 'origin/4.14'
Change-Id: I6e67f23464fc14dda5a659004f0aa360d6f5d25f
2021-01-27 12:28:47 +01:00
Christian Kandeler
d9e5d079be ClangCodeModel: Relax completion result filtering
... in connect() calls.
The logic was: If we are in a place where a signal is expected and there
are signals among the completion results, then we should consider only
signals.
However, in e.g. a member function of a QObject subclass, there are
always signals in scope, even when we expect a class name. So we need to
allow class names as well.
Amends a79b0c6558.

Fixes: QTCREATORBUG-25153
Change-Id: Id3bbaaf4f8eefefe36cfc91e5959d3ef5ad28071
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-26 15:55:41 +00:00
Christian Kandeler
d8c1e51bfe ClangCodeModel: Support highlighting angle brackets
... in template declarations and instantiations.

Fixes: QTCREATORBUG-16799
Change-Id: I82bc6411ca980ecbe2a6c70ae37580166a4b89e9
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-22 10:48:33 +00:00
Eike Ziller
f1f3881cdb Fix build with Qt6
Some type issues (int vs long long, int vs QFont::Weight), no "midRef" any more.

Task-number: QTCREATORBUG-24098
Change-Id: Id39f70edc14832baaeebb2572bca5491deadaf1d
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
2021-01-21 14:05:46 +00:00
Christian Kandeler
a1c5dd93f5 TextEditor: Let TextMark subclasses provide a settings page
Task-number: QTCREATORBUG-25150
Change-Id: Id5bbdcf2db7afacb823140d77ebd5bc141ac7f81
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-20 14:17:35 +00:00
Eike Ziller
7ce3ceabe9 Merge remote-tracking branch 'origin/4.14'
Change-Id: I26a53ef81a54a2f7aa482448118298895b712941
2021-01-12 14:14:41 +01:00
Christian Kandeler
47dfc16eee ClangCodeModel: Work around race condition when closing editors
The editor manager emits currentEditorChanged() before editorsClosed(),
which throws off the clangbackend. Fix this by sending an extra
DocumentVisibilityChangedMessage after the DocumentsClosedMessage.

Fixes: QTCREATORBUG-25193
Change-Id: Ic02ae174a2912d79aeded44ced13d962b53526b1
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-08 13:39:34 +00:00
Christian Kandeler
6d2edf0613 ClangCodeModel: Fix header file completion weirdness
... when completing right after a dot.
It's unclear why the code uses half-baked heuristics all over the place
instead of simply employing the lexer (which is also used at some point)
for everything. For now, use it to determine the correct starting
location of string literals.

Fixes: QTCREATORBUG-25154
Change-Id: I14c4d71c4a9bc3e2407688ed9c908d1c99155c76
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-07 14:36:28 +00:00
Eike Ziller
d95e1f940a Merge remote-tracking branch 'origin/4.14'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri

Change-Id: I5b8d93f2f08b62626c3f3447728c64d198b601ff
2021-01-04 09:09:21 +01:00
Eike Ziller
305ca7e434 cmake build: Fix handling of test dependencies
Test dependencies are not "real" code dependencies, they just
declare that for testing the plugin the other plugin has to
be loaded, even though it is _not_ a code dependency.

Add PLUGIN_TEST_DEPENDS to add_qtc_plugin. We cannot assume
that the target exists at that point, so adapt the usual pattern.

Fixes: QTCREATORBUG-25024
Change-Id: I4165ff8df762309e0be0bfe9e8bedef796a3bf17
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-12-18 08:24:46 +00:00
Eike Ziller
eaefcbd8f0 Use new, more evocative MessageManager API
At various places where semantics doesn't change.

Change-Id: Ib4d4a5c9f067e109126c6de88257f9e198a71447
Reviewed-by: hjk <hjk@qt.io>
2020-12-16 09:30:44 +00:00
Alessandro Portale
a3857a996a Don't access static functions/fields via instance
Courtesy of readability-static-accessed-through-instance

Amends: b2a766a79a

Round #2: This time done with Qt Creator's Analyzer, which
found other occurences than run-clang-tidy.py

Change-Id: I479e280c7abcf2d24baccbb0af69ae4bda05198e
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-11-27 13:26:07 +00:00
Christian Kandeler
bcf900e29b ClangCodeModel: Prevent outdated fix-its from getting applied
The code locations might no longer be correct.

Fixes: QTCREATORBUG-21818
Change-Id: I866a29d2fd63ff65cf33168024f7788c5f6e3547
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-11-24 11:24:08 +00:00
Eike Ziller
8d67dd57e8 Merge remote-tracking branch 'origin/4.14'
Change-Id: I5e138bb7883c0436fee14ca6af20e99396676af1
2020-11-20 13:00:37 +01:00
Christian Kandeler
f697a0d46c ClangCodeModel: Fix sorting of includes when auto-completing
... by treating the directory separator specially.

Fixes: QTCREATORBUG-21490
Change-Id: Iad6f51f39516a88bd14ba1eddcf2c6656490ee5b
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-11-20 08:43:41 +00:00
Jarek Kobus
b269066435 Use const iterator with std::find_if where possible
Make the resulting interator const.

Change-Id: I4aadcfff35f6b1015e506bc75bcfc2a1f1be4d65
Reviewed-by: hjk <hjk@qt.io>
2020-11-19 09:46:31 +00:00
Jarek Kobus
48c2afe157 Decorate some classes and methods with final keyword
This way we silence the clang warnings about calling
virtual methods from c'tor or from d'tor:
[clang-analyzer-optin.cplusplus.VirtualCall]

Change-Id: I8d6318b490152133da4833bda2ba28622bce30dd
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-11-19 09:45:53 +00:00
Eike Ziller
1d2b5db02f Merge remote-tracking branch 'origin/4.14'
Change-Id: I2ae0eb18782224e48cd20d41907f9dfea6ee1771
2020-11-10 13:42:46 +01:00
Jarek Kobus
c0408ed52e Compile fixes with Qt 6
Change-Id: Ia5335bef6aeaff3ce12339db52d96793ff588824
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-11-05 08:14:55 +00:00
Christian Kandeler
baf25e4cdb ClangCodeModel: Do not ignore highlighting for raw string literals
Also add the special handling for prefix and suffix like in CppHighlighter,
as not to re-introduce QTCREATORBUG-19119.

Fixes: QTCREATORBUG-16183
Change-Id: Ie264946782220a8e5a862c1d4550bcd49bc2349f
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-10-22 09:48:02 +00:00