Commit Graph

72 Commits

Author SHA1 Message Date
Semih Yavuz
df2e55d92a Opt out qmlls semantic highlighting
Apperantly, qmlls semantic highlighting is not as powerful as the
embedded code model's highlighter. Disable lsp based highlighting until
qmlls semantic highlighting reaches the feature parity with the QtC
highlighter. This is tracked by QTBUG-126550.

Task-number: QTBUG-126550
Fixes: QTCREATORBUG-31083
Change-Id: I6cab94d4ba1d1cde50b62ce03a6b1cc5b6d7d27b
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-06-24 07:35:03 +00:00
Sami Shalayel
3b558792eb qmlls: ignore versions from Qt 6.7 or below
Do not select qmlls executables from versions below 6.8 by default,
as those have less features than QtC's builtin codemodel. Add an
option to re-enable using qmlls versions from Qt 6.7 or below,
which is off by default.

Fixes: QTCREATORBUG-31088
Change-Id: I56bfd39bc980996a92232cbcb424252d755cdfc0
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2024-06-21 07:31:38 +00:00
Christian Stenger
6b7c6bde5a QmlJSEditor: Avoid crash on temporary documents
Fixes: QTCREATORBUG-30739
Change-Id: I62872fc23529674d5fca6dcb6255872eab12a9da
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-04-26 05:12:57 +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
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
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
David Schulz
a18ea390e1 LanguageClient: Fix crashed client restart condition
Change-Id: I4b0195a512b6b1dcbcc6fd02f6014a27b4606ea0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-10-20 10:47:44 +00:00
Sami Shalayel
79cc12ab8c qmljseditordocument: fix quickfix shortkey
QtC shows qmlls's warnings, but does not apply quick fixes to it when
using the quickfix shortkey. In quickFixAssistProvider, use the base
class implementation to detect running language clients and apply their
quickfixes, and fallback to the builtin qml code model quickfix if no
language client is running.

Fixes: QTCREATORBUG-29557
Change-Id: I75262d13ab229f8d3b4069fc0003574d41cabab0
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-09-04 11:08:07 +00:00
Jarek Kobus
8dd46d0399 Various Plugins: Simplify return FilePath statements
Change-Id: Ia9efb86f722caca1492b577d51442f1f23b804b4
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2023-08-02 08:19:23 +00:00
David Schulz
b794e98233 QMLLS: fix crash on opening non existing qml files
The automatic handling of the document inside the language client
manager is normally done after a document was opened successfully. Since
the QML document registers the document manually on construction before
the file was tried to be opened the automatic cleanup inside the manager
does not work. Postpone the document registration like in the
PythonDocument after the document was opened successfully.

Fixes: QTCREATORBUG-29021
Change-Id: I2dd9e2da9c9ed6d38414ad991df3c03b62e9d611
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-04-24 06:25:19 +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
1aa2d8ad30 QmlJSEditor: do not wait for the semantic info update
... when destructing a qmljseditor. Just let the updater continue and
delete it once it finishes.

Fixes: QTCREATORBUG-28206
Change-Id: Icabe10f17b7bf326bb15e5ee622504c477d83acf
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-22 10:48:06 +00:00
Fawzi Mohamed
d8987a1042 qmljseditor: remove unneeded import
Change-Id: I99da4f9083759041da1a839f6f451a4a4bd787ca
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-10-18 08:17:05 +00:00
Fawzi Mohamed
e27af202fc qmlls: move isSematicInfoOutdated to private object
this avoid use of the (still unintialized q->d) in settingsChanged in
the constructor

Change-Id: Idd756fc88df166124c34a6177a9d598604634057
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-14 13:45:43 +00:00
Fawzi Mohamed
3baf305f9b Automatic qmlls support (experimental)
Looks for qmlls (the qml language server of Qt) and if available
and set in the preferences uses it instead of the embedded code
model for the supported features.

Its usage is driven by two flags that can be set in the QtQuick > QML/JS
Editing preferences: "use qmlls" activates the use of qmlls if available;
"use latest qmlls" always uses the qmlls of the latest Qt, instead of
the one of the target (with the one used to compile QtCreator as
fallback).

To support disabling/enabling of qmlls as soon as one changes the
preferences the singleton QmllsSettingsManager can emit a signal
on changes.
It also keeps track of the latest qmlls binary known.

QmlJS::ModelmanagerInterface::ProjectInfo is also extended to keep track
of the qmlls binary.

QmlJSEditorDocument uses the ProjectInfo and QmllsSettingsManager to
decide if a LanguageClient::Client should be started for that
document.

The client uses the QmllsClient subclass to keep track of the path of
the qmlls clients and use the same qmlls process or all files that
use the same binary.

Currently qmlls <6.4.0 are not considered because they might have too
many issues.

The enabling/disabling of warnings and highlight is a bit cumbersome
because they are handled together in the semantic highlighter, but
must be handled separately depending on the qmlls capabilities.

The disabling is done at the latest moment stopping the visualization
of the embedded model warnings/highlights/suggestions.
The computation of the semantic info is not suppressed to support the
other features (find usages, semantic highlighting if active,...).
When qmlls supports more features a complete removal of the semantic
info construction could be evaluated.

Change-Id: I3487e1680841025cabba6b339fbfe820ef83f858
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-10-12 16:09:04 +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
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
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
6b270b8dc9 qmljs: correctly handle js string templates
In most cases we do want to visit the expressions in a function
template. Changing its accept0 would force those not wanting to visit
it to iterate on the templates (currently a linked list), so we add a
visit method explicitly visiting the expression in all the needed
places.

Fixes: QTCREATORBUG-21869
Change-Id: I47733544bfd32eec357810b97242608b8f7de572
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
2022-03-21 09:32:29 +00:00
Eike Ziller
3749cfc896 InfoBar: Make adding more buttons possible
Change-Id: Ic0c946cf3f87fe46cd06391f38e0bc71374ad340
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-01-18 09:33:20 +00:00
Fawzi Mohamed
125d7c0cce Updating qmljs parser to latest qtdeclarative parser
improves support for string templates, required properties,
and other smaller improvements

Task-number: QTCREATORBUG-21869
Change-Id: Ia2359e1f75d4bd7b9ea4f27a920acd2251e36108
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-16 08:27:55 +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
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
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
Eike Ziller
7c5ed6f7d9 Move InfoBar to Utils
The only reason it was required to be in Core plugin, was its use of Id,
which now is available in Utils.

Change-Id: I66ce863c24924e6448d339b3422538a7fe167336
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2020-06-18 06:39:54 +00:00
Fawzi Mohamed
b09a48599e Update qmljs parser to Qt 5.15 parser
* parser side support for annotations, inline components, new UiVersion
  and all the things included in QT 5.15 parser
* SourceLocation moved from QmlJS:AST to QmlJS
* Visitors now need to handle throwRecursionDepthError
* BaseVisitor for visitors that want to override all visit

Task-number: QTCREATORBUG-23591
Change-Id: I682a30d0b08b6c929739fd0e339ef6fbde3eb630
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-03 15:31:10 +00:00
Eike Ziller
59e2774d0d Qt Quick: Separate Qt Quick Designer and QMLJS editor factories
Currently the QmlJSEditorFactory hardcodes that .qml.ui files are opened
"in Design mode", without any option to explicitly open them directly in
text mode.
While this is the preferred way of working, there are always exceptions.

Separate the "Edit mode by default" and the "Design mode by default"
parts into separate editor factories. The former one is the default
editor for .qml files, the latter for .qml.ui files.

This allows users to explicitly choose "Open With > QML JS Editor" to
open .qml.ui files directly in Edit mode.

Fixes: QTCREATORBUG-18123
Change-Id: I72ab2d25fdc538210123782f6611f9c6e3157dea
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2019-08-15 12:29:07 +00:00
Eike Ziller
e9272d848b QmlJsEditor: Avoid unneeded exports of constants
Change-Id: I332ff9a01963fe4d37dce9ecd0586d8f0fa6573c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-07-19 07:21:26 +00:00
hjk
6f37348b4c Replace static_casts by QOverload where possible
Mainly to get rid of the QProcess::finished deprecation warning.

Also adjust coding style in the surrounding connects when needed.

Change-Id: I12f9b248c7974b892c4a069356e578e80f8c59e9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-26 15:18:14 +00:00
Ivan Donchevskii
d7058e1afe ClangFormat: Refactor indenter to allow ClangFormat unit-tests
We do not build texteditor files in unit-tests so some tricks
were required to make ClangFormatIndenter available.

First simple unit-test proofs it builds and runs.

Change-Id: I81d5ea099bd27fd1c1ed8b5b7877299dcc62a67f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-22 09:52:15 +00:00
Alessandro Portale
5242f58173 QmlJSEditor: Modernize
modernize-*

Change-Id: I4dceb82c3904069a0d9848b2af61122d9282cb36
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2018-12-10 18:54:57 +00:00
Marco Benelli
4646acad0d qmljs: update parser
Update the qtcreator qmljs parser to the
one of Qt 5.12. It supports EcmaScript 7.

Task-number: QTCREATORBUG-20341
Change-Id: I0d1cff71402ba17e22cde6b46c65614e162280de
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2018-11-22 11:21:32 +00:00
Eike Ziller
922e506296 QmlJSEditor: Fix missing override
Change-Id: I617d7363779b30c882ce96b08e56c74f3cb1df96
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
2018-09-18 13:15:31 +00:00
Alessandro Portale
3d3f14e3fe Prefer using 'override' instead of 'virtual'
warning: prefer using 'override' or (rarely) 'final' instead of
'virtual' [modernize-use-override]

Change-Id: I6dac7a62b627fa1353b4455e1af92f869c2571cc
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
2018-07-11 16:31:35 +00:00
Eike Ziller
4cba1d7c71 Merge remote-tracking branch 'origin/4.6' into 4.7
Change-Id: I5ffa9febea2ced10892a145aa0b930d45d84aea5
2018-06-11 14:31:54 +02:00
Marco Benelli
50f536b9ae QmlJs: check markers before cleaning them
Task-number: QTCREATORBUG-20197
Change-Id: If4594a72abf4acf2455e55688679ba7f78900f76
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2018-06-08 09:02:21 +00:00
Eike Ziller
45f8d221bf Use FileName in TextMark
Change-Id: I3666d95dc8ef3b7da099d6d30f5cb4678a349493
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-05-03 06:51:47 +00:00
Eike Ziller
428fcb476b Merge remote-tracking branch 'origin/4.6'
Conflicts:
	src/libs/utils/settingsaccessor.cpp
	src/plugins/autotest/autotestplugin.cpp
	src/plugins/git/gitclient.cpp
	src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
	src/plugins/qbsprojectmanager/qbsrunconfiguration.h

Change-Id: I65f143cad18af509a2621d6c5925abbd038ea70f
2018-04-13 10:54:42 +02:00
David Schulz
a2c362af31 QmlJSEditor: fix crash after document reload
Clean up all marks in the document destructor, to prevent accessing
already deleted member in a TextMark callback.

Task-number: QTCREATORBUG-20199
Change-Id: Ica996ea393b9ae636c731f009a6d39552ff35e26
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
2018-04-11 08:18:49 +00:00
Orgad Shaneh
7d3a79c696 Utils: Purge asConst
Replace by qAsConst.

Change-Id: I3301366f73c066c86f08df7188d70dc3b613c55c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-04-09 09:04:00 +00:00
hjk
3da9c89981 QmlJSEditorPlugin: Refactor
This follows the recently introduced pattern for plugin setup
- Pimpl QmlJSEditorPlugin
- remove unneeded uses of global object pool
- apply "static pattern"
- simplify some constructors of data members in some cases
- use in-class initialization in some case

Change-Id: I95b42d0885f4a8d6c9bfe1e4c004d3ace0a3eba5
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-02-15 13:31:13 +00:00
Christian Stenger
3e81fe628a QmlJSEditor: Avoid detaching of containers
Change-Id: I52bb5b073793c11cf157cb72244ba3552ca1ac72
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
2018-01-22 13:58:57 +00:00
David Schulz
f9c959cee2 QmlJSEditor: Move ownership of QmlJSTextMarks to document
Task-number: QTCREATORBUG-19607
Change-Id: I65fa11b43dcbe3c28ab100a1636ad592cfff5a4d
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-01-22 12:10:02 +00:00
hjk
ff04632b92 TextEditor: Remove QuickFixAssistProvider
It did not contain any functionality beyond the base IAssistProvider
anymore.

Change-Id: I0198b3d629f81be8c994ffed3904b5f12ee7f9b9
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-12-15 11:42:40 +00:00
Tim Jenssen
99f2fc9b45 QmlJSEditor: use direct member initialization
Change-Id: I03aada10107a9d80d920d18c92df7ec36e6a22d4
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
2017-04-03 12:28:49 +00:00
Orgad Shaneh
7609e56ee3 QmlJS[|Editor|Tools]: Use Qt5-style connects
The heavy lifting was done by clazy.

Change-Id: I56550546b341d486d321329e9a90b9369d56af40
Reviewed-by: Marco Benelli <marco.benelli@qt.io>
2016-06-28 08:47:26 +00:00
Vlad Seryakov
af56457ab6 Add support for new javascript methods to QML/JS outline
Extened AST visitor for outline, declaration and locator to include
Javascript methods, prototype functions with formal parameters for
better readability.

Change-Id: Ifbb2b157699c929412196f356b0c28ae0564f866
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2016-05-20 10:07:58 +00:00
David Schulz
898968b101 CodeAssist: Support only one quickfix assistant per editor class.
Currently we are just using the first that is found. Which could lead
to unexpected behavior. Adjust the API to make clear just one assistant
is supported per editor type.

Change-Id: I711e66b4c5c5f347118357a8bafa0ffc6d650f7e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-04-28 12:14:41 +00:00