Commit Graph

1238 Commits

Author SHA1 Message Date
Christian Stenger
e2ae2ad41d QmlJSEditor: Support dragging of functions
Currently you can drag around items and properties.
Extend this by JS functions.

Fixes: QTCREATORBUG-21993
Change-Id: I2934450cbaf8646620b43ce33fdb523b5d2803ab
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-06-04 06:35:49 +00:00
Christian Kamm
40dd6fc185 QmlJS: Add workaround for missing imports in Qt >=5.15.0
The QtQuick module plugins.qmltypes in Qt 5.15.0 do not contain
QML types like QtObject. Instead, they are found in the QtQml module.

Something similar applies to QtQml and QtQml.Models and
QtQml.WorkerScript.

As Qt 5.15 can't use the "import" command in the qmldir file, this code
instead detects the 5.15 QtQuick and QtQml modules and adds the
dependent imports manually, as a workaround.

Change-Id: I982e349298eb7200372390dfc384fb43a762b253
Task-number: QTCREATORBUG-23986
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-05-21 07:54:08 +00:00
Christian Kamm
f64146741d QmlJS: Use "import" commands from qmldir files
qmldir files can have lines like "import QtQml". These were already
parsed, but not stored in LibraryInfo. Store them.

When imports are resolved in Link and a library has such an import, also
load the module it refers to, with the same version and "as" scope.

Add a test to verify the behavior works.

Change-Id: I80b260bfaa36a9e5de0849fa5632b3361077ef01
Task-number: QTCREATORBUG-23986
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-05-21 07:53:44 +00:00
Christian Kamm
338fa26bc3 QmlJS: Scan import paths, even if there is only one
Previously a single QML import path would not be scanned. This did not
usually happen to users, as there's almost always more than one path.
But it could lead to unexpected behavior in tests that explicitly
controled import paths.

Change-Id: I015f44f183ad484c333ab7a4e5e98b87098620a7
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-05-21 07:53:24 +00:00
Christian Kamm
96c860159b QmlJS: Track futures to allow testing
Tests often want to wait for all async tasks to finish before
progressing.

Change-Id: I61738df730ca341b5c9d227569d961cd1991b296
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Philip Van Hoof <philip@codeminded.be>
2020-05-21 07:53:11 +00:00
Christian Kamm
037ff590e6 QmlJS: Fix loading builtin library info
The condition was always false, since projectInfoForPath always returns
an empty project member. This meant the the fallback builtins that ship
with Qt Creator were used, instead of the builtins that shipped with the
Qt version.

Change-Id: I9c3bf949d0046bcf687c913e32ddac95734f6c43
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2020-05-21 07:52:51 +00:00
Christian Kamm
6dc87d96b7 QmlJS: Fix bug with async typeinfo loading
There were infinite loading loops, because the unupdated LibraryInfo was
written to the ModelManager.

Change-Id: I22faf017a2c9370e97042152cddc872a3d35fb77
Reviewed-by: Christian Kamm <mail@ckamm.de>
Reviewed-by: Philip Van Hoof <philip@codeminded.be>
2020-05-18 10:27:09 +00:00
Eike Ziller
be73f41ad4 Merge remote-tracking branch 'origin/4.12'
Change-Id: Ib95ec2c50c4bbaefd4ed0ec5af191ccc846c824f
2020-05-04 10:52:34 +02:00
Christian Stenger
626807c94e QmlJS: Fix line number for string literals
When a string value's first line ends with an EOL the
line number for the next line got wrong which in turn
confused the syntax highlighter.

Fixes: QTCREATORBUG-23777
Change-Id: I37eed839a2e63cf470b9bc2ac0596ab8bc8d373c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-04-29 16:09:08 +00:00
Christian Stenger
549b5719f6 QmlJS: Fix lexer handling of escape sequences (again)
The lexer handled escape sequences already, but not fully
correct.
This effectively reverts 63db0f271f and fixes the wrong
offset.

Task-number: QTCREATORBUG-23830
Change-Id: I2cc1e9df5c0218cf9ee80998adce69bbc2eb4dab
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-04-29 13:48:11 +00:00
Philip Van Hoof
a6f69d6142 qmljs: Use Utils::onFinished instead of manual QFutureWatcher
Change-Id: Iad6b958cb87ea5d4edaa270c27fac5ffdc334bba
Fixes: QTCREATORBUG-20243
Task-number: QTCREATORBUG-18533
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-04-27 16:29:46 +00:00
Philip Van Hoof
ba171172e4 qmljs: Make the QMLJsPluginDumper asynchronous to avoid eventloop hangs
Change-Id: I3f6e6acaaf3781d86a0fa5fb100219f92b70f0b5
Fixes: QTCREATORBUG-20243
Task-number: QTCREATORBUG-18533
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2020-04-27 16:28:09 +00:00
Christian Stenger
20b095c6b4 QmlJS: Fix palette support
Fixes false positive warnings of having no members
and allows to auto-complete its members.

Fixes: QTCREATORBUG-23659
Change-Id: I4da43b9d3f005f9c6cc759ec424bf67062beff78
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-04-24 10:34:58 +00:00
Christian Stenger
63db0f271f QmlJS: Fix lexer handling of escape sequences
Escape sequences inside strings need to get handled explicitly
to avoid wrong length and offsets of tokens to avoid follow-up
problems while highlighting or symbol interaction.

Fixes: QTCREATORBUG-23830
Change-Id: I4ab0b166bbab22ef3b7b54071e128416a14e97e1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-04-24 10:34:25 +00:00
Eike Ziller
49626f7ea9 CMake build: Fix devel package issues
Include paths and headers were missing for building a separator
Qt Quick Designer plugin.

Task-number: QTCREATORBUG-23778
Change-Id: Ib6ba96ad42a8b2b36e0ee2f0e3c51c27f3365d37
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-04-23 10:03:37 +00:00
Ulf Hermann
b86dedb3e8 QmlJS: Tolerate extra members in qmltypes
We are going to add more fields to the qmltypes file format. Qt Creator
should not barf on those.

Fixes: QTCREATORBUG-23855
Change-Id: Ibea5a8270d2236d6b9b87ae672a1526107fe8b3b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-04-16 06:26:17 +00:00
Maximilian Goldstein
2392f29a59 qmljs: Do not use app.qmltypes and lib.qmltypes anymore
Task-number: QTBUG-82710
Change-Id: I876ec2b8e2b668a239248511b0fbd58389098de6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-03-27 08:17:07 +00:00
Leena Miettinen
6d484ec120 QML/JS: Fix punctuation of error message
Task-number: QTCREATORBUG-23683
Change-Id: Idb503e00b4f48dfe9ac20d5cc49f6df01153dd20
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-03-11 10:12:14 +00:00
Tim Jenssen
8573623c6e QmlJS: remove unused QtQuick2 check
Change-Id: I7d613ba825a5ce3d4d8302adff9c98f751bc7ab1
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2020-03-06 14:06:54 +00:00
Christian Stenger
a82f707ee5 QmlJS: Fix up compile fix
Amends 33b091bd40.

Change-Id: I26d98bae8a074f7c3515b46994afd5548e2ca82f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-03-04 10:15:16 +00:00
Christian Stenger
33b091bd40 QmlJS: Fix compile
..in general, with tests, and when using a namespaced Qt.
Amends b09a48599e.

Change-Id: I99e275e10df5eed741d021911a360457f0d0d2e7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-04 08:22:12 +00:00
Orgad Shaneh
e4dab6b83e QmlJS: Fix compiler warning and add a missing include
qmljsdiagnosticmessage_p.h: In static member function ‘static QmlJS::Severity::Enum QmlJS::DiagnosticMessage::qtMsgTypeToKind(QtMsgType)’:
qmljsdiagnosticmessage_p.h:72:5: warning: control reaches end of non-void function [-Wreturn-type]
   72 |     }
      |     ^

Change-Id: I2183199bf257453e0af2998b739fae8c90f5c098
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2020-03-03 17:28:52 +00:00
Orgad Shaneh
989eb36012 QmlJS: Fix Qbs/CMake build
Change-Id: I27b4e2024ad1cddafea7ca7be5eb3055d34bf297
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2020-03-03 17:05:17 +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
Thomas Hartmann
bbf5ff61ea QmlJSCheck: Allow animations in ui.qml files
Task-number: QDS-1613
Change-Id: I4beecff16d0b67652abbdb16945614d2497d3921
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2020-02-19 15:47:14 +00:00
Cristian Adam
08202b9110 CMake Build: rename target qmljs to QmlJS
This is in sync with what qmake and qbs project have.

Change-Id: Id82bbd933a8331c3e2032e5068323c183b2a1814
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2020-01-16 17:32:24 +00:00
Christian Stenger
6b492866af QmlJS: Add check for duplicated import
Add a soft check for duplicated Qml/JS imports which
adds a warning when a file contains imports that
duplicate the same URI / version or file path.

Change-Id: Ib9a1f8a90dd3cf469d90e83abc1d748901b1e353
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2019-12-16 06:28:20 +00:00
Christian Stenger
ee77b4fca3 QmlJS: Fix type lookup
Amends 8f682573a8.

Task-number: QTCREATORBUG-15684
Change-Id: I2d35e8f88612d5834519931d00049aa1a99d47c8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-12-10 08:21:06 +00:00
Christian Stenger
8f682573a8 QmlJS: Improve support for multiple imports into same alias
Add extra handling for aliased imports to avoid handling
shadowed imports as unknown which in turn ignored them
and marked their members as unknown types and did not
provide auto completion for their members.

Fixes: QTCREATORBUG-15684
Change-Id: Iee1009cbdfde13ce261854c3239b9b50c434f563
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-12-09 11:37:26 +00:00
Orgad Shaneh
49f6b0146a Merge remote-tracking branch 'origin/4.11'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri
	src/plugins/mcusupport/mcusupportrunconfiguration.cpp
	src/plugins/python/pythonproject.cpp
	src/plugins/qmakeprojectmanager/qmakestep.cpp
	src/plugins/qmlprojectmanager/qmlproject.cpp
	src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp

Change-Id: I22507be28fd80c49c9fee0dff5937a40db176a82
2019-12-07 18:39:54 +02:00
Tim Jenssen
8ebcef7b51 QmlJS: Add "Symbol, Object, Function, RegExp" to global functions
This fixes a false positive error message.

Task-number: QTCREATORBUG-22599
Change-Id: Ibdf9a3a6b1679bd11afa87ca3d5e77fcda773ce0
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-12-06 10:57:12 +00:00
Ulf Hermann
1e587831d1 QmlJS: Scan app.qmltypes and lib.qmltypes for type information
app.qmltypes is being added as a new convention to Qt 5.15. These files
are to be found next to application binaries, and contain the QML types
those application register themselves, in contrast to QML types
registered from plugins loaded via the regular import mechanism.

lib.qmltypes works the same way, in principle, for libraries. This
change only adds it to the possible names for qmltypes files, though.

Change-Id: I1d7c5835c8c3e988d214c5cdb949ca677b48dfc5
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-10-31 09:07:57 +00:00
Ulf Hermann
58c023e7c4 QmlJS: Clean up qmljsmodelmanagerinterface.{h|cpp}
Avoid foreach, fix linter warnings, simplify types, apply coding style.

Change-Id: I7cec65e775ee14ce60e1e57077e917285d58c152
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-10-29 11:45:32 +00:00
Ulf Hermann
3cc6083c27 QmlJS: Use default initializers for LibraryInfo
Change-Id: I1bbad35010af3953ca29a6bb7b79fa0bd5560c88
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2019-10-28 07:47:14 +00:00
Christian Stenger
32ae4d0036 QmlJS: Fix warning regarding forward declaration
Change-Id: I37dad31562565b75db2d92b2f956cf8ba629b5a0
Reviewed-by: hjk <hjk@qt.io>
2019-10-26 12:35:37 +00:00
Christian Stenger
1d2c249be6 Fix build for Qbs and CMake
Amends 6371725dbf.

Change-Id: Idea2196edcfd50341b5dd266e9ea13f35095647e
Reviewed-by: hjk <hjk@qt.io>
2019-10-23 11:08:27 +00:00
Ulf Hermann
6371725dbf QmlJS: Clean up ViewerContext
The special ctor wasn't used anywhere, the default ctor can be replaced
by inline initialization, maybeAddPath is only meaningful in the model
manager and the language compatibility check should definitely not
pretend to be a general rule either.

Change-Id: I11cf25fe1c696550d33b56ce57316100321d564b
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-10-23 10:14:47 +00:00
Ulf Hermann
3b65c0a5d5 QmlJS: Clean up qmljslink.{h|cpp}
Fix linter warnings, apply coding style, avoid foreach, drop dead code.

Change-Id: Ib98488725262c1bd3a04de0db0397a9129e21901
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-10-23 10:14:38 +00:00
Thomas Hartmann
3ee870a3d8 QmlJS: Fix regression caused by parser update
We have to keep the semicolonToken into account.

Change-Id: Ie599d141d21f09f1d0036c0382f6a3098fde6ca5
Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-10-21 07:21:08 +00:00
Ulf Hermann
3d21c7fdc3 Retain ".pragma library" when reformatting JavaScript files
For ".pragma library" there is a special flag in QmlJS::Directives.
We just need to actually set the flag and query it when re-emitting the
code.

Change-Id: Ia3455fda18aba3219b02ecf092bb28987a6ccef5
Fixes: QTCREATORBUG-22326
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2019-10-10 14:05:18 +00:00
Ulf Hermann
4d7c644268 Fix parsing of QML version tokens in the presence of "as Foo"
The previous code would omit the minor version, leading to a test
failure.

Change-Id: I3dccee5252a54806f8e1e5bf5c49eff149d9b936
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2019-10-10 11:34:52 +00:00
Ulf Hermann
58d35f8a64 QmlJS: Update QML parser using the one from qtdeclarative 5.15
We need to do this because the new "required" keyword should be
recognized by Qt Creator.

This is not a verbatim copy of the QML parser from qtdeclarative. A few
data structures have changed that would require large scale changes in
otherwise unrelated parts of the code. For example, all Visitors need to
handle recursion depth errors now and the DiagnosticMessage only has
line and column now, no longer begin and legth.

Change-Id: Iea5b04e27b07e0cba55d64b844315af9828acbf7
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-10-07 07:33:58 +00:00
Ulf Hermann
b5b1367b0b Accept arrays as enum descriptions in qmltypes files
We don't use the values at all and they are hard to determine
statically. Qt >= 5.15 will generated arrays instead of objects.

Change-Id: I3b3bbd427c49e649ca3f9cef51c89b32e830eb66
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2019-09-30 08:24:30 +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
Thomas Hartmann
4bf1474aa0 QmlDesigner: Allow transformations in Qt Quick Designer
They are passively supported and we plan better support in the future.

Change-Id: I22520335ae3dba5804ec4c8902624b4afe4254a3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-09-05 12:47:03 +00:00
Eike Ziller
8d85a7c2bc QmlJS: Fix compiler warnings
Change-Id: I94fccd913a4a06fb55acee3df974859f9a163b4f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-09-04 10:11:48 +00:00
Thomas DeRensis
edad44f213 Parse the types registered with qmlRegisterUncreatableMetaObject()
Fixes: QTCREATORBUG-20569
Change-Id: I65fe8843b09aa127f0c564942b5b4e10a51342ba
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2019-08-22 11:34:12 +00:00
hjk
2e14df7561 Some clang-tidy -use-modernize-nullptr
Change-Id: I1bed5e85a5b7948d08502a72a10f80baa075c204
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
2019-08-01 13:20:26 +00:00
hjk
e3b1106afa Compile fix with recent Qt dev
The reasoning in 1b4766e26c did not take into account that the scope
of QT_NO_JAVA_STYLE_ITERATORS may change over time, as done with
f70905448f6 in Qt base.

Change-Id: Ib1966ff26c4d36d5f62e149d6b45baa4aecf825d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-07-29 08:54:18 +00:00
hjk
7ab6783e24 Standardize on int for line and column values
Recently tons of warnings show up for presumably "problematic"
singned <-> unsigned and size conversions.

The Qt side uses 'int', and that's the biggest 'integration surface'
for us, so instead of establishing some internal boundary between
signed and unsigned areas, push that boundary out of creator core code,
and use 'int' everywhere.

Because it reduces friction further, also do it in libcplusplus.

Change-Id: I84f3b79852c8029713e7ea6f133ffb9ef7030a70
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-07-26 09:23:48 +00:00