Commit Graph

72 Commits

Author SHA1 Message Date
David Schulz
cdeac76df3 LSP: react on file list changed signal from project
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>
2020-05-13 10:58:25 +00:00
Alexis Murzeau
84b068d1b3 LSP: addDiagnosticsSelections should be static in Client.cpp
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>
2020-05-12 22:28:44 +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
3268e5f0bc LSP: Add setting to provide initializationOptions to the language server
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>
2020-05-11 22:33:45 +00:00
Alexis Murzeau
5868e15c30 LSP: Always override the assist providers if the server supports them
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>
2020-05-11 22:32:09 +00:00
Alexis Murzeau
2d5a981b9c LSP: allow non versioned text document in SemanticHighlightingParams
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>
2020-05-11 22:30:49 +00:00
Alexis Murzeau
5d9d0b876a LSP: underline code with diagnostics from the language server
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>
2020-04-29 19:36:51 +00:00
Alexis Murzeau
6118463d39 LSP: Fix language server desynchronisation when whole file contents change
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>
2020-04-29 19:36:31 +00:00
David Schulz
03dd165474 LanguageClient: Fix setting trigger chars for function hint provider
Change-Id: Ibd9f647ea6005638a06524aeac9ea64a0632b0d0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-03-26 05:50:44 +00:00
David Schulz
821f073f15 LanguageClient: Add logging window
Change-Id: Ib86b70381b69df55d62a97abdf52b747f7f1c75e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-03-02 13:38:46 +00:00
Eike Ziller
fa59e02f89 Merge remote-tracking branch 'origin/4.11' into 4.12
Change-Id: I8cc80483cdb10309bf73aba5cfab52c1d90e1bbc
2020-02-26 08:14:47 +01:00
David Schulz
8625bbfe5a LanguageClient: Fix client restart after crash
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>
2020-02-25 13:17:13 +00:00
David Schulz
45381e9d04 LanguageClient: Only send contentsChanged notification to reachable clients
Change-Id: Id35b94d3c6f9b3b08b1e66b992ca5fe86cdab6d5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-25 13:17:05 +00:00
David Schulz
db7d12b78c LanguageClient: fix memory leak in client initialization
Change-Id: I30e4032cea5fff46ffd790336729cc6fbaf4b104
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-20 11:56:58 +00:00
David Schulz
29dc8e740f LanguageClient: fix soft assert for uninitialized server
Do not send close documents notifications to an uninitialized server

Fixes: QTCREATORBUG-23598
Change-Id: Iaabd082203a91a56ebcd60f93e6a0c97048e89c1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-20 07:50:40 +00:00
David Schulz
b9af9881a9 LanguageClient: update semantic highlighting only if server supports it
Task-number: QTCREATORBUG-23599
Change-Id: I76c804b51362ad6ab2aecf0631a16289a33e4810
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-18 12:03:29 +00:00
David Schulz
7cba257299 LanguageClient: Print json before error message
This saves a roundtrip when reporting bugreports where an unexpected
error shows up.

Change-Id: Id2e7cbd86a456ea794f0791199077f931cab03c5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-12 11:25:10 +00:00
David Schulz
e3c7b72003 LanguageClient: introduce new type for gorgeous formatted errors
Change-Id: Ia76bd768bcb6d33ce66319dddf8cc355a41ffa31
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-12 11:25:01 +00:00
Eike Ziller
5c121d5791 Merge remote-tracking branch 'origin/4.11'
Conflicts:
	src/plugins/genericprojectmanager/genericproject.cpp

Change-Id: Ib54f1645ec70a9e6460a888a13190ede130bccca
2020-02-05 11:59:35 +01:00
David Schulz
5f1fd0caee LanguageClient: keep the project on client reset
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>
2020-01-22 11:55:18 +00:00
David Schulz
55a10b0e7a LanguageClient: add lsp based auto formatter
Change-Id: I2a7347961b4633868aa3b033c351a1e709c3597e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-01-22 08:42:32 +00:00
Eike Ziller
267946d100 Merge remote-tracking branch 'origin/4.11'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/boot2qt/qdbrunconfiguration.cpp
	src/plugins/boot2qt/qdbrunconfiguration.h
	src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp
	src/plugins/qnx/qnxrunconfiguration.cpp
	src/plugins/remotelinux/remotelinuxrunconfiguration.h

Change-Id: I17c8e1bf300bb75d7317ccf7749dd3cc07709c21
2019-12-16 16:19:44 +01:00
David Schulz
017ed74400 LanguageClient: Fix crash on closing qc while restarting a server
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>
2019-12-10 11:34:30 +00:00
Eike Ziller
9f21f59e68 LanguageClient: Support markdown tool tips with Qt 5.14
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>
2019-11-19 12:26:04 +00:00
David Schulz
30587e6dce LanguageClient: Do not add hover handler twice to editor
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>
2019-11-06 12:40:23 +00:00
David Schulz
bfc65cee98 LanguageClient: create TextMarks only for active clients
Fixes that marks from all running clients are shown after splitting the
editor.

Change-Id: Ia76a084e5b133d5f7205ac79f9584b211d73b501
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-10-17 08:04:47 +00:00
David Schulz
9afc5305d6 TextEditor: more FileName -> FilePath renaming
Change-Id: Ia61868806db47561e7bf7ae9b3cfb1e62a085a7a
Reviewed-by: hjk <hjk@qt.io>
2019-10-01 07:54:11 +00:00
David Schulz
e24ef9ca08 LanguageClient: always reset code assistant providers
Change-Id: Ic31eb11822b0ca1d82d0274f9b01749cebeecb2b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-09-20 06:59:19 +00:00
David Schulz
59c4d92186 LanguageClient: Fix typo
Change-Id: If565199b92b45c2c2fe7069180613e61d25e7738
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-09-19 08:53:55 +00:00
David Schulz
468f604900 LanguageClient: have one active client per open document
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>
2019-09-19 08:53:47 +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
567a20843f LanguageClient: remember opened documents by TextEditor::TextDocument
... instead of Utils::FilePath

Change-Id: I4ca38ca127fbb1a503a0cb9b5228cab325519550
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-09-16 07:31:49 +00:00
David Schulz
d3c94edd93 LanguageClient: only send contents of TextDocuments to the server
Change-Id: Ifdcd6ba161336814744c51f15e35a756960cb199
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-09-12 10:53:57 +00:00
David Schulz
45cd20c4a0 LanguageClient: remove unused function
Change-Id: I2177d6d4a11bdaf9666a1e529b3231c291aa4123
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-09-12 08:13:15 +00:00
David Schulz
704de8d676 LanguageClient: set assist provider trigger characters just once
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>
2019-09-12 07:26:51 +00:00
David Schulz
bf6fd00163 LanguageClient: remove unsigned cast for HighlightingResult
Change-Id: Iefcc316a4a471e39f52cd8c7709a9feb967263aa
Reviewed-by: hjk <hjk@qt.io>
2019-09-11 12:01:22 +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
David Schulz
332031d677 LanguageClient: open a document in just one client
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>
2019-09-09 13:29:33 +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
Eike Ziller
4ce34fd90f Merge remote-tracking branch 'origin/4.10'
Change-Id: I88a6704fb8d723a3cbdfb1a2d9c84741f30d4da6
2019-07-22 09:34:47 +02:00
David Schulz
18e6962fca LanguageClient: reverse error list for initialize errors
like it's done in Client::handleMethod.

Change-Id: I78c8c43f93ebde20b662fa3d1b6032d83ccac0fd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-07-19 07:33:22 +00:00
David Schulz
c65e480cbd LanguageClient: include the range length in document updates
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>
2019-07-19 06:00:58 +00:00
David Schulz
3fbb5ddba8 LanguageClient: Show outline after server start
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>
2019-07-18 08:34:18 +00:00
David Schulz
307f1d8e6e LanguageClient: add support for proposed semantic highlight
implements the current proposal for the semantic highlighting
via the language server protocol.
https://github.com/microsoft/vscode-languageserver-node/pull/367

Change-Id: I857d606fcf5c782e0ea8e18e5d098edd26286aed
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-06-21 08:37:11 +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
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
c874f07d53 LanguageClient: add hover handler
Change-Id: Iddf30828ef26a157ab935d0abe708087ab123dd6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-05-17 09:18:41 +00:00
David Schulz
e04339b1e8 LanguageClient: only replace the default completion provider
Change-Id: I36977132ac8094fd31d7bc255a1666ba807810bb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-05-17 09:18:32 +00:00
David Schulz
10611f2af9 LanguageClient: always set client capabilities
Not just if a project is currently set.

Change-Id: I07b19695464025a9d039364ff1611aa39e8e1a9b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-05-17 09:01:29 +00:00
David Schulz
763f114c83 LanguageClient: send partial document in update notification
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>
2019-05-13 10:14:24 +00:00