Commit Graph

141 Commits

Author SHA1 Message Date
David Schulz
ba5e09f03f TextEditor: always return a valid assist interface
It is required for updating currently visible proposals. Also guard
against potential null assist interfaces.

Amends 0bd6d7a69f

Fixes: QTCREATORBUG-29096
Change-Id: Ic34d70561b471e7e529f2fb7c239b49712aca502
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-05-02 12:08:04 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
David Schulz
0bd6d7a69f LanguageClient: move completion rerequest logic
...from the code assistant to the language client specific assist
implementation. This further reduces the complexity of the code
assistant.

Change-Id: I08ba5eecea826d3ccfe7f1f5a8791a085299d6ef
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-11-29 06:04:30 +00:00
David Schulz
0e4b0a26d3 Editor: move ownership of assist interface to processor
This way the base class can manage the lifetime of the interface object
and it doesn't need to be done in each implementation of perform.

Change-Id: Ie1ce742e31b688a337533ee6c57d376146e25ace
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-17 13:23:55 +00:00
David Schulz
f297b3f1b5 Editor: always configured assistant
A code assistant is not usable without a text editor widget and is
always created as part of one, so make the dependency obvious by require
it in the construction of the code assistant. This removes a bunch of
functions and cheks.

Change-Id: I96556430082ff729d99d2ae2516599f9b8cbc704
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-11-16 05:24:06 +00:00
David Schulz
09ee528c40 Editor: unify assist processor handling
Define the run type of the processor by its implementation instead of a
enum value of the provider. The execution of a processor inside the
assist now follows a unified procedure.

Change-Id: Ibe9fab324c6072e77702c2663946d7a9f562a085
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-14 13:02:51 +00:00
David Schulz
5eca1ff873 LanguageClient: use internal filtering if we got all completions
... at the current position. This reduces the amount of requested
completions.

Change-Id: I0fa35269bc123513217e3b3abd2c921bd92d8d10
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-11 10:11:33 +00:00
David Schulz
63a8218680 Editor: consider all providers with matching activation chars
Amends 45317da25a

Change-Id: I6bc748f2be54f47c0e23788352f74cecdd5d730f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-11 05:22:51 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Jarek Kobus
bc8ebd3bc7 CodeAssistant: Avoid using sender()
Change-Id: I8483b368ebf5dca684d817390e1138362bf11d6f
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-08-01 14:47:42 +00:00
Jarek Kobus
44f1fd6498 Drop Qt5: Cpp/TextEditor: Get rid of QOverload
Change-Id: I010f211b40f876c0f033fd717aaa094f775ea214
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-07-26 16:58:45 +00:00
David Schulz
13af74a4e8 LanguageClient: remove fragile flag from lsp proposals
Those proposals are not fragile anymore since they reuse the old
completion widget. This fixes vanishing of none idle editor completions
on backspace if there are less than 3 characters to complete.
Additionally this removes the double completion request if there are
more than 3 characters typed in.

Change-Id: Id47d341adf954dfaaaeb70c17f6774ba38cc8bdf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-07-11 12:15:09 +00:00
David Schulz
d3a40b1d04 CodeAssist: Fix disapearing completion list after update
Change-Id: I3e35fe53a69e7806c0c8a5959ef8c16344aace8d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-07-08 10:19:23 +00:00
Orgad Shaneh
4180e1b84f CodeAssist: Fix Coverity issues
* Initialize m_reason in IAssistProposal.
* Remove superfluous null validations.

Change-Id: Icb9b7a7a98db719540586142e30be75f37a4ab92
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-07-04 04:42:22 +00:00
David Schulz
84ef111847 Editor: only close proposal widgets after updates
To prevent closing function hint widgets after the completion processor
did not return a proposal.

Change-Id: I1901f3f21917d348ef12a6db846739e3c54752fb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-28 11:47:34 +00:00
David Schulz
c3cb262154 Editor: Fix dangling completion widgets
Set the correct assist reason when rerequesting a code assist to be able
to detect perfect matches. Also destroy the code assist context when the
processor is not running and has not returned a proposal after perform.

Change-Id: Ieb04203269076655ac3d7ffc54ea8a1d055194a4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-24 04:15:57 +00:00
David Schulz
9f7c822197 CodeAssist: reset flag before starting new processor
If a new processor is started while waiting for a result of a still
running procesor reset the flag whether content was received while
waiting.

Change-Id: I21a254681050d1db077deec88706f0010670e0ac
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-02-07 11:50:04 +00:00
David Schulz
f349de45f4 TextEditor: correctly initialize automatic proposal timeout
Change-Id: I53db54b51361ce3389bb25c420880a117ede7c2d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-12-09 10:48:29 +00:00
David Schulz
a442d275fc Editor: hide old proposal if new proposal is empty
amends 28447355ba

Change-Id: Ica1b95e205be4328e675714dbf81f813a76ec9a3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-10-28 12:18:02 +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
David Schulz
28447355ba Editor: reuse generic proposal widget
Do not close already visible proposal widget if we get new results for
the same base position. Just replace the model of the widget and update
the prefix.

Change-Id: I298aba6eb8177edc17fea783189a2f987dbf15a2
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-02 11:04:55 +00:00
Christian Kandeler
dc4a8b3866 TextEditor: Allow incremental proposals
... and make use of them with clangd.
This way, users can get immediate feedback when a new proposal entry
has been found, rather than having to wait until all of them have been
collected.

Change-Id: I2adfe0153aa7a058f28eb3bd65c71dd30ea018e0
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-18 11:43:08 +00:00
Christian Kandeler
b0d4fc359f ClangCodeModel: Let user choose the override
.... when following virtual function calls.
This brings us up to par with the built-in code model.
We do lose the icons, but they are of very little use in this context.

Change-Id: I29b27d538e7277d06a5af7acee07bddb6eb94c98
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-01 08:22:21 +00:00
David Schulz
ba83b852b6 Editor: Close function hint proposal on destroyContext
Fixes: QTCREATORBUG-25691
Change-Id: I2cb1b52fdda386cbfe3ca7f54746edd3e5562ea0
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-17 09:57:52 +00:00
David Schulz
a86da031c7 TextEditor: Fix is visible check of function hint
Since the FunctionHintProposalWidget is just a proxy witget that uses a
FakeToolTip it is not shown directly so we cannot check the visibility
with isVisible.

Fixes: QTCREATORBUG-25664
Change-Id: I6888e373afcfc79565ce8e3dad1bb05501d58200
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-05 10:11:21 +00:00
Jarek Kobus
e3ae92bc5f TextEditor: Use invokeMethod instead of singleShot timer with 0 delay
Use QCoreApplication::instance() as a context object for the
IAssistProposal deleter.

Change-Id: Idf8cd1955dca146a500da1ea036298455c8a5da1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-02 08:15:28 +00:00
David Schulz
859d2edbb5 TextEditor: Always destroy old context when displaying new proposal
This makes sure that the old proposal widget is disconnected from the
finalizeProposal slot and thus prevents resetting the currently shown
proposal.

Change-Id: I80d58d9a04831d464bea69697568359990ac5260
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-10-26 05:00:49 +00:00
David Schulz
a962a08b1a Editor: fix completion character completions
Cleanup the proposal after an item is activated even if the proposal
widget is not visible anymore. Otherwise we might wrongly cleanup a
proposal that was triggered by a completion character while a completion
list was already open.

Change-Id: Ie95247de09313c5816cffd9a865b05183db02354
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-19 15:56:47 +00:00
David Schulz
2842b613ed TextEditor: request assist after trigger char inserted
... while proposal is shown

amends 23d63dcc8b

Fixes: QTCREATORBUG-24225
Change-Id: Ie935c7c1d4786a4fd3cf338d7f1df52ae28de63b
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-10-05 09:05:25 +00:00
David Schulz
a36bdfc858 Revert "CodeAssist: Avoid pointless completion request after accepting item"
is replaced by 23d63dcc8b

This reverts commit 44b71f7a16.

Change-Id: Ib5adaab4a962a54495b48e6b88ab164046526c37
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-10-02 09:32:02 +00:00
Christian Kandeler
23d63dcc8b TextEditor: Do not invoke auto-completion recursively
It's unclear why that was done, and it threw off the clang code model by
introducing an unexpected sequence of events.

Fixes: QTCREATORBUG-18676
Change-Id: I4dabb56eb97e18141080c22be324c826202977ce
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-09-11 11:44:35 +00:00
Eike Ziller
7aa0b1ea6b TextEditor: Fix build with Qt6
Adapt to QStringRef and QAbstractItemView::viewOptions() removal

Task-number: QTCREATORBUG-24098
Change-Id: Ia2d446312f68bd60143796284d31f5bba56aa0ed
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-09-08 07:47:30 +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
David Schulz
755de9f86a Editor: delete processor after canceling
Set a null proposal has the potential to restart the processor
in combination with the invalidateCurrentRequestData from this
cancelCurrentRequest will result in a restarted processor that is not
tracked via m_asyncProcessor.

Change-Id: Ia0e0d49564170a1e705994933d07e00c23f24f5d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-05-14 10:44:57 +00:00
David Schulz
738726d656 Editor: delete the processor that proposes a result
Not the currently active one.

Change-Id: Ia0e146e61c07564107ca5a3ec6b5b2d65967f572
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-05-14 10:44:45 +00:00
David Schulz
8bde432dfe CodeAssist: Fix leaking asynchronous processors
Currently the ownership of the processor is unknown to the codeassist
when running an async operation. Move the ownership of the processor to
the assist and delete the processor after the proposal was completed.

Change-Id: I6a2e023c47cbc876669dba866bee12b481447cb7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-05-12 08:24:41 +00:00
David Schulz
552ccd6a61 CodeAssistant: add cancel to asynchronous processors
Fixes crash when the processor reports a result after the code assistant
was destroyed.

Change-Id: I8588d3d6acad69f1ec6302e8ba09d642ebbb77f1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-20 12:59:55 +00:00
hjk
251287f0d3 Avoid warning on empty expressions
For some reason, Q_UNUSED includes already a semicolon, adding one
on the user side creates an additional empty statement.

Change-Id: I9c5e8fac381345a60792cb75e2938fd53958d3b0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-07-23 11:55:59 +00:00
David Schulz
b0039f1ec8 LanguageClient: add signature help provider
Change-Id: Ia89c28b574c92802bbfda280115a50f5955f0854
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-05-21 05:46:37 +00:00
David Schulz
14834e6b0a TextEditor: replace generic highlighter with ksyntaxhighlighting
Fixes: QTCREATORBUG-21029
Change-Id: I9894c4384e0e47da6bf030b7b8e07c3ad4737ff3
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-01-28 11:37:08 +00:00
Nikolai Kosjar
44b71f7a16 CodeAssist: Avoid pointless completion request after accepting item
Previously, accepting an item from the completion pop-up triggered
another completion request, but the result of that request was never
displayed since the inserted text was a perfect match.

Now, trigger another completion request only if the inserted text
matches the activation characters.

Change-Id: Ic8ed4139efb10aadc8d41105634fcc856e0a15be
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-11-06 10:01:25 +00:00
Nikolai Kosjar
5601ac2952 TextEditor: Fix requesting more proposals than needed
Since

    commit d61d29cf16
    Introduce a basic client for the language server protocol

extra proprosals were requested in the fragile case on a change
notification, e.g. for function signature completion. Restrict this to
the language client proposal, as it was actually intended.

The language client does not support prefixes, so introduce this concept
for deciding whether to request new proposals or not.

Done-with: David Schulz
Change-Id: Ibc1ad82dbeeea93b85f279c59b8c7289fe6ec726
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-10-23 13:10:52 +00:00
David Schulz
5719adc47c LSP: rerequest completion if contents change while processing
Task-number: QTCREATORBUG-21108
Change-Id: I6ca7920e7099dba0ba1bc953a2e6296bd86c1dc1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-10-19 08:46:13 +00:00
Orgad Shaneh
41dee83bec TextEditor: Modernize
override, auto, nullptr, member initializers.

Change-Id: I04c6ebb683849568973bd7782fb5a3279267141e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-09-20 08:48:49 +00:00
David Schulz
d61d29cf16 Introduce a basic client for the language server protocol
The language server protocol is used to transport language specific
information needed to efficiently edit source files. For example
completion, go to operations and symbol information. These information
are transferred via JSON-RPC. The complete definition can be found under
https://microsoft.github.io/language-server-protocol/specification.

This language server protocol support consists of two major parts, the
C++ representation of the language server protocol, and the client part
for the communication with an external language server.

The TypeScript definitions of the protocol interfaces are transferred to
C++ classes. Those classes have getter and setter for every interface
value. Optional values from the protocol are represented by
Utils::optional<ValueType>. The JSON objects that are used to transfer
the data between client and server are hidden by a specialized
JsonObject class derived from QJsonObject. Additionally this JsonObject
provides a validity check that is capable of creating a detailed error
message for malformed, or at least unexpected JSON representation of the
protocol.

The client is the interface between Qt Creator and language server
functionality, like completion, diagnostics, document and workspace
synchronization. The base client converts the data that is sent from/to
the server between the raw byte array and the corresponding C++ objects.
The transportat layer is defined in a specialized base client (this
initial change will only support stdio language server). The running
clients are handled inside the language client manager, which is also
used to connect global and exclusive Qt Creator functionality to the
clients.

Task-number: QTCREATORBUG-20284
Change-Id: I8e123e20c3f14ff7055c505319696d5096fe1704
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-09-03 08:00:46 +00:00
David Schulz
8749ccc69f TextEditor: sync code completions in snippets
Update all identical snippet placeholder after selecting an item from
the completion proposal.

Change-Id: Iac4f4183c30517a8133269cc607edadce0c6bd23
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-09-03 04:43:58 +00:00
Eike Ziller
847787f146 Merge remote-tracking branch 'origin/4.7'
Conflicts:
	src/plugins/debugger/debuggerruncontrol.cpp

Change-Id: I72882df605bc3fc8a8d20118fd4e49207ac92664
2018-08-07 09:42:02 +02:00
David Schulz
e3a0a710c6 TextEditor: fix crash while request follow symbol and typing on mac
Use a qobject_cast to prevent accessing a not available function.

Task-number: QTCREATORBUG-20910
Change-Id: If2aa6b7b120379681e9590db80904c45a6d9bd55
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-08-06 10:03:23 +00:00
Alessandro Portale
3d3f14e3fe Prefer using 'override' instead of 'virtual'
warning: prefer using 'override' or (rarely) 'final' instead of
'virtual' [modernize-use-override]

Change-Id: I6dac7a62b627fa1353b4455e1af92f869c2571cc
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
2018-07-11 16:31:35 +00:00