From 28d2b1616541eee4ab0e06e89c7e8cab04bd9961 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Fri, 24 Apr 2015 14:32:43 +0300 Subject: Allow plugins to insert custom imports. 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 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, ""); 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); } Change-Id: I395c273c7b15a9e4ed5a89a81d70ff92db2b7c0c Reviewed-by: Marco Benelli Reviewed-by: Kai Koehne --- tests/auto/qml/codemodel/importscheck/importscheck.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/qml/codemodel/importscheck/importscheck.pro b/tests/auto/qml/codemodel/importscheck/importscheck.pro index b36550a10a..2821fb95ef 100644 --- a/tests/auto/qml/codemodel/importscheck/importscheck.pro +++ b/tests/auto/qml/codemodel/importscheck/importscheck.pro @@ -1,4 +1,4 @@ -QTC_LIB_DEPENDS += cplusplus utils +QTC_LIB_DEPENDS += cplusplus utils extensionsystem include(../../../qttest.pri) include($$IDE_SOURCE_TREE/src/rpath.pri) DEFINES += QMLJS_BUILD_DIR -- cgit v1.2.1