Commit Graph

31 Commits

Author SHA1 Message Date
David Schulz
d729835c24 LanguageClient: add snippet parsing
Task-number: QTCREATORBUG-22406
Change-Id: I5b3a65984f1b4a9198bcbfec24aaa920dcb6dbf1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-10 11:46:37 +00:00
David Schulz
14067cca86 LanguageClient: filter completion results
Use the optional filter text or the label of a completion item to filter
out results that do not match the current completion prefix. Fixes
completing code with language servers that do not provide server side
filtering.

Done with: Thorbjørn Lindeijer

Change-Id: Id27b88bb4e8f0b8b68d6ee49bd1d41ec11d54c45
Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-01 09:33:30 +00:00
David Schulz
44e7047450 Editor: Allow defining custom snippet parser function
Task-number: QTCREATORBUG-22406
Change-Id: I21ae9740d348d4e0869029343d51b70f9df9cdac
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-25 08:16:38 +00:00
David Schulz
d17277b546 LSP: reduce error handling complexity
Instead of checking recursively every possible object just check the
required keys for an object and validate it on construction or
assignment from json.

This will reduce the implementation effort for protocol extensions and
also reduce the false positives we might get if the protocol gets
updated.

Change-Id: I3df24e62430d2c7575d26c1581e6a9606e7da4c1
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-03-02 12:51:47 +00:00
Eike Ziller
aae3bf4ef7 Merge remote-tracking branch 'origin/4.14'
Change-Id: I516e87eed1b716ec085095c9dd4f47f04a99de7c
2021-01-25 09:06:36 +01:00
David Schulz
6564234dd9 LanguageClient: fix dynamic registered completion provider
Change-Id: I4c770b5b59b30b22a280a526b881b3b47bc43f45
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-22 08:54:34 +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
20f51bc642 Merge remote-tracking branch 'origin/4.13' into master
Conflicts:
	src/plugins/languageclient/languageclientcompletionassist.cpp

Change-Id: If12e1c532e5623ef063681309a918e7b51117b1c
2020-09-14 10:12:14 +02:00
Christian Stenger
24f35037d1 LanguageClient: Fix regular expression
The match has to be a full match to avoid always validating
the full file if located at a literal.
This fixes bad performance of language clients in big files.
Amends 119a3c1ce9.

Change-Id: I7153f3d7d7125715846de7626d215093feae2908
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-09-09 10:44:05 +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
Christian Kandeler
760d91665f TextEditor: Make threshold for automatic completion configurable
Fixes: QTCREATORBUG-19920
Change-Id: Id6be79485b1fb8c2ab4cce2706816949ae5e217b
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-08-13 13:49:44 +00:00
David Schulz
11ea89d936 LSP: Explicify API
Change-Id: Id208a420fd3e1e23d3279c4f1f19bdbed994a8d3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-15 08:31:30 +00:00
David Schulz
ca0f504c0e LSP: workaround msvc 2017 bug
Change-Id: I6a6fbfc1a582d83df3f3cf489236c7ca4c6626f7
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-07-14 10:48:31 +00:00
David Schulz
e323529b3c LSP: Compress document change notifications
Change-Id: Iaf6cb99784f4e1ed1291ace1f4cc18cf6af88672
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-22 04:23:06 +00:00
Christian Stenger
119a3c1ce9 LanguageClient: Replace QRegexp by QRegularExpression
Task-number: QTCREATORBUG-24098
Change-Id: Ic8259ded3f721957bd04aa00146b20bd90b41dcd
Reviewed-by: hjk <hjk@qt.io>
2020-06-19 12:48:54 +00:00
David Schulz
f3407bb0ca LSP: fix codeassists running check
Since MessageId is always valid (needs to be fixed separately)
use an optional to store whether we have a request running.

Change-Id: I7a1f136a09d776b33509bc914247d11076abeaa5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-05-14 09:46:55 +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
Alexis Murzeau
95d9eafc8a LSP: CompletionRequest: set triggerCharacter when possible
When the completion request is triggered by an activation character,
set the triggerCharacter accordingly.
This can help the language server to propose more sensible items.

Detected while trying cmake language server. It was throwing an error
when triggerKind is TriggerCharacter and triggerCharacter is not present.

Change-Id: Ifde578e39f2eebfc5c6551f08985f4408f6c7933
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-05-11 22:34:40 +00:00
Christian Stenger
c7e2ba9c14 LanguageClient: Fix passing proposals
Pass the real proposals around instead of a copied
nullptr.

Change-Id: I1a8678bcbd5838113f6416b6f63d92d6cceceb3f
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-03-02 13:44:27 +00:00
David Schulz
1f37eaa265 Editor: Fix crash in codeassist
We have to report back to the code assistant even if we have no results.
Otherwise the processors aren't correctly reset and may be called after
deletion.

Change-Id: Id7af2e0ee9f631efc00beb2a84bfe1824e138d24
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-26 08:18:58 +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
Nikolai Kosjar
9a567a48dd LanguageClient: Fix some bugprone-branch-clone
Change-Id: If1eb43168db65190983049f30bf217f0628e78e4
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-11-04 13:18:27 +00:00
David Schulz
f0ad5813b9 LanguageClient: more FileName to FilePath renaming
Change-Id: I803211d462b442b6881a02e870d2cd816675e0d9
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-09-17 08:15:40 +00:00
David Schulz
f0a3779513 LanguageClient: reset all assist providers
Instead of just unsetting the function assist provider and quick fix
assist provider reset it to the previous provider.

Change-Id: I46c5c2f14234e3da08480dd103e4634859447d57
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-09-11 07:37:17 +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
David Schulz
970a09519d LSP: reredo completion replacement logic
replacing the text from word start to current cursor position only works
if we are not currently at a word start. For example completing:

  object.function(var|)

will not replace the already typed var, because selecting from cursor
position to word start does not select anything.

Try selecting from current position backwards as long as the inserted
text matches case insensitive to the already available text, or select
the match of the "[a-zA-Z_][a-zA-Z0-9_]" regex. Whichever selected text
is longer will be replaced.

Change-Id: I73965183ba430a8de1b7725e1f7bc7621861433f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-05-09 10:25:24 +00:00
Nikolai Kosjar
741e8d8aba LanguageClient: Use empty icon for unknown completion item kind
...instead of a null icon.

Without this, a completion item gets no icon and looks misaligned
between items with icons. For example, for the completion item "size_t"
(a typedef) clangd reports a completion kind of "Reference", for which
we do not have a dedicated icon.

Change-Id: Ibba658d6bfb958bb34747e3f57514af49f5427b0
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-05-08 06:17:16 +00:00
David Schulz
d28a452053 LanguageClient: enable commit characters for completion items
While a completion is currently active a commit character can
automatically apply the current item and close the current completion
widget.

Change-Id: Ia962eed69684f8f13f54b88934c63700532103e7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-05-07 07:57:41 +00:00
David Schulz
5eca6c031f LanguageClient: redo completion replacement logic
Instead of trying some magic when applying completion items just replace
the text from the current position back to the start of the word.

Change-Id: I03ac0f8c9bced88d21bd51f9e5cfa0a3ea25025a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-05-06 09:01:15 +00:00
David Schulz
0eb3b54434 LSP: add completion context to completion request
Change-Id: I97df6d70ef2ad6e6e1fc0153cd1589b5d5c9683b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-04-25 06:24:05 +00:00
David Schulz
c6415e2652 LSP: collect and execute quick fixes via shortcut
Fixes: QTCREATORBUG-21802
Change-Id: I611fac1c3fc5b094816441e36492ed57706c98b8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-12 12:57:31 +00:00