Commit Graph

68 Commits

Author SHA1 Message Date
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
15419cb145 LSP: Fix completion assist that could be the wrong provider
When a document is opened that uses a language server, it would not gain
the completion assitance from the language server in some cases.
Instead, the default completion assist provider is used, which in case of
the TextEditor, will only provide basic autocompletion.

The reason is that Client::activateDocument is not called if the document
is not in LanguageClientManager::m_clientForDocument when
Client::openDocument is called. The check is at the end of that function.
When the issue happens, openDocument is called indirectly from
LanguageClientManager::documentOpened.

The fix is to change the order of instructions in
LanguageClientManager::documentOpened so m_clientForDocument is updated
before calling openDocumentWithClient.

This way, the language server's completion assist is really used as it
should.

Change-Id: I0d2b3b8573e97c0c0c4bd517775668d41a4a797b
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-04-29 19:36:20 +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
83eab470c1 LanguageClient: Only send position changed signals to reachable clients
Change-Id: I0d387ea10aeba8f5f1be3d0ddb6a6ccb82e04e64
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-02-25 13:16:58 +00:00
David Schulz
73161356d5 LSP: take account of resolveTarget when checking for links
Return a link to the word under cursor when the target should not
get resolved. This results in a highlight of the text the mouse cursor
is positioned on when pressing ctrl to follow a link.

Change-Id: Iaf1ba289644ed3e3fc062b418dd2fa3bfa8da6ad
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-11-28 14:05:05 +00:00
David Schulz
02b7a529dd LanguageClient: request link from active server for the document
Instead of sending the link request to all reachable server send it only
to the server that is currently used to handle this document.

Change-Id: I27a8d0e4573f734baa2931a0af771e60665a4532
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-11-18 14:40:28 +00:00
David Schulz
6399188090 LanguageClient: prevent accessing deleted document
By always removing them from the list of opened documents also for
uninitialized clients. Fixes crash when closing creator before the
initialize response of a language server was handled.

Change-Id: I81fb15d8d9d7bf47300a6eac373ef9db04387bd4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-10-29 08:17:41 +00:00
David Schulz
28c3f0c31e Python: Add info bar entry to enable pyls
Show an editor info bar entry displaying that the language server for
the current python is disabled and a button to quickly enable the pyls.

Change-Id: I3adb2e7cbfb1a32e35413b0b06dfbe66a0b214af
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-10-18 05:23:29 +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
57749e91e8 LanguageClient: allow adding settings via the manager
This adds the possibility to configure language servers
from other plugins.

Change-Id: I33c7d637ddd73dcfc0d02c366b8b9749ac1c2b98
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-09-23 09:51:41 +00:00
David Schulz
20e6e84b1a LanguageClient: Add already open documents to starting client
After settings are applied in the manager make sure to assign all
open documents to the newly created clients if the document filter
accepts them.

Change-Id: I30e06e37bc4fde0bc7bab34a2de564a7df043edf
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-09-23 08:51:46 +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
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
Eike Ziller
8df0653bf8 Merge remote-tracking branch 'origin/4.10'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/projectexplorer/gcctoolchain.cpp
	src/plugins/qmldesigner/components/stateseditor/stateseditormodel.cpp

Change-Id: Iffdf48e782a734107ea170ebb3812e997cea0e7b
2019-09-12 09:08:04 +02:00
Orgad Shaneh
2aca0c1b28 Fix MSVC warnings
* Missing `this` captures
* Implicit size_t -> int conversion
* Unused argument
* Suppress warnings in clang headers

Change-Id: I7083ce6ab22ee22ecc1258539e77c790acc78df1
Reviewed-by: hjk <hjk@qt.io>
2019-09-11 15:20:34 +00:00
David Schulz
a8fa9c5f89 LanguageClient: Fix wrong notification after will save signal
Change-Id: I9470dc7ea9058f43fcf61d4721c3aee1348a7d6e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-09-11 04:45:44 +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
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
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
0c5837a111 LanguageClient: Fix crash after disabling client setting
Change-Id: I0f9ec02edc645726764fc9ea9ea1832e40bbef80
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-05-09 11:07:34 +00:00
David Schulz
69e880c050 LanguageClient: add current document locator filter
Change-Id: I20442a254e4e016088b2da845d87af6e9f836731
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-04-30 05:19:31 +00:00
David Schulz
0ea840c2bd LanguageClient: add option to start client per project
Some server like rust or haskell require a project at server startup.
Add option that postpones the server start until we can assign a project
to an open file.

Change-Id: Iaa475289e833b27a730a90ea228f5d85ecc30338
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-04-29 09:52:02 +00:00
David Schulz
5c7d8a20c7 LanguageClient: move setting client relationship to manager
Change-Id: I9bf712227d44eada28abb18bbf641a2bfa835914
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-04-24 09:01:11 +00:00
David Schulz
ad703e108b LanguageClient: move current settings to manager
In preparation to have relationship between clients, settings and
project to one another in the manager.

Change-Id: I00ae15abe03c54b4a58e429d67d6ff939662cce6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-04-23 06:44:12 +00:00
David Schulz
d1fd3ea667 LanguageClient: only use BaseSettings in the settings API
Change-Id: Ie2ccda8fe4349f495f31a5d46254b68f6074ac6d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-04-04 08:18:48 +00:00
David Schulz
37d0525953 LanguageClient: remove friend relationship between manager and plugin
Change-Id: I594d62615f365db34174c4bd1e6c8a9f6aeb545a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-04-04 08:18:41 +00:00
David Schulz
dac8262aeb LanguageClient: show icon with assigned server names in toolbar
Change-Id: I44ceeb184812a4c48f042a19197c7f0ffd4299f8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-04-03 07:09:59 +00:00
David Schulz
35baa3e89d LanguageClient: send project folder on server request
The server can request the list of opened projects via the
"workspace/workspaceFolders" request. Add a creator response for
this request.

Change-Id: Ieadf604aeb920da28f085b8441e6f9af1f540fd3
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-04-02 07:57:16 +00:00
Christian Stenger
266e525a4e LanguagClient: Fix missing connect
Change-Id: I45fcafcce9d46df41788016a39b3ce1263e2ac9a
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-03-25 13:35:59 +00:00
David Schulz
a6f0e564d4 LanguageClient: Add option to start server when needed
Until now all servers where startet on creator startup. Change this
default to start server when first file that matches the configured
filter is opened. Additionally add an option that restores the old
behavior of always on servers.

Change-Id: I595e0ede1cf136cc803181377155bcd58ca1a83c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-03-15 11:31:53 +00:00
Eike Ziller
c53ccceff1 Merge remote-tracking branch 'origin/4.9'
Conflicts:
	qbs/modules/qtc/qtc.qbs
	qtcreator.pri
	src/plugins/debugger/debuggerkitinformation.cpp
	src/plugins/languageclient/languageclientmanager.cpp
	src/plugins/plugins.pro
	src/plugins/projectexplorer/kit.cpp
	src/plugins/projectexplorer/kitmanager.cpp

Change-Id: I66fb941202991f35f7d7761430b21e42dfc678a8
2019-03-14 15:51:15 +01:00
David Schulz
6b59d711a8 TextEditor: return all BaseTextEditor for a document
Change-Id: Iab483528357fdba1b7107130c19370974c03979c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-03-13 05:38:00 +00:00
David Schulz
a78bbe48cc LanguageClient: connect the opened editor to LanguageClientManager
... and not just the first one returned by
BaseTextEditor::textEditorForDocument

Change-Id: I39e9271b3a2b6c0f131a5ce77959a8d57e462397
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-03-12 13:46:59 +00:00
David Schulz
543ab86ebc LanguageClient: connect each editor widget to the LanguageClientManager
... not just the first returned by BaseTextEditor::textEditorForDocument

Change-Id: I262cd68e6dea59aa23be718fb85d2ae68c40ef39
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-03-12 12:47:52 +00:00
David Schulz
dd92ef15c1 LanguageClient: Use document instead of editor opened/closed
Makes sure that the same document is not twice reported as opened to the
language server.

Change-Id: I348b0f4d8f9162e6ba73a4e3292abce146935eca
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-03-12 12:47:43 +00:00
Christian Stenger
3d1efce0a4 LanguageClient: Fix possible crash on shutdown
If a shutdown is in progress we need an immediately delete
of the client to avoid accessing an already deleted
TextMarkRegistry instance when deleteLater() is triggered
too late.

Change-Id: I274f40532cec0bfc026322a633441a1856cb848c
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-03-06 09:05:52 +00:00
David Schulz
fa1862c782 LSP: move text marks from the manager to the individual clients
Diagnostics are “owned” by the server so it is the server’s
responsibility to clear them if necessary. So do not delete the
corresponding text mark after a file was closed, because the server does
not have to resend the diagnostics when the file is reopened. Only
delete text marks when they are replaced or when the client is deleted
or reset.

Change-Id: Ief821c7ec401f4c52ee30d99f8dec47dcd6f1c98
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-04 11:22:59 +00:00
David Schulz
93ea656821 LSP: rename BaseClient -> Client
Since BaseClient isn't part of an inheritance hirarchie any more the
Base doesn't make sense now.

Change-Id: I69200b19a22e5a04079e5289a02234af4f56a1bd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-04 09:43:22 +00:00
David Schulz
aa2ad04e04 LSP: add Command and CodeAction support to the language client
Change-Id: I9e86c17b87c6b6aef36bd0ca293d9db40c554aad
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-01-31 14:20:44 +00:00
David Schulz
49bd5b6c50 LSP: add a convenient function returning a TextDocument
...for a Utils::FileName

Change-Id: If490eba29a50f20c2f19f741e60f09244ee73cb6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-01-25 09:49:25 +00:00
David Schulz
d14490d302 LSP: Collect usages of the symbol under cursor
Fixes: QTCREATORBUG-21577
Change-Id: I2bc6a0ac094eb74f802f5fe77a6eab2c82cbbbbf
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-01-17 06:39:40 +00:00
Alessandro Portale
128a33548b Fix warning: "Missing reference in range-for with non trivial type"
[-Wclazy-range-loop]

Change-Id: I5dcb263c754d423740e7bce3dcb948d52f2dec67
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-01-16 20:22:56 +00:00
David Schulz
0a8a4bad7e LSP: add outline support
Fixes: QTCREATORBUG-21573
Change-Id: If579715c84210eb80d258ec944e00f1fac1badbe
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-01-10 07:26:08 +00:00
Eike Ziller
e5c2ee922a Merge remote-tracking branch 'origin/4.8'
Conflicts:
	src/plugins/cpptools/compileroptionsbuilder.cpp

Change-Id: I743ea39480cc5c7b6febcd2e93713d15a3ae6d9c
2018-12-07 08:53:11 +01:00