This patch allows a plugin to insert custom imports. These imports are
used by QtC for syntax highlighting and code completion. This way a
plugin can register types and objects that are available only at
runtime.
This is an example of an imports function implementation:
QList<Import> MyPlugin::imports(ValueOwner *valueOwner, const Document
*context) const
{
// context is needed to know from which project is the opened document
// in this example we don't care about multiple projects
Import import;
import.object = new QmlJS::ObjectValue(valueOwner, "<defaults>");
import.valid = true;
const ComponentVersion version(1, 0);
import.info = ImportInfo::moduleImport("MyPlugin", version,
QString());
auto myType = valueOwner->newObject(nullptr)
myType->setMember("myProperty", valueOwner->valueOwner->intValue());
// add more properties & methods/signals to myType
import.object->setMember("MyType", myType);
// in this example we return only one, but you care return more than
one
return QList<Import>(import);
}
Change-Id: I395c273c7b15a9e4ed5a89a81d70ff92db2b7c0c
Reviewed-by: Marco Benelli <marco.benelli@theqtcompany.com>
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Method that returns list of all project infos where this file belongs (similar to methods in cpp module).
Change-Id: I94eb86ffa5bdbee8d794377a03160418b7340662
Reviewed-by: Marco Benelli <marco.benelli@theqtcompany.com>
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
The class was only used for the Apply on Save functionality in the
QML Debugger, which got nuked in 3bf81efbe7.
Change-Id: I1842cc07d61fe84f8da23210ebac04dd4d567fce
Reviewed-by: Marco Benelli <marco.benelli@theqtcompany.com>
Reviewed-by: hjk <hjk@theqtcompany.com>
.. of builtIn qml and cpp code over "Inspect API For Element Under
Cursor" action.
Change-Id: I70d5bec2933b682295c5242248a2b0f95dba4e76
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Must at some point in time have been changed to use QXmlStream*
Change-Id: I8ed535f51246a0917454352d459a0f24c34f4a62
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
Mostly done using the following ruby script:
Dir.glob('**/*.cpp').each { |file|
next if file =~ %r{src/shared/qbs|/qmljs/}
s = File.read(file)
s.scan(/^using namespace (.*);$/) {
ns = $1
t = s.gsub(/^(.*)\b#{ns}::((?!Const)[A-Z])/) { |m|
before = $1
char = $2
if before =~ /"|\/\/|\\|using|SIGNAL|SLOT|Q_/
m
else
before + char
end
}
if t != s
puts file
File.open(file, 'w').write(t)
end
}
}
Change-Id: I492792bb9e5655c55795e938031efc557c9a462f
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
looking up types in prototypes leads to a recursive blowup when resolving
the prototype of a type returns (for incorrect code) the type itself.
Change-Id: Iebcbdda7554e5fe01f0ef323ccc2079888c7ef4e
Task-number: QTCREATORBUG-13906
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This feature is needed to enable code-completion in a dynamically loaded
qml file e.g. let's say that Main.qml is our application entry point and
in it will load *dynamically* another qml file: MyView.qml. At runtime
MyView.qml will see all Main.qml ids and properties. The problem is that
QtCreator doesn't know that MyView.qml will be loaded dynamically by
Main.qml and it can't offer code-completion of Main.qml ids and
properties. This patch allows the user to inform QtCreator that
MyView.qml will be loaded by Main.qml using a simple annotation in
MyView.qml: // @scope Main.qml
It also works recursively e.g. if MyView.qml loads dynamically another
qml file (MyView1.qml) and in MyView1.qml we can add "// @socpe
MyView.qml" annotation. This way QtCreator will offer code-completion of
MyView.qml and Main.qml ids and properties when coding on MyView1.qml.
Change-Id: If50aee81cae40c8b95dbb4c0653e5a91f7a4cff4
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
m_fileToPath was not always updated correctly which lead
projectInfoForPath to return a wrong/invalid project info,
messing up the paths used by the code model.
Change-Id: If5e144f1ef2c7353b9077deb1b9c9aa9d1708651
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
Private plugin are considered those whose name ends with "private".
Avoid being misleading, i.e. do not declare the plugin dump as successful.
Change-Id: Id181d3a09dc9c4895f6566e22ad670435bd5a7f8
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
builtins were always using qtimportPath, which is now being removed,
so prefer qtQmlPath.
Change-Id: I99d9214c2188507859f27b729c027aaf77eb579e
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
qmltypes files were stored in the snapshot during scan, this is wrong
and bloats the memory usage.
Task-number: QTCREATORBUG-13369
Change-Id: Ie8c3970ad7a8d732230f3dc73a9ba65ab62ea4e9
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
If the qmljsmodel has no background task, then isIdle returns true
Change-Id: I31420343c560c5ed118f371f7be347eadb6622f4
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
The respective items are available without it.
Change-Id: Idc840cf08e7bec84f561c096afe8de25b1fb8468
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Edit the new messages and add them to the Qt Creator Manual.
Change-Id: Ib494fd20861473ea824dd0d4260cad621c4081a4
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
We properly distinguish between warnings in the Qt Quick Designer and
error in a .ui.qml file.
The warnings are a subset of the errors anyway.
Change-Id: Ib3b21a845436381df10863b464c975b0b39fc063
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
Enable access to the private Document
instance in the same way its done
already in the ASTObjectValue class
by adding a const getter.
Change-Id: I0581e527bb766fc72682f2e38d0d8d52d4452deb
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>