Commit Graph

100 Commits

Author SHA1 Message Date
Eike Ziller
aae3bf4ef7 Merge remote-tracking branch 'origin/4.14'
Change-Id: I516e87eed1b716ec085095c9dd4f47f04a99de7c
2021-01-25 09:06:36 +01:00
David Schulz
4f1c5bacb9 LanguageClient: fix multiple crashes in languageClient
The temporary containers are needed in some places because the content of the containers change
while iterating over them.
partially reverts: cf010911f7

Change-Id: I4d6df987b9e5382b6b18fa659b1174ca6919a02e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-01-25 07:42:26 +00: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
Eike Ziller
5c7793b07b LanguageClient: Do not pop up general messages pane
General messages pane should only be opened on direct user interaction.

Task-number: QTCREATORBUG-24430
Change-Id: I526659110fc67c627cb60fe56e1f709f064667c2
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-01-04 07:30:07 +00:00
Jarek Kobus
cf010911f7 Don't allocate unneeded temporary containers
Fix clazy warnings: allocating an unneeded temporary container
[clazy-container-anti-pattern]

Change-Id: I4b4c2c634eea650bbdf3c12d982a17f899fc94ec
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2020-12-14 12:35:47 +00:00
David Schulz
f440dfe43a LanguageClient: Restructure request response handling
Instead of working on a Client member IContent now returns an optional
response handler that consists of an id, a name and a callback.

Change-Id: I5ca7dd4eaa7ae37f333f99c9fe60339db03ebf2c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-12-10 09:31:31 +00:00
David Schulz
7e10d6d7b5 LanguageClient: remove unused function
Change-Id: If931e1e6d2e28eddb599faefda2590324ff0801b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-11-16 05:29:34 +00:00
David Schulz
bf2276ebde LanguageClient: do not generate diagnostics twice
Change-Id: Ib15f67fb362440fa901ae4118cb176b2bf073fdc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-28 13:29:51 +00:00
David Schulz
b0d4414dfc LanguageClient: pass id as a const ref when handling client messages
Change-Id: I7ab6a7517d4dd0fe66f601661e7b3f6a7afb338b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-10-19 15:56:31 +00:00
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