Commit Graph

23 Commits

Author SHA1 Message Date
David Schulz
52770b746e LSP: fix hover request result
According to the protocol a hover request can also return a Null as a
result. Reflect this in the protocol implementation and adapt usages.

Change-Id: I14ce71639c64b6de00e9c1198617083c1a3de9eb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-16 12:36:44 +00:00
David Schulz
4452f71201 LanguageClient: avoid optional::value
Potentially throws std::bad_optional_access. Use operator* and
operator-> instead.

Change-Id: Idefa137da53f3663ea88961f1105b93402ec4777
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-02-24 12:04:38 +00:00
David Schulz
6aa2c58842 LanguageClient: remove semantic highlighting proposal
The semantichighlighting proposal from
https://github.com/microsoft/vscode-languageserver-node/pull/367
was replaced with semantic tokens in the final protocol version 3.16.

This reverts 307f1d8e6e

Task-number: QTCREATORBUG-26624
Change-Id: I635f0b4763a197edabf9edf8d9041143dcf531e3
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-29 09:57:45 +00:00
David Schulz
93fcf5c91f LSP: Fix CodeActionResult
The isValid check now works on both objects since the error message
simplification. So check the command property and see whether it is a
string to identify the object.

Change-Id: Iaafe2d868267ebb83440d72703ee3edc517385d8
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-08 06:14:50 +00:00
David Schulz
d17277b546 LSP: reduce error handling complexity
Instead of checking recursively every possible object just check the
required keys for an object and validate it on construction or
assignment from json.

This will reduce the implementation effort for protocol extensions and
also reduce the false positives we might get if the protocol gets
updated.

Change-Id: I3df24e62430d2c7575d26c1581e6a9606e7da4c1
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-03-02 12:51:47 +00:00
Christian Kandeler
f9efff42e1 LanguageClient: Fix DocumentOnTypeFormattingRequest interface
Change-Id: Ib84f6c475e5bf2faff395d60d4c3b42b0a9d7017
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-02-24 10:57:40 +00:00
Eike Ziller
d400dce35d Require GCC 7 and enable C++17
Fix MSVC2019
- result type of conditional expression is ambiguous:
  types 'const char [1]' and 'QByteArray' can be converted
  to multiple common types

Fix MinGW 8.1
- undefined reference to SemanticHighlightNotification::methodName

Fix Utils::transform with std::vector for GCC & MSVC

Unfortunately we cannot get rid of the special variant and optional
implementations, because Apple Clang requires deployment target >= 10.14
for the functions that can throw std::bad_optional_access.

Fixes: QTCREATORBUG-20520
Change-Id: I5c36a70f21f8b0215d2f4fc5c0653a022778d928
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-07-10 11:52:24 +00:00
Cristian Adam
a2273f9f82 LanguageServerProtocol: Compilation fix for MinGW 8.1
Change-Id: I5b7d643e529217a1077777ee542a48a237fa42b3
Reviewed-by: hjk <hjk@qt.io>
2020-05-19 18:02:28 +00:00
hjk
1dc00ac125 LSP: Link fix
Change-Id: I983987e689e0f57f3243b43d64d112a2960263ec
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-05-19 11:13:32 +00:00
David Schulz
b7382bcf2e LSP: add PrepareRename request to the protocol implementation
Task-number: QTCREATORBUG-21578
Change-Id: I5bd87610d7c49f1e4a09ee1bd2221e4786a1856b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-05-19 10:11:01 +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
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
David Schulz
e941e0cac7 LSP: Fix document range formatting request
Change-Id: Ide1de7def5ddabda5536a75d1400d6ea03bab8fd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-01-09 08:27:58 +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
Christian Stenger
5459d3ca72 LanguageServerProtocol: Fix build on macOS
Change-Id: Id13c0c32d03a7c5226d80afafb952fd33b2d608a
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-05-17 11:36:03 +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
Christian Stenger
90e432aa05 LSP: Avoid unneeded copy inside loop
Change-Id: I7c4d61eda6caf0baacdde01392e2457d54286863
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-08 12:09:08 +00:00
Christian Kandeler
dbf7c9f658 LSP: Fix build
Change-Id: Ic43ce5e2f55dc450fb0a4628dc5de22a4a6f3dbd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-08 10:20:18 +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
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
696dedefa1 LSP: add support for hierarchical document symbols
The result of the document symbol request was a flat list of symbols
until version 3.10.0 of the Protocol. The new result type also added
whether a symbol is deprecated and what text should get selected
when a symbol is activated in the IDE UI.

Change-Id: Id30366c44198434c240f3a21b8b237bf6819a425
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-12-03 11:50:13 +00:00
Leena Miettinen
22547c1ca4 LSP: Fix punctuation and capitalization of UI text
Change-Id: Ifc04d979ec7e989ed50d6af23d18819dd91dc0be
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-10-19 11:55:29 +00:00
David Schulz
d61d29cf16 Introduce a basic client for the language server protocol
The language server protocol is used to transport language specific
information needed to efficiently edit source files. For example
completion, go to operations and symbol information. These information
are transferred via JSON-RPC. The complete definition can be found under
https://microsoft.github.io/language-server-protocol/specification.

This language server protocol support consists of two major parts, the
C++ representation of the language server protocol, and the client part
for the communication with an external language server.

The TypeScript definitions of the protocol interfaces are transferred to
C++ classes. Those classes have getter and setter for every interface
value. Optional values from the protocol are represented by
Utils::optional<ValueType>. The JSON objects that are used to transfer
the data between client and server are hidden by a specialized
JsonObject class derived from QJsonObject. Additionally this JsonObject
provides a validity check that is capable of creating a detailed error
message for malformed, or at least unexpected JSON representation of the
protocol.

The client is the interface between Qt Creator and language server
functionality, like completion, diagnostics, document and workspace
synchronization. The base client converts the data that is sent from/to
the server between the raw byte array and the corresponding C++ objects.
The transportat layer is defined in a specialized base client (this
initial change will only support stdio language server). The running
clients are handled inside the language client manager, which is also
used to connect global and exclusive Qt Creator functionality to the
clients.

Task-number: QTCREATORBUG-20284
Change-Id: I8e123e20c3f14ff7055c505319696d5096fe1704
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-09-03 08:00:46 +00:00