Commit Graph

417 Commits

Author SHA1 Message Date
David Schulz
5f8ffd66ff QmlJSEditor: fix assigning outline toolbar widget
Instead of adding a second toolbar widget, replace the current one. This
avoids weird situations where you get two outline toolbar widgets, one
provided by qmljseditorwidget and another one provided by qmlls.

Turning the language server on deletes the combobox created by
qmljseditorwidget, such that qmljseditorwidget has to recreate
its combobox after the language server stopped being in use.

Also make sure that m_outlineCombo is set to nullptr after it gets
deleted, such that late jumpToOutlineElement and
updateOutlineIndexNow() calls do no try to attempt stuff on an already
free'd pointer.

Change-Id: Ie323a7b3e7a4d5e24407fcedf8383dd2f0efe525
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2024-06-18 11:23:13 +00:00
David Schulz
411100b037 TextEditor: remove text editor action handler
Give each editor a context and register editor actions individually for
that context. This removes the need to tell the action handler the
current editor. Additionally all actions are now available in editor
widgets outside of the EditorManager.

Change-Id: I0109866b180889762f8bd8aa07874d8d7c55bfa6
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2024-04-09 10:52:26 +00:00
hjk
320a0da060 QmlJsEditor: Work around moc-produced 'using namepace'
... for QmlJsEditor::QmlJsEditor causing ambiguities.

Change-Id: If15a0cb0410093857848b871d7f99c84b1b35826
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2024-01-16 11:48:53 +00:00
hjk
53ebc15918 QmlJsEditor: Hide plugin class definition in .cpp
Change-Id: I7d6325059aedd92b34072de1fbb05bc72fc95efd
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2024-01-16 09:50:00 +00:00
hjk
63374fb34d QmlJsEditor: Don't export Internal classes
Export two functions doing the actual work instead.
Centralize some repeated code.

Change-Id: I7de674ef7ae5537663d1227d36cc556c4ee3ed74
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2024-01-09 16:17:37 +00:00
Xavier BESSON
90368e2bba QmlJsEditor: navigate from QML code to C++ code
Fixes: QTCREATORBUG-28086
Change-Id: I00acfe49b8e74aa057cb59d8c951d477f8ad487e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-12-20 15:03:39 +00:00
Artem Sokolovskii
62ea85ee6a SyntaxHighlighter: Move SyntaxHighlighter to separate thread
This change involves the relocation of SyntaxHighlighter processing
to another thread. The core idea is to create a duplicate of the
original TextDocument using SyntaxHighlighterRunnerPrivate::cloneDocument.
A new SyntaxHighlighter is then instantiated by SyntaxHighLighterCreator
for the cloned document. The entire SyntaxHighLighterCreator class is
moved to a new thread, where it performs highlighting on the cloned
document. Upon completion of the highlighting process, the resultsReady
signal is emitted, and the updated highlighting data is applied to the
original document.

This shift of SyntaxHighlighter to another thread enhances the user
experience by preventing UI slowdowns during the highlighting process.

- Introduction of BaseSyntaxHighlighterRunner as an interface class for
future *SyntaxHighlighterRunner.
- Inclusion of DirectSyntaxHighlighterRunner class for performing
highlighting in the main thread, suitable for syntax highlighters
that cannot be moved to another thread.
- Introduction of ThreadedSyntaxHighlighterRunner class for highlighting
in a separate thread, preventing UI blocking during the process.
- Addition of Result data to the SyntaxHighlighter class to facilitate
data exchange between threads.

Task-number: QTCREATORBUG-28727
Change-Id: I4b6a38d15f5ec9b8828055d38d2a0c6f21a657b4
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-12-11 09:55:02 +00:00
Christian Kandeler
ba249a3514 QbsProjectManager: Add a language client
... and use it to follow symbols that QmlJSEditor does not know about.
For now, the only implemented case on the server side is getting to a
product or module via a Depends item.
More functionality will follow.

Change-Id: I597c7ab10f4bf6962684ed26357dfc0eef3a6c15
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-11-27 13:00:36 +00:00
Artem Sokolovskii
4bfc3476f4 SyntaxHighlighter: Move highlighter creating to TextDocument
Added setSyntaxHighlighterCreator function to TextDocument
which allows the creation of highlighters inside TextDocument.

Change-Id: I454f800c878c48a154dad5abd68b7a4f9ceb378a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-11-20 14:52:20 +00:00
hjk
6685f0255d Utils/all: Move mime constants into a central place
They are reasonably standardized, and generally usable cross-plugin,
so this can help to avoid a few cross-plugin compiletime dependencies.

Change-Id: Icb2b010c3e12dee69df54ab16f6f8e90d9cffba6
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-11-08 09:59:26 +00:00
David Schulz
80633a59aa LanguageClient: support additional goto targets in symbol support
Allow to follow to the symbol definition as well as to the type
definition for the symbol under the cursor position.

Change-Id: I8ff50b33a1e739f81b0832b1b28ffc525e1f7177
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-09-29 09:10:14 +00:00
Sami Shalayel
77b368045c qmljs: use qmlls for 'go to definition'
Use the language client in qmljseditorWidget to do 'go to definition'
aka 'findLinkAt', when the language client is enabled.

Also move static helper method getQmllsClient up in the file.

Task-number: QTCREATORBUG-29567
Change-Id: I4f9132ba5f6bffc5090f3b1f7f6ccfd0c7b40e2a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
2023-09-20 12:59:27 +00:00
Sami Shalayel
25e1266c26 qmljs: add option to disable builtin codemodel
Add an option in the QML Language Server settings to disable the code
model, for now it allows to use qmlls for renaming and find usages
operations.
Some of the checkboxes in the qmlls settings were not making a lot of
sense, rephrased them to be easier to understand for the user.

TODOs for later commits:
* use qmlls for 'go to definition' aka 'follow symbol under cursor'
* add extra action to the context menu for 'go to type definition' and
  implement it using the language client
  * also, remove builtin codemode stuff from the context menu when the
    builtin model is disabled

Task-number: QTCREATORBUG-29567
Change-Id: I6283d99bd2b5dc8aef7df49994eb313bfbb854c6
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-07 07:11:34 +00:00
hjk
b9188fb747 QmlJSEditor: Remove unneeded indirection via qmljsicontextpane.h
Change-Id: I39989fdb697dc7078a01f9582b790ee91021e3ab
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-09-05 07:14:18 +00:00
hjk
c4f2c14aa2 QmlJsEditor: Delay construction of QuickToolBar
It's now apparently created when the first .qml file opens.

Change-Id: I4bcd84d29da268565ee6e771f8c56c8b07ecdaf3
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-09-04 13:40:06 +00:00
David Schulz
c547c8615f TextEditor: optimize setting refactor markers
emitting requestBlockUpdate is not for free so limitting it to blocks
that have changed improve the performance notable for documents with a
lot of refactoring markers.

Change-Id: Ie288a367d1d1d6a9f4359e37ff8486a1dfe36752
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-06-13 11:52:00 +00:00
David Schulz
ba5e09f03f TextEditor: always return a valid assist interface
It is required for updating currently visible proposals. Also guard
against potential null assist interfaces.

Amends 0bd6d7a69f

Fixes: QTCREATORBUG-29096
Change-Id: Ic34d70561b471e7e529f2fb7c239b49712aca502
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-05-02 12:08:04 +00:00
Alessandro Portale
e27f82b49e Translations: Merge "OpenWith::Editors" into "QtC::Core"
Change-Id: I241ccc53afa11fa3faa1f1ca9363421827081812
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2023-02-20 08:00:37 +00:00
hjk
f939f968ea Utils: Consolidate Link::from{FilePath,String}
The input is more unparsed-string-ish in nature, so FilePath is not
appropriate.

Change-Id: I85efb5813b8f5fbbc4127be1c936d5487637b75c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-01-17 09:46:58 +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
Xavier BESSON
3f554f3837 TextEditors: Implement "Follow Symbol" for HTTP urls in string literals
Task-number: QTCREATORBUG-14967
Change-Id: I30923aa94d761b06edb1f67007fd7e2a67065ef0
Reviewed-by: Xavier BESSON <developer@xavi-b.fr>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-12-16 12:08:37 +00:00
Xavier BESSON
9f9c40b29f QmlJsEditor: Implement "Follow Symbol" for qrc paths in string literals
Task-number: QTCREATORBUG-28087
Change-Id: If1e706a96bb9cbb004f826c4d58d7d7f0c306b41
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-12-15 15:35:53 +00:00
David Schulz
0e4b0a26d3 Editor: move ownership of assist interface to processor
This way the base class can manage the lifetime of the interface object
and it doesn't need to be done in each implementation of perform.

Change-Id: Ie1ce742e31b688a337533ee6c57d376146e25ace
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-11-17 13:23:55 +00:00
Andre Hartmann
2bcdc1ee7e QmlJsEditor: Add color preview tooltip
Fixes: QTCREATORBUG-28446
Change-Id: I650c18c0ecf2b6c8572ec3876c38eb313c434392
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-11-15 08:49:38 +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
David Schulz
b88ba1b7a6 TextEditor: add optional action mask for find usage
Change-Id: If8187b226d176c292d0d90aed870f78d9d3d2730
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-23 11:39:07 +00:00
Alessandro Portale
0a6523e7f1 QmlJSEditor: Convert to using Tr::tr
Change-Id: I7e6bc774cdac0ead8ef944a46db120d290419f18
Reviewed-by: hjk <hjk@qt.io>
2022-09-22 16:37:56 +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
Jarek Kobus
ad35f08498 Drop Qt5: Qml lib / QmlDesigner: Get rid of QOverload
Add a context object into some lambdas.

Change-Id: I16ee7a0c061483e4d90c9e015852c41a4f3cde90
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-07-20 13:13:41 +00:00
Fawzi Mohamed
fd89043de2 qmljs: (QString -> Utils::FilePath)++
convert more QString containing paths to Utils::FilePath

Change-Id: I1219d7d147993e48cfa641dc9bea72ab38c90f51
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-07-13 17:13:23 +00:00
Fawzi Mohamed
a235aa29a1 qmljs: avoid linking to files in the build directory
cmake creates a consistent uri structure in the build directory.
We use that as import path, but when we find a type in them we should
refer back to the original file, as editing those is dangerous because
any edit are lost with the next build.
To find the original file we use the qrc, as the qrc path is mostly
the same of as the uri path.
It is possible to add prefixes which would make an exact match fail,
so we compare the paths from the right to the left and find the
longest match.

To acheive this:
 * QrcParser keeps a reversedResources, so the match from right can be
   done efficiently, and provides a longestReverseMatches method
 * the model manager keeps a list of all common prefixes of the
   application paths (build directories), and identify all files in
   build directories
 * the method fileToSource identifies the files in the build directory
   and tries to find the corresponding source file, warning if he
   cannot find it
 * fileToSource is used for follow Symbol and find usages

We could use fileToSource much more aggressively, to use to in editor
content for the files in the build directory, increasing the
consistency, but that is a more dangerous change for later.

Fixes: QTCREATORBUG-27173
Change-Id: Iea61b9825e5f6e433a7390cf2de9564b792458a5
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-06-21 10:39:52 +00:00
Christian Kandeler
a167bd9ad2 Do not pass Utils::LinkHandler by rvalue ref
There is nothing special about this type that justifies it sticking out
everywhere it appears.

Change-Id: Iccdc95163d477db8a031d0d520f28fea26432a44
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-06-07 09:22:30 +00:00
Christian Kandeler
5693c518bc Utils: Rename ProcessLinkCallback to something less clumsy
Change-Id: Icce4995f4aa886524dc3eedb7cf9ba72adbe8783
Reviewed-by: hjk <hjk@qt.io>
2022-06-03 13:23:28 +00:00
Artem Sokolovskii
54d4c4db62 QmlJsEditor: Remove foreach / Q_FOREACH usage
Task-number: QTCREATORBUG-27464
Change-Id: I77741a639d8585d1e0ad04d7c5e6588852202e4a
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-05-18 10:40:48 +00:00
David Schulz
59a77a4965 TextEditor: add text cursor to assist interface
This will allow us to request assistance for a specific selection
instead of just the position.

Change-Id: Ib8e5b32d4a8f2936e5a6f1b7ac968d7f1d8d9de6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-13 09:18:53 +00:00
David Schulz
bfe6c46f9f QmlJSEditor: block non Utf8 codecs
Additionally adjust the postioning of the initial setCodec to all other
forced codecs.

Change-Id: Id60bfdac858851e5ad6554ff2dbcb3dd5b806c0b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-11-09 05:14:02 +00:00
David Schulz
4324f3e8c1 Editor: pass AssistInterface to createProcessor
The interface can be used for checking the context of a codeassist
request to determine
the correct processor that has to be created.

Change-Id: I47ddb05c46399566e27bae21711f11a3a4132c3f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-09-16 08:25:36 +00:00
Kai Köhne
bf04c98c1c Do not pass QStringView by const reference
That's what the documentation says:

  https://doc.qt.io/qt-6/qstringview.html#details

Change-Id: I0b41fc4abad1601c0ed416a505534cf7ae7633e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-06-17 09:54:42 +00:00
David Schulz
356bfcc9fd Utils: filepathify Link
Change-Id: Ie62500bde139158e776f9698ee0ea00c2a113f93
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-05-25 17:32:18 +00:00
Tim Jenssen
b801a9339d Merge remote-tracking branch 'origin/4.14'
Change-Id: I70504e096be620434f38cd990c593950da8b24ba
2021-01-07 14:23:46 +00:00
Christian Stenger
e7a65dd3c9 QmlJSEditor: Ensure extra selections are ordered
The code model may provide selections that are not ordered
as they appear inside the document due to the declarative
nature of QML.
Ordering before using them avoids couple of warnings stating
"overlay selections not in order".

Change-Id: Ie912e94aa01ffde52b01dca7a9bde24ae02e8b33
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2021-01-07 11:07:45 +00:00
Alessandro Portale
a3857a996a Don't access static functions/fields via instance
Courtesy of readability-static-accessed-through-instance

Amends: b2a766a79a

Round #2: This time done with Qt Creator's Analyzer, which
found other occurences than run-clang-tidy.py

Change-Id: I479e280c7abcf2d24baccbb0af69ae4bda05198e
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-11-27 13:26:07 +00:00
Jarek Kobus
d2e1feceac Don't clash signal names with other methods
In case when signal name clashes with other method name -
rename accordingly.
Remove some repeated signal declarations - they are already
declared in superclass.

Change-Id: Ie1430b85d6436d26996494fa44c7554fb354b6ce
Reviewed-by: hjk <hjk@qt.io>
2020-11-18 12:20:43 +00:00
Eike Ziller
cc502e3667 Remove bool return value from IEditor::restoreState()
It's never used, and actually there wouldn't be any sensible thing to do
with it.

Change-Id: Id8a8df18c7db4b98e5abbc034240bb90dc1dcaa9
Reviewed-by: hjk <hjk@qt.io>
2020-09-24 13:02:56 +00:00
Eike Ziller
cf2a651c3b Make QmlJS(Tools) build with Qt5 & Qt6
Port from QStringRef to QStringView

Change-Id: I472d16f20e40ca52b8e5d481850a6bd8a1a38f3b
Reviewed-by: hjk <hjk@qt.io>
2020-09-17 09:37:23 +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
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
3559af69db TextEditor: move rename symbol action to text editor
Task-number: QTCREATORBUG-21578
Change-Id: I9a873dcd38bacb2287c45973b6be0091c3eb9480
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-05-12 04:28:19 +00:00
David Schulz
dee0997d38 QmlJSEditor: jump to file under cursor if it exists
Don't limit this functionality to files that are part of the snapshot,
but try to open all files. This will allow opening c++ files defined in
a qbs project file.

Fixes: QTCREATORBUG-22685
Change-Id: If2a2a2075e5d7113a7bb44625c0f29ef66138d3c
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-04-23 13:00:07 +00:00