forked from qt-creator/qt-creator
QmlDesigner.MetaInfo: fix for importDirectoryPath()
This fixes importDirectoryPath() for library imports. For libraray imports we have to iterate over all importPaths provided by the modelManager. Change-Id: I68d4f0b7600e3b5d3f1c686ecb6887584cdd2031 Reviewed-by: Marco Bubke <marco.bubke@digia.com>
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
#include <rewriterview.h>
|
||||
#include <propertyparser.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QSharedData>
|
||||
#include <QDebug>
|
||||
#include <QIcon>
|
||||
@@ -45,6 +46,7 @@
|
||||
#include <qmljs/qmljsbind.h>
|
||||
#include <qmljs/qmljsscopechain.h>
|
||||
#include <qmljs/parser/qmljsast_p.h>
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
#include <languageutils/fakemetaobject.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -869,11 +871,24 @@ QString NodeMetaInfoPrivate::componentFileName() const
|
||||
|
||||
QString NodeMetaInfoPrivate::importDirectoryPath() const
|
||||
{
|
||||
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
|
||||
|
||||
if (isValid()) {
|
||||
const Imports *imports = context()->imports(document());
|
||||
ImportInfo importInfo = imports->info(qualfiedTypeName(), context().data());
|
||||
ImportInfo importInfo = imports->info(lookupNameComponent().last(), context().data());
|
||||
|
||||
return importInfo.path();
|
||||
if (importInfo.type() == ImportInfo::DirectoryImport) {
|
||||
return importInfo.path();
|
||||
} else if (importInfo.type() == ImportInfo::LibraryImport) {
|
||||
if (modelManager) {
|
||||
foreach (const QString &importPath, modelManager->importPaths()) {
|
||||
const QString targetPath = QDir(importPath).filePath(importInfo.path());
|
||||
if (QDir(targetPath).exists()) {
|
||||
return targetPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user