Commit Graph

91 Commits

Author SHA1 Message Date
David Schulz
30f21bcf01 LanguageClient: Generate BaseMessage only once per send content
Change-Id: Ife4135dce924db83b8539035b4837ecee1403ad8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-19 08:16:13 +00:00
David Schulz
116fb0895d LSP: move diagnostic handling from client in a separate class
Change-Id: Id70a7b82137d3a4591de521380199e546e8685f4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-15 10:45:49 +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
David Schulz
3a51cdf2ba LanguageClient: avoid recursive postponed document update
Change-Id: Ibaf8831977e254c7dad10617754e763114993aee
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-11 11:57:34 +00:00
David Schulz
44271262d9 LanguageClient: Fix crash after server shutdown
Unconditionally reset the assist provider even to a null pointer

Change-Id: Ie8f87802ab26b4a686704b792adc726a50f98bab
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-09-08 10:41:58 +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
Eike Ziller
f296ed1328 Merge remote-tracking branch 'origin/4.13' into master
Change-Id: I1c426d95eedd82bd4470a64a9bafd734d23081ac
2020-08-13 11:41:32 +02:00
David Schulz
2ca4010f2d LSP: use DocumentUri as workspaceFolder
Fixes: QTCREATORBUG-24452
Change-Id: I596138e658118f7b348c22e67d60d153f547fdfa
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-08-13 06:44:06 +00:00
Eike Ziller
3944162039 Merge remote-tracking branch 'origin/4.13' into master
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/cmakeprojectmanager/cmakebuildstep.cpp
	src/plugins/cmakeprojectmanager/cmakebuildstep.h
	tests/auto/debugger/tst_namedemangler.cpp
	tests/auto/qml/codemodel/check/tst_check.cpp

Change-Id: Iefd5f71c03c0078513b76a92af764a4fb22ee4c2
2020-08-10 15:56:54 +02:00
David Schulz
91e78936fe LSP: prevent nullptr access
Found by coverity scan

Change-Id: Ibc243abbb40cde8c670084c9486fdd2f47b137de
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-28 11:35:17 +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
d097330b40 LSP: remove qt version check for markdown
Change-Id: I54da2acf5e3542355064b916582f3507b6bc5356
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-07-10 06:13:36 +00:00
hjk
e1c88116b3 Core/Utils: Migrate further to Utils::Id
The coreplugin/id.h header is kept for downstream for now.

Change-Id: I8c44590f7b988b3770ecdc177c40783e12353e66
(cherry picked from commit 430a33dcd9)
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-07-06 11:15:18 +00:00
hjk
430a33dcd9 Core/Utils: Migrate further to Utils::Id
The coreplugin/id.h header is kept for downstream for now.

Change-Id: I8c44590f7b988b3770ecdc177c40783e12353e66
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-07-06 06:07:13 +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
David Schulz
2b36770d07 LSP: add rename functionality
Fixes: QTCREATORBUG-21578
Change-Id: Iec54ebed6358453af4ef16a2a4e6aef0418faebe
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-17 07:51:52 +00:00
David Schulz
4121eccf1e LSP: add symbol support class
Declutter the client and client manager by moving find usage and follow
symbol into this helper. This functionality was "temporary" put into the
client manager, but is more an implementation detail that shouldn't be
handled in that central place. Rename symbol will also go into this
helper class.

Task-number: QTCREATORBUG-21578
Change-Id: I56680f6ccbb8d244066561167178af7b341b8822
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-05-19 10:10:12 +00:00
David Schulz
8f5109b6ee LSP: Robustify open documents
Use Client::openDocument if you just want to open a document and
activate it if it is not already used in another client.

Use LanguageClientManager::openDocumentWithClient if you want to make
sure a document is opened _and_ activated for a specific client.

Change-Id: I6b790f15e17335ce2dc8981a04d2cd571b22b66b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-05-14 09:51:26 +00:00
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