Commit Graph

79 Commits

Author SHA1 Message Date
Christian Kandeler
52959ce472 CppEditor: Acknowledge the existence of clangd
Stop pretending to be super generic. Instead, let interested code know
directly whether a document is under clangd's control.
This saves code and makes the logic easier to understand.

Change-Id: Ia19d0ec6c4e83926379a7d17ca53896bee3a50e1
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-11 07:41:44 +00:00
Eike Ziller
42e072f159 Move MinimizableInfoBars from CppEditorDocument to IDocument
Similar to the InfoBar.

The only thing that an editor implementation needs to do is to set a
settings group and the possible info bars in the document constructor.
And later call document->minimizableInfoBars()->setInfoVisible(id,
visible) to manage the state.

Change-Id: I23afb3639b70b1bfccd424579da018280a7fe2cb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-10 13:16:22 +00:00
Eike Ziller
b0fb2de04e MinimizableInfoBars: Move to Utils
Change-Id: I6b42948c4bddaa396122b845c5c1e2aa70d8aaad
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-09 10:13:29 +00:00
Eike Ziller
8bb63ebc9a MinimizableInfoBars: Move toolbar visibility handling
Remove some coupling between CppEditorWidget and MinimizableInfoBars by
handing the visibility of the toolbar buttons solely within
MinimizableInfoBars.

Change-Id: I5abf59187ea9b37fd13c91d63b2c82a1caa67275
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-06 13:21:14 +00:00
Christian Kandeler
818dc8b0cc Remove clangsupport dependency from plugins
Change-Id: Ifd4215a590d32cd04fab720d0d8d5e746e81c6e8
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-05-06 08:11:42 +00:00
Christian Kandeler
969b1f711f CppEditor: Remove RefactoringEngine
Another useless indirection.

Change-Id: Icfcc0704a1056d8002a674edbe74b946cb56ff27
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-05-04 10:05:31 +00:00
Christian Kandeler
f2c267f328 ClangCodeModel: Remove libclang fallback for "follow symbol"
... and "switch between declaration/definition".
It's either clangd or built-in code model now.
Use the opportunity to dissolve the pointless FollowSymbolInterface
class hierarchy, which introduced a confusing parallel inheritance
chain.

Change-Id: I792ad55656c5dd9f10c6b4db7c5c36cf7be45125
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-04-28 09:47:52 +00:00
hjk
974d37d58a TextEditor: Suppress warning about unused parameters
Change-Id: I159989501b9c5c14b5b452bf7b5d1e27d442775e
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-03-30 08:41:57 +00:00
David Schulz
7552c9958f TextEditor: move setIfdefedOutBlocks to TextDocument
The location of the blocks to marked ifdefed out are not tied to a
specific editor instance, but just depend on the document content.

Change-Id: I837730dc00e1d6060dd46bbb2cfccbfa5f72e6ce
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-12-06 05:17:51 +00:00
Christian Kandeler
560d16a096 CppEditor: Follow symbols in generated UI headers to .ui file
Fixes: QTCREATORBUG-2374
Change-Id: I784fe39c11c834525cdd37ca719efa65efcb307c
Reviewed-by: hjk <hjk@qt.io>
2021-10-27 09:17:49 +00:00
David Schulz
c00330f905 Editor: multi cursor support
Adding a way to create multiple cursors that can insert/remove text at
arbitrary positions in the document. Adding cursors is done by pressing
alt + up/down or by clicking into the editor while holding the alt key.

Fixes: QTCREATORBUG-16013
Change-Id: I495d27d95a3d277220946616ef30efc241da0120
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-27 10:56:54 +00:00
David Schulz
4324f3e8c1 Editor: pass AssistInterface to createProcessor
The interface can be used for checking the context of a codeassist
request to determine
the correct processor that has to be created.

Change-Id: I47ddb05c46399566e27bae21711f11a3a4132c3f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-16 08:25:36 +00:00
Christian Kandeler
1b723f6fd9 CppEditor: Remove unneeded CppEditorWidgetInterface
Removes a pseudo-abstraction and simplifies ClangdClient.

Change-Id: I5161d069371ff92a517866bb7500517cab6781b7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-07 11:16:47 +00:00
Christian Kandeler
7761a5afbc CppEditor: Move trySplitComment() to its only point of use
Change-Id: I50dc26835a54558879498bcfedf3f246f99f86d2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-06 09:37:12 +00:00
Christian Kandeler
284817fae6 Merge CppTools into CppEditor
There was no proper separation of responsibilities between these
plugins. In particular, CppTools had lots of editor-related
functionality, so it's not clear why it was separated out in the first
place.
In fact, for a lot of code, it seemed quite arbitrary where it was put
(just one example: switchHeaderSource() was in CppTools, wheras
switchDeclarationDefinition() was in CppEditor).
Merging the plugins will enable us to get rid of various convoluted
pseudo-abstractions that were only introduced to keep up the artificial
separation.

Change-Id: Iafc3bce625b4794f6d4aa03df6cddc7f2d26716a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-09-01 14:53:58 +00:00
Christian Kandeler
a952500e90 CppTools: Use only const pointers for ProjectInfo and ProjectPart
All members were already const, but this makes it clear at all points of
use that these data structures are immutable.

Change-Id: Iea615c090bde462c445d15223caccc561b0c713d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-08-27 10:53:54 +00:00
Christian Kandeler
e0e8fda580 ClangCodeModel: Use clangd for completion and function hint
Change-Id: I80160f3a40da18ac178682afe6caba5e5af6e3eb
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-08-23 09:06:31 +00:00
Christian Kandeler
33108795d6 CppTools: Turn some classes into pure value types
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>
2021-08-13 12:35:49 +00:00
Christian Kandeler
eff5cbeb86 CppEditor: Enable/disable outline dynamically
The "outline enabled" property is not static: E.g. the user might switch
on/off clangd support, and then we should hide/show our outline,
respectively.
This also eliminates the danger of null pointer accesses.
Amends c0a44be27b.

Fixes: QTCREATORBUG-25963
Change-Id: I508b9700ba1a99204ea8315546db089486b5d122
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-08 09:14:21 +00:00
Christian Kandeler
c0a44be27b ClangCodeModel: Provide outline via clangd
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>
2021-07-01 08:36:20 +00:00
David Schulz
b6367b6359 Core: use FilePaths to notify files changed internally
Change-Id: I2fce65ad340f18292fc0286233e78aaf769a130d
Reviewed-by: hjk <hjk@qt.io>
2021-06-23 12:03:10 +00:00
Christian Kandeler
40181057cd ClangCodeModel: Use clangd for local renaming
Change-Id: I1536265a8d46c9840e722bdfcb8638906d3f45cf
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-21 13:00:40 +00:00
Christian Kandeler
41dafc8132 ClangCodeModel: Implement declaration/definition switch via clangd
Change-Id: I522a415d76fbc5332e5cc1fdfd2d7ab19cb9ed64
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-18 11:11:17 +00:00
Eike Ziller
baa83725f6 Remove ClangRefactoring and ClangPchManager
This removes the plugins and tools, and removes all the tests that would
fail to build because of that.

Fixes: QTCREATORBUG-25659
Change-Id: I8adb5d503fc8eea313bcaada421f309dbbfa8c26
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2021-06-15 10:07:57 +00:00
David Schulz
79b9a2fea6 TextEditor: filepathify RefactoringChanges
Change-Id: Ie97e484bcdeaa0cb2f5d04b3c79ace55ff2e426c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-08 11:40:10 +00:00
Christian Kandeler
eba2f2df84 CppEditor: Run test cases for virtual functions also with clangd
This uncovered some bugs, of which we fixed the ones that we could do
something about.

Change-Id: Id8494793bec4d25635bf920133d9f9331bd36228
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-08 09:51:09 +00:00
Christian Kandeler
b087897b42 ClangCodeModel: Implement global "follow symbol" via clangd
Change-Id: Iaa58e3ee2e74b1a1210850f944df942e3669d247
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-05-19 11:32:06 +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
David Schulz
8b7a90ac51 Utils: filepathify TextFileFormat
Change-Id: I6a4e2d38b0bbdec661a4a492901d9182a9f2e502
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-18 12:35: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
261967a5f4 Fix search result font for symbol searches
SearchResultItem defaults to the standard application font,
we need to tell it to use the text editor font explicitly,
like the specialized addResult method did that was removed.

Amends d3deefc3a4

Fixes: QTCREATORBUG-25396
Change-Id: Id8d41d93c96fbfd6d993568a37d42509da452665
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-03-02 11:13:52 +00:00
Christian Kandeler
d3deefc3a4 Core: Streamline SearchResultWindow interface
That is, make SearchResultItem the one data type for adding search
results.
This will allow us to add additional properties to search results
without adding more and more parameters to a bunch of functions.

Change-Id: Ic2740477ae47449cee75caa2525727fe2b460f91
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-18 16:46:08 +00:00
Christian Kandeler
12c0aadc82 CppEditor: Fix race condition for highlighting of local usages
Starting a renaming action involves looking up local usages. In this
case, a different code path than normal updates the editor's extra
selections, in order to make sure that the occurrence to be edited is
rendered in a special way. We must therefore prevent the normal handler
from taking action, as it would overwrite abovementioned special
selection.

Change-Id: Ia811b49b3023a0a366a43a69cc01e6b2b370acb5
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-15 08:15:22 +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
2b414508b7 Remove unneeded includes
Change-Id: I67fee9303509b7080e123a2a5826e200ce498ce2
Reviewed-by: hjk <hjk@qt.io>
2020-11-12 12:14:11 +00:00
David Schulz
dba4bff703 TextEditor: use Utils::FilePath as file member in AssistInterface
Change-Id: I3bf9b013b9350411f918efdb9d1a36a2c22bf972
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-09-04 10:14:21 +00:00
David Schulz
339db00f85 Core: replace QString with Utils::FilePath to get documents
Change-Id: I01777c227398be8bd3bf877c5429b84a75aa361b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-09-04 10:14:14 +00:00
Christian Kandeler
7938320291 TextEditor: Introduce shortcut for forcing a function hint proposal
... 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>
2020-08-11 10:10:08 +00:00
hjk
430a33dcd9 Core/Utils: Migrate further to Utils::Id
The coreplugin/id.h header is kept for downstream for now.

Change-Id: I8c44590f7b988b3770ecdc177c40783e12353e66
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-07-06 06:07:13 +00:00
Christian Kandeler
a204fa65c8 CppEditor: Do not underline leading whitespace
... when visualizing the range of a code model warning.
Otherwise, warnings covering multiple lines can get too noisy.

Fixes: QTCREATORBUG-18659
Change-Id: Ieff7729d8069e791027f7bdde5fca13f4c7f7163
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-06-23 11:01:12 +00:00
Christian Kandeler
a0764603d0 CppTools: Also look up definitions for variables
... not just functions.
This includes global variables and static members.

Fixes: QTCREATORBUG-18828
Change-Id: Iee9f83a4f955a859c6fc4038c61997b30afdaec8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-18 12:02:00 +00:00
Eike Ziller
7c5ed6f7d9 Move InfoBar to Utils
The only reason it was required to be in Core plugin, was its use of Id,
which now is available in Utils.

Change-Id: I66ce863c24924e6448d339b3422538a7fe167336
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-06-18 06:39:54 +00:00
David Schulz
3559af69db TextEditor: move rename symbol action to text editor
Task-number: QTCREATORBUG-21578
Change-Id: I9a873dcd38bacb2287c45973b6be0091c3eb9480
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-05-12 04:28:19 +00:00
Alessandro Portale
24a25eed14 Use isEmpty() instead of count() or size()
Change-Id: I0a89d2808c6d041da0dc41ea5aea58e6e8759bb4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-01-20 20:56:57 +00:00
Marco Bubke
20a304c8e0 CppEditor: Reuse document for search results
Instead of open a document for every entry we do open it only once per
search. For that we sort the entries by file path, so that they are clustered
together and reuse the last document if the path hasn't changed. This can
improve the calculations of the search results drastically.

Change-Id: I9c9c1e387624297d84c6a2ca6edb6130f739d295
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-08-29 07:53:24 +00:00
hjk
6a58666f44 More Utils::toSet/toList
... and unrelated cosmetic changes.

Change-Id: I591b17fd5289831e701b683f8fb47816efd1fa67
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-07-04 12:28:38 +00:00
hjk
473a741c9f Utils: Rename FileName to FilePath
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>
2019-05-28 12:23:26 +00:00
Nikolai Kosjar
e0c7722441 CppEditor: Modernize
modernize-orgad
modernize-return-braced-init-list
modernize-use-auto
modernize-use-default-member-init
modernize-use-equals-default
modernize-use-nullptr
modernize-use-override
modernize-use-using

Change-Id: Ifa862782fb7b56ed3f93d9f98685c3af616797c2
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-02-08 08:39:58 +00:00
Nikolai Kosjar
55f4c28889 CppEditor: modernize-loop-convert
Change-Id: I80382880a3c35ef0b59729bd222a626bc5c4a32b
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-08 07:52:23 +00:00
David Schulz
7b7a2ad630 TextEditor: Use callback in refactoring markers
Allows to trigger actions without adding specific handling into the
editor.

Change-Id: Ia63d65d3feca37bcefca1b6322ade039027a92d8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-01-25 06:13:11 +00:00