Fixes opening projects that lazy load their file lists. For example
CMake projects open without a file list. This list will be generated
after a successful configuration of the project.
When a session is loaded that contains an open document from a project
the document and project open signal is triggered when there is still no
connection between these two. So recheck the project for documents after
the file list got updated.
Also add documents that are already opened before they are assigned to a
project.
Change-Id: I6f2bde0edf88a505116b05efe5564318f2cfb892
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
That function should really be static, it is not meant to be used
elsewhere.
Also, replace duplicate "uri.toFilePath()" with just set filePath
variable.
Change-Id: I11e6cd2133d8999b34ed24b774ab13036f2b9fc8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: David Schulz <david.schulz@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 language server is initialized, the Initialize request can contain
user provided data in initializationOptions field.
Allow the user to set data inside. This can be required to let the
language server have some context.
Change-Id: Ib057fdb940c21b3fd032853fb84253d42ad1e321
Reviewed-by: David Schulz <david.schulz@qt.io>
When the default assist provider is not DocumentContentCompletionProvider
because of some plugin that also provide an assist provider, this would
fail.
If the user has configured a language server, assume is prefer that and
always propose the server's assist providers when available.
This the case for CMake files but probably C/C++ files too if the CppEditor
plugin is configured to handle them.
Change-Id: I641d73466c8b520beb494dae8e6b274debd2881f
Reviewed-by: David Schulz <david.schulz@qt.io>
The proposal of SemanticHighlighting uses a versioned text document
identifier, but there is a suggestion to be more coherent with other
existing requests and use text document identifier instead (non versionned).
See here: https://github.com/microsoft/vscode-languageserver-node/pull/367/files#r225879268
The clangd language server implements the non versioned version.
Existing code was returning errors with clangd because
SemanticHighlightingParams::isValid would return false because of the
missing version field.
Change-Id: I1c36151342437adad2405118ca6b303db0936e41
Reviewed-by: David Schulz <david.schulz@qt.io>
When the language server reports diagnostics, it also reports to which
part of the code the diagnostic applies.
That part of the code wasn't emphasized before, there is only an icon
next to the line and part of the diagnostic message in the text editor,
but no exact clue of which word is targeted by the diagnostic.
This commit add information about the affected code by diagnostics using
extra selection of type CodeWarningsSelection as other plugins do (like
the clang code model).
If a diagnostic has no severity or is not Error, Warning is used (the word
will be underlined in yellow).
Diagnostics can be either Error, Warning, Information or Hint.
For example, clangd uses Hint for remarks and Information for notes.
Notes can be related to a warning or an error, for example
when a function call has an incorrect number of argument, the call site
will have an error diagnostic with red color and the called function
declaration will have a Hint diagnostic with a yellow color.
Change-Id: Ifa433553be95a4913541d5570a2758ac213e7075
Reviewed-by: David Schulz <david.schulz@qt.io>
When the whole file contents are changed, for example because of changing
the highlight definition when there is several candidates, the language
server will behave as if the file's content was the result of
concatenating two times the file's content (leading to duplicate
declarations errors for C++).
The issue is that when this happens, the didChange message indicate
only the added portion of the change without the removal of the whole file
beforehand (ie: the range is empty and the text is the whole file content).
This is because charRemoved and charAdded are equal to the length of the
document which is not exactly the number of /visibles/ characters, but also
including some invisible formating characters according to QTBUG-80662.
This causes the QTextCursor to ignore the second setPosition because of
invalid position out of range.
Fix this using the same code as QWidgetTextControlPrivate::_q_contentsChanged
that is to use qMin to ensure the end position is not after the end of
the document according to QTextCursor.
For charsAdded, document->textAt takes care of that itself, via
Utils::Text::textAt.
See also: QTBUG-32583, QTBUG-80662
Change-Id: If781707d42253f4659005754efa73d872577f738
Reviewed-by: David Schulz <david.schulz@qt.io>
Do not clear open documents but disconnect and deactivate them,
so they can be correctly reopened once the server is restarted.
Change-Id: I0f61a5461c020865e61d9808e8c645ea842f64ad
Fixes: QTCREATORBUG-23648
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Do not send close documents notifications to an uninitialized server
Fixes: QTCREATORBUG-23598
Change-Id: Iaabd082203a91a56ebcd60f93e6a0c97048e89c1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This saves a roundtrip when reporting bugreports where an unexpected
error shows up.
Change-Id: Id2e7cbd86a456ea794f0791199077f931cab03c5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
It won't be set again when restarting the server.
Task-number: QTCREATORBUG-23497
Change-Id: I28b4c4f9169a2de94d7ea7f6712c3900fd7099ee
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reset the assist providers when restarting a server, so the client can
be safely shutdown while closing Qt Creator.
Change-Id: I4d5f18582a8c67cbe02974d72fcef9703ed64dc4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Use Qt::MarkdownText if language server returns markdown and it was
built against Qt 5.14.
Change-Id: I75787cfcb32480cb37bc0dadc4be12d005005099
Reviewed-by: David Schulz <david.schulz@qt.io>
Check whether an editor already contains the hover handler before adding
to the list of handlers. Also remove the handler when a document is
deactivated for a specific client.
Change-Id: Iec1d3a0fd1dc3f02c8dd50b8968ff063efe2508a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Fixes that marks from all running clients are shown after splitting the
editor.
Change-Id: Ia76a084e5b133d5f7205ac79f9584b211d73b501
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
open a document in all clients supporting the document, but have just
one client that provide functionality like highlights, completions, and
find usages.
Change-Id: I6bd72eb022005ed643fefd1da139d482f4dd5279
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
... instead of Utils::FilePath
Change-Id: I4ca38ca127fbb1a503a0cb9b5228cab325519550
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Instead of setting the completion characters every time after a document
was opened only set it when the server capabilities are set.
Change-Id: Ia37dc426a98aca1a4884752ac5da2659bfda53ec
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>
Also show a menu when triggering the language client toolbar button that
allows you to manage and switch between different language clients. The
default language server used to open a specific file type is determined
by the order of the servers inside the settings.
Change-Id: Ib1b21dd2c04d4559f538705e6ba229af043e02ae
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
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>
The did change notification parameter has an arguable redundant range
length field, but it seems that there are language server out there
which rely on the presence of this field.
Change-Id: Id29132fb6586a2886b8ba6d9a13df52a64f31161
Fixes: QTCREATORBUG-22694
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
If the server was started by opening a document the outline factory and
client was not properly initialized in the time the outline was
requested. Update the outline after the client is fully initialized.
Fixes: QTCREATORBUG-22695
Change-Id: I84dc56eead9774d80ed6baf7792daff930a7cb8e
Reviewed-by: Eike Ziller <eike.ziller@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>
Reduce the amount of transferred data between client and server by
sending events which just contain the changed part of the document
instead of the full content if the server supports those events.
Change-Id: I596930c405bd7a71e4219e328b449fca67664750
Reviewed-by: Christian Stenger <christian.stenger@qt.io>