It is unclear if and how the client should order completion items, but
at least haskell-language-server provides a sensibly sorted list (not
alphabetically) and doesn't set a "sortText".
Sorting the items alphabetically by label messes up the prioritization
of "best" matches that the server correctly does.
Only sort, if any item has a sortText.
Task-number: QTCREATORBUG-26114
Change-Id: I55a966763e21ba8b85085a087c37e6005438d4e3
Reviewed-by: David Schulz <david.schulz@qt.io>
The label is not sufficient to identify duplicates for language client
completion items, since the changed text is not always equal to the
label.
Change-Id: I4d3295944a78b541144ecac0982e1f09a53bec8a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
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>
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>
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>
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>
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>
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>
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>
Pass the real proposals around instead of a copied
nullptr.
Change-Id: I1a8678bcbd5838113f6416b6f63d92d6cceceb3f
Reviewed-by: David Schulz <david.schulz@qt.io>
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>
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>
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>
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>
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>
...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>
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>
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>