forked from qt-creator/qt-creator
qmljs: adding qrc support
Qmljs now keeps a cache of parsed qrc files, and can resolve "qrc:" links. This breaks the assumption that the name that the qml files has on the filesystem is the one that qml sees, and that contents of directories can be found just looking at file whose path starts with the directory path. Currently the first file is used when multiple qrc files contain the same path, but support for strict and weak path resolving is already there. At the moment only qrc files for projects that call updateQmljsCodeModel are updated. ChangeLog: QmljsSupport: Imports using qrc links are resolved. Task-number: QTCREATORBUG-8953 Change-Id: I695fac2692af2417d49c192c580a1c2e7b4873f4 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
#include <qmljs/parser/qmljsast_p.h>
|
||||
#include <qmljs/parser/qmljsastfwd_p.h>
|
||||
#include <qmljs/qmljsutils.h>
|
||||
#include <qmljs/qmljsqrcparser.h>
|
||||
#include <texteditor/itexteditor.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
#include <texteditor/helpitem.h>
|
||||
@@ -134,9 +135,15 @@ static inline QString getModuleName(const ScopeChain &scopeChain, const Document
|
||||
} else if (importInfo.isValid() && importInfo.type() == ImportInfo::DirectoryImport) {
|
||||
const QString path = importInfo.path();
|
||||
const QDir dir(qmlDocument->path());
|
||||
// should probably try to make it relatve to some import path, not to the document path
|
||||
QString relativeDir = dir.relativeFilePath(path);
|
||||
const QString name = relativeDir.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||
return name;
|
||||
} else if (importInfo.isValid() && importInfo.type() == ImportInfo::QrcDirectoryImport) {
|
||||
QString path = QrcParser::normalizedQrcDirectoryPath(importInfo.path());
|
||||
path = path.mid(1, path.size() - ((path.size() > 1) ? 2 : 1));
|
||||
const QString name = path.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||
return name;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
|
||||
Reference in New Issue
Block a user