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:
Fawzi Mohamed
2013-05-21 11:35:15 +02:00
parent 69a9dc3f1c
commit 5a4cdc11cb
23 changed files with 1109 additions and 19 deletions

View File

@@ -33,6 +33,7 @@
#include "qmljstools_global.h"
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/qmljsqrcparser.h>
#include <cplusplus/CppDocument.h>
@@ -41,6 +42,7 @@
#include <QMutex>
QT_FORWARD_DECLARE_CLASS(QTimer)
QT_FORWARD_DECLARE_CLASS(QLocale)
namespace Core {
class MimeType;
@@ -50,6 +52,10 @@ namespace CPlusPlus {
class CppModelManagerInterface;
}
namespace QmlJS {
class QrcParser;
}
namespace QmlJSTools {
QMLJSTOOLS_EXPORT QmlJS::Document::Language languageOfFile(const QString &fileName);
@@ -77,6 +83,14 @@ public:
bool emitDocumentOnDiskChanged);
virtual void fileChangedOnDisk(const QString &path);
virtual void removeFiles(const QStringList &files);
virtual QStringList filesAtQrcPath(const QString &path, const QLocale *locale = 0,
ProjectExplorer::Project *project = 0,
QrcResourceSelector resources = AllQrcResources);
virtual QMap<QString,QStringList> filesInQrcPath(const QString &path,
const QLocale *locale = 0,
ProjectExplorer::Project *project = 0,
bool addDirs = false,
QrcResourceSelector resources = AllQrcResources);
virtual QList<ProjectInfo> projectInfos() const;
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
@@ -87,6 +101,7 @@ public:
void updateDocument(QmlJS::Document::Ptr doc);
void updateLibraryInfo(const QString &path, const QmlJS::LibraryInfo &info);
void emitDocumentChangedOnDisk(QmlJS::Document::Ptr doc);
void updateQrcFile(const QString &path);
virtual QStringList importPaths() const;
virtual QmlJS::QmlLanguageBundles activeBundles() const;
@@ -147,6 +162,7 @@ private:
QTimer *m_updateCppQmlTypesTimer;
QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > m_queuedCppDocuments;
QFuture<void> m_cppQmlTypesUpdater;
QmlJS::QrcCache m_qrcCache;
CppDataHash m_cppDataHash;
mutable QMutex m_cppDataMutex;