Commit Graph

140 Commits

Author SHA1 Message Date
Christian Kamm
82cbd0a974 QmlJS: Support .import directives in js files.
* Allow .import...
* Fix parsing of JS files when using Lexer::scanDirectives()
* Clean up ImportInfo construction.
* Rename ImportInfo::id to ImportInfo::as.

Change-Id: I888da248f06dc6184db99aa74c3b50d7f2f5e491
Reviewed-on: http://codereview.qt-project.org/5625
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
2011-09-28 08:52:56 +02:00
Christian Kamm
c7d8462bf8 QmlJS: Fix threading issue in QmlObjectValue.
Still need to get rid of the lock in ValueOwner::registerValue.

Change-Id: If9bbc548de54edf52805906aaaf730f5c66573dd
Reviewed-on: http://codereview.qt-project.org/5542
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-09-27 08:30:28 +02:00
Christian Kamm
fdd0a15ef4 QmlJS: Separate metaObjectRevision from minor version number.
They need not to be identical. Additionally:
* Rename ImportInfo::name to path, because that's what it does.
* Add ImportInfo::name, for getting the uri with the names
  separated by dots.
* Allow for exportMetaObjectRevisions in qmltypes files.
* Allow for exports with an empty type name, as generated by
  qmlRegisterRevision. They are used for associating meta object
  revisions with non-exported types.
* Rewrite the Qt 4.7 import to QtQuick 1.0 at an early stage. In
  preparation for the Qt 5 type information update, where Qt 4.7
  is gone.

Change-Id: Ia287193623d9530a56b9eb8d2481d50aabd94c3e
Reviewed-on: http://codereview.qt-project.org/5309
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-09-26 12:04:16 +02:00
Christian Kamm
4fdeeb3039 QmlJS: Fix enum completion with 'as' imports.
Change-Id: Ifc229c23c14a6395c9d3e5f7ec76b9b04678787d
Reviewed-on: http://codereview.qt-project.org/5134
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2011-09-19 13:52:44 +02:00
Christian Kamm
6c925cf0fc QmlJS: Rework exported C++ type registry.
The problem was that if you exported
A 1.0, A 1.1 and B 1.0 where A is the prototype of B
the code model had not enough information to know that, depending
on the import, B 1.0's prototype should be A 1.1 or A 1.0.

To solve this problem QmlObjectValues now store the import's version
as well as the local component version. In the example above B 1.0
would have import version 1.1 if the 1.1 module was imported and thus
be able to choose the right prototype.

Change-Id: I7ef33f12ca5a528c62b2a8240f4b5720b0ebd4c3
Reviewed-on: http://codereview.qt-project.org/5129
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2011-09-19 13:52:26 +02:00
Christian Kamm
4083880073 QmlJS: When completing enums, add Item.Foo instead of "Foo".
Change-Id: I9a74bd726d9691ca93477916159a80c04c35f52d
Reviewed-on: http://codereview.qt-project.org/4987
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2011-09-15 13:49:13 +02:00
Christian Kamm
5b1a24ab95 QmlJS: Improve completion of signals.
* Change from Reference to FunctionValue: There was no reason for them
  being References as the argument types never need lookup.
* Enumerate in global completion: When you define 'signal foo(int a)'
  you now get completion for 'foo' and will get the function argument
  hint popup.

Change-Id: Ic348db477a34ba468dfdb690499a9cd8fd605cd2
Reviewed-on: http://codereview.qt-project.org/4774
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2011-09-14 13:00:29 +02:00
Christian Kamm
4b2f42cf87 QmlJS: Adjust existing code for updated QML parser.
Change-Id: I153723eeb9973be025daf47e317f7b9d076a3c72
Reviewed-on: http://codereview.qt-project.org/4733
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2011-09-14 11:48:22 +02:00
Christian Kamm
ece400cfb6 QmlJS: Enable 'follow symbol' for local variables.
Task-number: QTCREATORBUG-6094
Change-Id: Icf286bc412b48dbd1cb38c47ad7b91040b5aae0f
Reviewed-on: http://codereview.qt-project.org/4864
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2011-09-14 11:13:21 +02:00
Christian Kamm
7b2110de7e QmlJS: Fix reference lookup cycles.
Since several reference lookups involve Evaluate which may cause
further reference lookups, we need to be able to pass the existing
ReferenceContext to avoid cycles.

Change-Id: I2f1eeaad4d6b6ff094413d51077b03c985f6fab4
Reviewed-on: http://codereview.qt-project.org/4653
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-09-12 14:47:35 +02:00
Christian Kamm
312d43f215 QmlJS: Fix lookup for enums.
* Also look for enums in prototypes.
* Report back which QmlObjectValue had the enum.
* Fix a bug where enum lookup was always skipped.

Change-Id: I9c9fd8f8cf9bd8cc5f1bb5688fef5786267cd794
Reviewed-on: http://codereview.qt.nokia.com/4192
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2011-09-05 14:56:37 +02:00
Christian Kamm
197c60e928 QmlJS: Add XMLHttpRequest, DB API and JSON completion.
Change-Id: I30773e8879086c1f85d331fabf9380e217b32dd7
Reviewed-on: http://codereview.qt.nokia.com/2745
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-08-09 08:36:35 +02:00
Christian Kamm
0e54183d4d QmlJS: Remove Interpreter namespace.
The distinction between QmlJS and QmlJS::Interpreter has always been
weak and the extra namespace just added an unnecessary complication.

Change-Id: I4db8ef4bd91b5f6bf610a9d23fdbf55bd60250fc
Reviewed-on: http://codereview.qt.nokia.com/2743
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-08-08 13:21:28 +02:00
Christian Kamm
9dc9674c6b QmlJS: Share Context.
Previously Context was not entirely thread safe and had to be
copied locally. Now it is thread safe and its lifetime
managed by QSharedPointer.

The non-safe parts were moved into ScopeChain in a previous commit.

Change-Id: I851a93de85cbd6391dbea0fe33b011e2e093addb
Reviewed-on: http://codereview.qt.nokia.com/1695
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-08-08 12:05:19 +02:00
Christian Kamm
f87dc61986 QmlJS: Split Context and ScopeChain.
Context is created by Link and has information about imports
for all Documents in a Snapshot.

ScopeChain represents how lookup is done at a specific place in
a Document.

Change-Id: I874102d57bbaf1a497fa3f27633bed6ee75dcf10
Reviewed-on: http://codereview.qt.nokia.com/1694
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-08-08 12:05:03 +02:00
Fawzi Mohamed
0c0ffab1bb avoid allocating QmlEnumValues each time
Change-Id: I61f39f5bafcb2c84e91f5bca4b52010a08ed9f37
Reviewed-on: http://codereview.qt.nokia.com/1592
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
2011-07-13 14:59:52 +02:00
Christian Kamm
4285b48455 QmlJS: Dump builtins per Qt version.
Change-Id: I7b5179c4b33c24e83baf0536d158dd48d277637f
Reviewed-on: http://codereview.qt.nokia.com/1305
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-07-11 11:28:38 +02:00
Christian Kamm
eec591ff1c QmlJS: Make 'length' property available on all FunctionValues.
Change-Id: I62bb8f41177521db1f3213d6bd804d8e4852560d
Reviewed-on: http://codereview.qt.nokia.com/1044
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-07-05 11:52:38 +02:00
Christian Kamm
d72ee7c7da QmlJS: Remove deprecated enum functions in QmlObjectValue.
Change-Id: I30c1636f4946f465e5924493e561310f506df3d7
Reviewed-on: http://codereview.qt.nokia.com/1043
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-07-05 11:52:28 +02:00
Christian Kamm
36ed6bce1d QmlJS: Move Context to its own file.
Change-Id: I91331b7039e27e2f57cc19b985c8ed86c955ec9e
Reviewed-on: http://codereview.qt.nokia.com/1042
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-07-05 11:52:20 +02:00
Christian Kamm
9ea0380a4d QmlJS: Enforce Context always being linked.
The default way of creating a Context is through Link.

Change-Id: Ia81f7ce90ba2b33d02eed432a61be836d404bedd
Reviewed-on: http://codereview.qt.nokia.com/1041
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-07-05 11:52:09 +02:00
Christian Kamm
f691d3824a QmlJS: Remove unused methods from Context
Change-Id: I1e4a013ee11f9747d6936c15bf81e971ca4e4f23
Reviewed-on: http://codereview.qt.nokia.com/1040
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-07-05 08:46:39 +02:00
Christian Kamm
8b778b266b QmlJS: Rename Interpreter::Engine -> ValueOwner
Also move to a separate file.

Change-Id: I05910e8cf04a533b5d09a1c16e612e3b99b1d606
Reviewed-on: http://codereview.qt.nokia.com/1039
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-07-05 08:44:16 +02:00
Christian Kamm
fc88340c6c QmlJS: Setup QmlEnumValues even if enum is non-local.
Change-Id: Ib7a3621c14b6dfbdf36c75abac282c08f47e55ca
Reviewed-on: http://codereview.qt.nokia.com/559
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2011-06-22 12:07:06 +02:00
Fawzi Mohamed
752ea43111 Qmljs: find usages for types and packages
detects and finds usages of types and packages in qml and javascript

Change-Id: Id13f48e435258ff10ab3e6f49049f7bb602a900f
Reviewed-on: http://codereview.qt.nokia.com/277
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Christian Kamm <christian.d.kamm@nokia.com>
2011-06-06 14:08:15 +02:00
Christian Kamm
83072da8b0 QmlJS: Fix potential linking problem.
Don't use plugin from libs/qmljs.

Change-Id: Ia345c567cd1f244ab2191017810ef3eeb91fe0e4
Reviewed-on: http://codereview.qt.nokia.com/213
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
2011-05-30 15:19:06 +02:00
Christian Kamm
f0a4e7e225 QmlJS: Output qmltypes parse warnings to General messages pane.
Change-Id: I8ca100ef141082c7606bb98f8a2f81502b14e1af
Reviewed-on: http://codereview.qt.nokia.com/204
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
2011-05-30 11:32:23 +02:00
Christian Kamm
a7f4e5fab5 QmlJS: Separate imported types and imported JS scopes.
Task-number: QTCREATORBUG-4981
Change-Id: I06d3e428ca4928296a3d5977aeff29fc3217c37c
Reviewed-on: http://codereview.qt.nokia.com/175
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-05-27 11:48:53 +02:00
Christian Kamm
d67b7d17dc QmlJS: Refactor ObjectValue members.
* property -> lookupMember
* setProperty -> setMember
* removeProperty -> removeMember

Change-Id: I638479ee2b90b684283e714630bdcab237f6b3f2
Done-with: Fawzi Mohamed
Reviewed-on: http://codereview.qt.nokia.com/77
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@nokia.com>
2011-05-24 11:55:03 +02:00
Christian Kamm
0bf18d008b QmlJS: Find prototype resolution errors.
To avoid lots of follow-up errors where the root cause is a failed
prototype resolution or a prototype cycle.

Task-number: QTCREATORBUG-4952
Change-Id: Id474c8c6c152c993aca8c6c421b6d88eb1481676
Reviewed-on: http://codereview.qt.nokia.com/36
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
2011-05-20 13:33:18 +02:00
Christian Kamm
cf15e14e5e QmlJS: Add tooltips to imports.
Task-number: QTCREATORBUG-4814
2011-05-12 15:29:41 +02:00
Tobias Hunger
aa2acec14c Fix/add copyright headers
Change-Id: I8b73d583be1ee7183f4074bce49d5390e38631a2
2011-05-06 15:17:05 +02:00
Christian Kamm
02b7eacf4b QmlJS: Fix type detection for alias properties.
Task-number: QTCREATORBUG-2306
2011-05-04 11:14:35 +02:00
Christian Kamm
e21311132b QmlJS: Fix library-by-path imports.
Fixes the problem 5426c3ac2c and
7b25f438c6 worked around.

Reviewed-by: Erik Verbruggen
2011-04-21 11:16:14 +02:00
hjk
8397663964 Update license. 2011-04-13 11:49:28 +02:00
Kai Koehne
3e07024e10 QmlJS: Don't warn user about imports if static info is available
Don't underline the import if a qmldump fails,
but the typeinfo is available via a .qmltypes file. That should allow
users to 'fix' qmldump issues by shipping a .qmltypes file.

Reviewed-by: Erik Verbruggen
2011-04-12 11:27:17 +02:00
Christian Kamm
b980a9b964 QmlJS: Fix implicit "." import when . has a QML module.
Reviewed-by: Erik Verbruggen
2011-03-10 15:03:36 +01:00
Christian Kamm
aeb8c352ee QmlJS: Try to implicitly import libraries in the same directory.
In QML, the current directory that holds a QML file is imported
implicitly. If it contains a qmldir file, the library is imported.

Since there is no explicit import statement, Creator can't know the URI
of this library. However, if type information is available for it
already - either through a previous dump or a qmltypes file - we can
guess the URI by looking at the contained exports.

Task-number: QTCREATORBUG-3768
2011-02-25 16:23:12 +01:00
Christian Kamm
1d4cd9b7f2 QmlJS: Remove the strict separation of types and attached types.
The problem was that several lookup calls suddenly failed because
the actual QML types were no longer in the default scope chain. However,
the QML documentation says the type names are in the scope.

Also, 'MyComponent.' in a JS-expression context only showed the attached
properties of MyComponent and missed the enums.

With this change completion now may offers too many options, but that's
better than missing some.

This reverts parts of 490f2797f6

Reviewed-by: Leandro Melo
2011-02-21 15:05:04 +01:00
Christian Kamm
490f2797f6 QmlJS: Completion for attached properties. 2011-02-10 17:04:22 +01:00
Christian Kamm
187ae1e94a QmlJS: Rework FakeMetaObjects to no longer contain pointers.
Having a duplicate prototype chain - once in FakeMetaObjects and once
in QmlObjectValues was unnecessary. Now FMOs don't contain references
which may allow other simplifications.
2011-02-10 17:04:22 +01:00
Christian Kamm
55520a3804 QmlJS: Simplify loading types defined in C++. 2011-02-09 13:40:09 +01:00
Christian Kamm
4fc2032e10 QmlJS: Put types with cpp names into a separate package.
In preparation of relocatable plugin types.
2011-02-09 10:42:49 +01:00
Christian Kamm
2ec429e8ce QmlJS: Switch to new format for QML meta data. 2011-02-09 10:42:49 +01:00
Christian Kamm
dd1de1b82f qmldump: Make Creator able to read qmldump's new output.
Task-number: QTCREATORBUG-3048
2011-02-09 10:42:48 +01:00
hjk
57eae3191e s:// end of namespace :// namespace :g for consistency
We use the latter style everywhere else to signify the end of a namespace block.
2011-02-04 12:45:32 +01:00
con
d1023c7614 It's 2011 now.
Reviewed-by: hjk
2011-01-12 09:46:24 +01:00
Christian Kamm
d3c1dd6a09 C++/Qml: Don't allow exported types to override builtins.
There was trouble when a plugin qmlRegisterType'd something like 'Item'
into the global default module.

Reviewed-by: Roberto Raggi
2011-01-10 14:40:40 +01:00
Christian Kamm
283a3d32cd Qml/C++: Fix performance problem with type extraction.
By moving the offending code into a background thread.

Reviewed-by: Erik Verbruggen
2011-01-06 15:02:06 +01:00
Christian Kamm
ab642bc820 QmlJS: Add refcounting to FakeMetaObjects.
Previously they were leaked when a qmldump or the C++ exported QML
type list updated.

Just deleting the previous FakeMetaObjects is not an option, as they
might still be used in a QmlObjectValue owned by an Engine.

Reviewed-by: Erik Verbruggen
2011-01-06 15:01:09 +01:00