QmlJS: Allow setting import paths in Qt4Projects using QML_IMPORT_PATH.

Introduced new Creator-specific qmake variable QML_IMPORT_PATH that
lists the import paths required by the QmlJS engine.

Done-with: Alessandro Portale
This commit is contained in:
Christian Kamm
2010-09-21 14:28:55 +02:00
parent 59c58a0c27
commit 427f775489
6 changed files with 41 additions and 5 deletions

View File

@@ -18,6 +18,7 @@ Alternatively, this plugin may be used under the terms of the GNU Lesser General
<dependency name="ProjectExplorer" version="2.0.90"/> <dependency name="ProjectExplorer" version="2.0.90"/>
<dependency name="CppTools" version="2.0.90"/> <dependency name="CppTools" version="2.0.90"/>
<dependency name="CppEditor" version="2.0.90"/> <dependency name="CppEditor" version="2.0.90"/>
<dependency name="QmlJSEditor" version="2.0.90"/>
<dependency name="Designer" version="2.0.90"/> <dependency name="Designer" version="2.0.90"/>
<dependency name="Debugger" version="2.0.90"/> <dependency name="Debugger" version="2.0.90"/>
</dependencyList> </dependencyList>

View File

@@ -1591,6 +1591,8 @@ void Qt4ProFileNode::applyEvaluate(bool parseResult, bool async)
0); 0);
newVarValues[LibDirectoriesVar] = libDirectories(m_readerExact); newVarValues[LibDirectoriesVar] = libDirectories(m_readerExact);
newVarValues[ConfigVar] = m_readerExact->values(QLatin1String("CONFIG")); newVarValues[ConfigVar] = m_readerExact->values(QLatin1String("CONFIG"));
newVarValues[QmlImportPathVar] = m_readerExact->absolutePathValues(
QLatin1String("QML_IMPORT_PATH"), m_projectDir);
if (m_varValues != newVarValues) { if (m_varValues != newVarValues) {
m_varValues = newVarValues; m_varValues = newVarValues;

View File

@@ -94,7 +94,8 @@ enum Qt4Variable {
PkgConfigVar, PkgConfigVar,
PrecompiledHeaderVar, PrecompiledHeaderVar,
LibDirectoriesVar, LibDirectoriesVar,
ConfigVar ConfigVar,
QmlImportPathVar
}; };
class Qt4PriFileNode; class Qt4PriFileNode;

View File

@@ -47,6 +47,7 @@
#include <coreplugin/progressmanager/progressmanager.h> #include <coreplugin/progressmanager/progressmanager.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <cpptools/cppmodelmanagerinterface.h> #include <cpptools/cppmodelmanagerinterface.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <projectexplorer/buildenvironmentwidget.h> #include <projectexplorer/buildenvironmentwidget.h>
#include <projectexplorer/customexecutablerunconfiguration.h> #include <projectexplorer/customexecutablerunconfiguration.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -318,7 +319,7 @@ bool Qt4Project::fromMap(const QVariantMap &map)
update(); update();
updateFileList(); updateFileList();
// This might be incorrect, need a full update // This might be incorrect, need a full update
updateCodeModel(); updateCodeModels();
createApplicationProjects(); createApplicationProjects();
@@ -395,7 +396,7 @@ bool Qt4Project::equalFileList(const QStringList &a, const QStringList &b)
return (ait == aend && bit == bend); return (ait == aend && bit == bend);
} }
void Qt4Project::updateCodeModel() void Qt4Project::updateCodeModels()
{ {
if (debug) if (debug)
qDebug()<<"Qt4Project::updateCodeModel()"; qDebug()<<"Qt4Project::updateCodeModel()";
@@ -403,6 +404,12 @@ void Qt4Project::updateCodeModel()
if (!activeTarget() || !activeTarget()->activeBuildConfiguration()) if (!activeTarget() || !activeTarget()->activeBuildConfiguration())
return; return;
updateCppCodeModel();
updateQmlJSCodeModel();
}
void Qt4Project::updateCppCodeModel()
{
Qt4BuildConfiguration *activeBC = activeTarget()->activeBuildConfiguration(); Qt4BuildConfiguration *activeBC = activeTarget()->activeBuildConfiguration();
CppTools::CppModelManagerInterface *modelmanager = CppTools::CppModelManagerInterface *modelmanager =
@@ -575,6 +582,28 @@ void Qt4Project::updateCodeModel()
} }
} }
void Qt4Project::updateQmlJSCodeModel()
{
QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance();
if (!modelManager)
return;
QmlJS::ModelManagerInterface::ProjectInfo projectInfo = modelManager->projectInfo(this);
// Not essential since the QmlJS engine parses required files on demand.
//projectInfo.sourceFiles = ...
FindQt4ProFiles findQt4ProFiles;
QList<Qt4ProFileNode *> proFiles = findQt4ProFiles(rootProjectNode());
foreach (Qt4ProFileNode *node, proFiles) {
projectInfo.importPaths.append(node->variableValue(QmlImportPathVar));
}
projectInfo.importPaths.removeDuplicates();
modelManager->updateProjectInfo(projectInfo);
}
void Qt4Project::qtVersionsChanged() void Qt4Project::qtVersionsChanged()
{ {
setSupportedTargetIds(QtVersionManager::instance()->supportedTargetIds()); setSupportedTargetIds(QtVersionManager::instance()->supportedTargetIds());
@@ -751,7 +780,7 @@ void Qt4Project::decrementPendingEvaluateFutures()
} else if (m_asyncUpdateState != ShuttingDown){ } else if (m_asyncUpdateState != ShuttingDown){
// After beeing done, we need to call: // After beeing done, we need to call:
updateFileList(); updateFileList();
updateCodeModel(); updateCodeModels();
if (debug) if (debug)
qDebug()<<" Setting state to Base"; qDebug()<<" Setting state to Base";
m_asyncUpdateState = Base; m_asyncUpdateState = Base;

View File

@@ -217,7 +217,9 @@ private:
void scheduleAsyncUpdate(); void scheduleAsyncUpdate();
void createApplicationProjects(); void createApplicationProjects();
void updateCodeModel(); void updateCodeModels();
void updateCppCodeModel();
void updateQmlJSCodeModel();
void updateFileList(); void updateFileList();
static void collectLeafProFiles(QList<Internal::Qt4ProFileNode *> &list, Internal::Qt4ProFileNode *node); static void collectLeafProFiles(QList<Internal::Qt4ProFileNode *> &list, Internal::Qt4ProFileNode *node);

View File

@@ -1,6 +1,7 @@
include(../../plugins/projectexplorer/projectexplorer.pri) include(../../plugins/projectexplorer/projectexplorer.pri)
include(../../plugins/cpptools/cpptools.pri) include(../../plugins/cpptools/cpptools.pri)
include(../../plugins/cppeditor/cppeditor.pri) include(../../plugins/cppeditor/cppeditor.pri)
include(../../plugins/qmljseditor/qmljseditor.pri)
include(../../plugins/designer/designer.pri) include(../../plugins/designer/designer.pri)
include(../../plugins/debugger/debugger.pri) include(../../plugins/debugger/debugger.pri)
include(../../libs/symbianutils/symbianutils.pri) include(../../libs/symbianutils/symbianutils.pri)