Commit Graph

45 Commits

Author SHA1 Message Date
Christian Kandeler
cf6bd7e012 Fix occurrences of the contains/insert anti-pattern
Introduce and make use of Utils::insert() for QSet with a return value
that indicates whether insertion actually happened.

Change-Id: I655e4bc3553b74fea5ae8956205e4d8070118d63
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-06-23 09:51:54 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
David Schulz
2d0456f085 LSP: Support remote LSP file paths
Change-Id: If3cf1b8d675ef091427dbcd703c7d14b384a1b3a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-12-15 09:49:48 +00:00
Christian Kandeler
13f40f5471 Utils: Add sorted() function
For simpler calling code.

Change-Id: Ia0a16a28770fd172f74d06a626148248bf5d3c0c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-10-25 14:29:45 +00:00
Marc Mutz
8eb4d52342 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I88edd91395849574436299b8badda21bb93bea39
Reviewed-by: hjk <hjk@qt.io>
2022-10-07 13:47:53 +00:00
Eike Ziller
04e50438eb Utils: Remove Utils::optional
Since we are now requiring macOS 10.14 we can remove our local
implementation of optional and use std::optional for macOS too.

Change-Id: I2bd018261b68da64f7f031a812045dd7784697e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2022-09-01 06:58:04 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Marco Bubke
84c1d6572b Utils: Remove variant.h
Since we are now requiring macOS 10.14 we can remove our local copy of
std::variant and use for macOS std::variant too.

Change-Id: I589d03b35fc56878b7392ffa7047a439e588fe43
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-23 09:51:43 +00:00
David Schulz
7c79e18831 LanguageClient: cancel running semantic token request
... when we are about to send a new semantic token request.

Change-Id: Ibd421dd29bf3ea0e2b502c227341ff03259b2370
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-07-08 05:05:23 +00:00
Christian Kandeler
9cbe2439dd CppEditor: Do not highlight macros as preprocessor statements
Macros are used like identifiers; there is no reason why they should need
to have the same highlighting as a preprocessor directive.

Fixes: QTCREATORBUG-23548
Change-Id: I186befc06ccb36a00451fd707c41e3687a84af14
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-06-29 09:08:27 +00:00
David Schulz
178d555151 LanguageClient: prevent assert in semantic highlighter
Do not send messages to server that are not reachable, but queue the
highlighting requests until the client is fully initialized.

Change-Id: I7da140ec33fb1974d3eaed03110ed85dc3a87594
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-06-20 12:43:46 +00:00
David Schulz
29f8db31ff LanguageClient: fix semantic highlight after a server reset
Change-Id: I3a389ec82032d21e2eb932ae8d0e8d5678575427
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-20 11:24:09 +00:00
David Schulz
a493970e05 LanguageServerProtocol: remove IContent
Do not pretend to support multiple message types, while no other
messages are actually implemented by us or even known to exist in the
wild.

Change-Id: I49ee2118b2e10f265ac641c195df8a9e5c97951c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-05-20 06:35:47 +00:00
David Schulz
26df1852d0 LanguageClient: do not highlight unknown tokens
If the language server registers token types for unsupported tokens do
not use the default text style for those tokens since it might overwrite
correct syntax highlighting.

Thanks to Alex Drozdov for providing a patch

Fixes: QTCREATORBUG-26193
Change-Id: I5d70763bc1e9434ffc6241d94f50f3bb3852e62c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-04-27 12:16:00 +00:00
David Schulz
fabbf88db5 LanguageClient: add support for two additional token types
Change-Id: I46f80af0da8cb42262842b5243630fa0087d564a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-04-27 12:15:55 +00:00
Eike Ziller
f562ebf239 Mimetypes: Make implementation switchable between new and old
- configure with QTC_USE_NEW_MIMEDATABASE to switch to the new one in
  utils/mimetypes2/
- added utils/mimeutils.h header for the Qt Creator specific static
  wrappers, that also includes the "public" headers for MimeType et al
  from the new or old implementation, depending on configuration
- change all utils/mimetypes/ includes to utils/mimeutils.h
- move the implementation for the wrappers to
  utils/mimetypes(2)/mimeutils.cpp
- also move the MimeDatabase declaration in the "old" implementation
  back to utils/mimetypes/mimedatabase.h

Change-Id: Ie8de229c035d6cd9a5e4739dc0fa78d9c17228e3
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-02-25 07:19:58 +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
9fea2af1e9 LanguageClient: keep semantic tokens after receiving error
A usual error we receive for semantic request is that the request got
canceled. This can be due to external changes. But a server might still
be able to calculate a diff against a previous token set. So just keep
the previously reported tokens and rerequest a new highlight. If the
server is not able to calculate a diff it also might send a full
token set as a result for the delta request according to the protocol.

Fixes: QTCREATORBUG-26624
Change-Id: Ia91e599706519dbbf4cd22050484e4f36cecdab8
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-01-14 13:57:08 +00:00
Eike Ziller
d422b408e0 Merge remote-tracking branch 'origin/6.0'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri

Change-Id: I32991a77e52831dd2e24cf4a51ec252998c2d743
2021-12-09 12:04:32 +01:00
Christian Kandeler
67cf7c08d0 LanguageClient: More verbose logging when clearing token data
Change-Id: I3f9883858fa2f23dff00cda9f556f0f4bbff127a
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-12-08 09:46:25 +00:00
Eike Ziller
d62d0f305b Merge remote-tracking branch 'origin/6.0'
Change-Id: I71b19dd8ecd96a7a2a58622f68283b8635264e48
2021-12-01 09:24:05 +01: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
b38251659b LanguageClient: more log output in the semantic highlighter
Task-number: QTCREATORBUG-26624
Change-Id: Ib276662f1ce2cf355015258c564f6f9c817a3d8a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-29 09:44:58 +00:00
Christian Kandeler
5769dbe0aa ClangCodeModel: Force clangd re-highlighting on font settings change
Change-Id: Ie449a5329bd49eac116751e66a07602f316e147d
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-11-15 14:35:02 +00:00
David Schulz
b41280b942 LanguageClient: do not send semantic requests to unrelated server
Change-Id: I97207a8569a5e26a7587fefc07d638b17d36d40b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-15 14:28:33 +00:00
David Schulz
426fde79d6 LanguageClient: support semanticTokens/refresh
Fixes: QTCREATORBUG-26499
Change-Id: Icd5879609bb856797fa223394357a1f15554d2cf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-11-03 07:46:50 +00:00
David Schulz
3b62755061 LanguageClient: additional log output for the semantic highlighter
Change-Id: Idc4d71bd988b9a23a6718932b4102a00fb94488e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-11-01 07:16:25 +00:00
Christian Kandeler
6f26a1545c ClangCodeModel: Check doc revision when highlighting with clangd
Change-Id: I981d375e3656e89bb66516218e3f4e33ee8bbb9e
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-25 08:45:07 +00:00
Christian Kandeler
2eb50afd9c LanguageClient: Fix document version update
... for empty semantic tokens delta.
Amends 86061fb44a.

Change-Id: Id6d6cdc1904ea5353d18cea57b55ed3fa16727de
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-25 08:43:11 +00:00
David Schulz
86061fb44a LanguageClient: save document version for semantic tokens
Change-Id: Icd17e7f140cd172b2515711a3562c479f0ad488d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-10-22 09:23:27 +00:00
Christian Kandeler
847a03786c LanguageClient: Re-highlight also on empty deltas
This is needed for e.g. ClangdClient, which may need to update even if
the highlighting delta from the server is empty.

Task-number: QTCREATORBUG-26183
Change-Id: I38398c9563fa7a6a1906c5cb57fd1cbcd444cbd9
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-09-07 09:12:13 +00:00
Christian Kandeler
e0e8fda580 ClangCodeModel: Use clangd for completion and function hint
Change-Id: I80160f3a40da18ac178682afe6caba5e5af6e3eb
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-08-23 09:06:31 +00:00
David Schulz
bbb06a72ec LanguageClient: reapply semantic highlight after font changed
Change-Id: I609e26b7f85744fdffb8399e0d651691b7c39900
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-08-10 06:20:20 +00:00
Christian Kandeler
f55d5d8ec1 LanguageClient: Do not re-highlight when receiving the error variant
... of a SemanticTokens message.

Change-Id: I0f6e55d6656c11e7925e3bc4400ea2e575b9f138
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-09 07:30:21 +00:00
David Schulz
5d33982513 LSP: reload semantic token if we encounter corrupted data
Change-Id: I73185b0b7be57d348fc1a461b1db0383313d7208
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-07-06 04:58:50 +00:00
Christian Kandeler
68846a7729 ClangCodeModel: Provide highlighting via clangd
Note that we lose the highlighting for virtual function calls. We need
to amend clangd to add the respective information to its semantic tokens
message.
Also, Qt properties are no longer highlighted as class members. We'll
investigate how to best restore this feature.

Change-Id: I403712aada3d7a8e1c7b7c1277f43f7f64f8450b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-07-05 07:39:06 +00:00
David Schulz
62cf127376 LanguageClient: highlight methods as functions
...like our internal or clang code model.

Change-Id: Ibe817611276999815fd28a22a73e07671a696479
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-06-10 11:46:58 +00:00
David Schulz
2d31ae0480 LanguageClient: Fix semantic token highlight
Ignore unknown modifiers when building up and accessing the text char
format hash.

Change-Id: I7e11e3fb6f4240083045368daec54e417416efa9
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-06-10 11:46:52 +00:00
David Schulz
0ab08e8574 LanguageClient: fix semanctic token delta data manipulation
Make sure that multiple edits are in order.

The SemanticTokensEdit start is relative to the start of the data and
not to the position of the previous edit.

Do not try to be smart when calculating the start of the modification,
but assume that start is always a preedit index.

Change-Id: I3e1513f5fe631aac21fecb5e0611d987355e2c21
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-12 12:14:54 +00:00
David Schulz
0938452199 LanguageClient: remove unnecessary member function calls
Change-Id: I27e626cdef9c8f645cc1ea2f79ec6cfda09342fb
Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
2021-05-06 10:48:09 +00:00
David Schulz
f1bb3b6811 LSP: add semantic tokens
Change-Id: Ia6865ec6991ec62ae9f0dc2dfa692f1f27318ed1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-21 11:33:56 +00:00
Tom Praschan
5fcd52fe83 ClangCodeModel/TextEditor: Add support for highlighting parameters
This is already built into clang, so we just need to expose it to the
highlighter and the UI.

Fixes: QTCREATORBUG-24880
Change-Id: I6d0595af2589a9b69eb954aafad46457ab2c5752
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-03-15 09:48:24 +00:00
Alexis Murzeau
aa68902b62 LSP: update semantic highlighting to use more colors
The actual highlighting of the C++ code using clangd doesn't use many
colors to differentiate symbols (for example, fields of a class).

This commit makes symbols more visible for these categories:
 - static methods
 - preprocessor macros
 - struct and class fields
 - static fields

Change-Id: I001325cf5e48aa07d7397b2b7ac98a65501e1d5d
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-04-29 19:36:39 +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
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