forked from qt-creator/qt-creator
Move qrc parser from QmlJS to Utils
We'd like to make use of it in a more general context, and it's not directly related to QML. Change-Id: I025ec67829f85544667684cdb8c99d1ee4c18197 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -36,7 +36,6 @@ HEADERS += \
|
|||||||
$$PWD/jsoncheck.h \
|
$$PWD/jsoncheck.h \
|
||||||
$$PWD/qmljssimplereader.h \
|
$$PWD/qmljssimplereader.h \
|
||||||
$$PWD/persistenttrie.h \
|
$$PWD/persistenttrie.h \
|
||||||
$$PWD/qmljsqrcparser.h \
|
|
||||||
$$PWD/qmljsconstants.h \
|
$$PWD/qmljsconstants.h \
|
||||||
$$PWD/qmljsimportdependencies.h \
|
$$PWD/qmljsimportdependencies.h \
|
||||||
$$PWD/qmljsviewercontext.h \
|
$$PWD/qmljsviewercontext.h \
|
||||||
@@ -70,7 +69,6 @@ SOURCES += \
|
|||||||
$$PWD/jsoncheck.cpp \
|
$$PWD/jsoncheck.cpp \
|
||||||
$$PWD/qmljssimplereader.cpp \
|
$$PWD/qmljssimplereader.cpp \
|
||||||
$$PWD/persistenttrie.cpp \
|
$$PWD/persistenttrie.cpp \
|
||||||
$$PWD/qmljsqrcparser.cpp \
|
|
||||||
$$PWD/qmljsimportdependencies.cpp \
|
$$PWD/qmljsimportdependencies.cpp \
|
||||||
$$PWD/qmljsviewercontext.cpp \
|
$$PWD/qmljsviewercontext.cpp \
|
||||||
$$PWD/qmljsdialect.cpp
|
$$PWD/qmljsdialect.cpp
|
||||||
|
@@ -42,7 +42,6 @@ Project {
|
|||||||
"qmljsmodelmanagerinterface.cpp", "qmljsmodelmanagerinterface.h",
|
"qmljsmodelmanagerinterface.cpp", "qmljsmodelmanagerinterface.h",
|
||||||
"qmljsplugindumper.cpp", "qmljsplugindumper.h",
|
"qmljsplugindumper.cpp", "qmljsplugindumper.h",
|
||||||
"qmljspropertyreader.cpp", "qmljspropertyreader.h",
|
"qmljspropertyreader.cpp", "qmljspropertyreader.h",
|
||||||
"qmljsqrcparser.cpp", "qmljsqrcparser.h",
|
|
||||||
"qmljsreformatter.cpp", "qmljsreformatter.h",
|
"qmljsreformatter.cpp", "qmljsreformatter.h",
|
||||||
"qmljsrewriter.cpp", "qmljsrewriter.h",
|
"qmljsrewriter.cpp", "qmljsrewriter.h",
|
||||||
"qmljsscanner.cpp", "qmljsscanner.h",
|
"qmljsscanner.cpp", "qmljsscanner.h",
|
||||||
|
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
#include "qmljsimportdependencies.h"
|
#include "qmljsimportdependencies.h"
|
||||||
#include "qmljsinterpreter.h"
|
#include "qmljsinterpreter.h"
|
||||||
#include "qmljsqrcparser.h"
|
|
||||||
#include "qmljsviewercontext.h"
|
#include "qmljsviewercontext.h"
|
||||||
|
|
||||||
|
#include <utils/qrcparser.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
@@ -139,10 +139,10 @@ ImportKey::ImportKey(ImportType::Enum type, const QString &path, int majorVersio
|
|||||||
break;
|
break;
|
||||||
case ImportType::File:
|
case ImportType::File:
|
||||||
case ImportType::QrcFile:
|
case ImportType::QrcFile:
|
||||||
splitPath = QrcParser::normalizedQrcFilePath(path).split(QLatin1Char('/'));
|
splitPath = Utils::QrcParser::normalizedQrcFilePath(path).split(QLatin1Char('/'));
|
||||||
break;
|
break;
|
||||||
case ImportType::QrcDirectory:
|
case ImportType::QrcDirectory:
|
||||||
splitPath = QrcParser::normalizedQrcDirectoryPath(path).split(QLatin1Char('/'));
|
splitPath = Utils::QrcParser::normalizedQrcDirectoryPath(path).split(QLatin1Char('/'));
|
||||||
if (splitPath.length() > 1 && splitPath.last().isEmpty())
|
if (splitPath.length() > 1 && splitPath.last().isEmpty())
|
||||||
splitPath.removeLast();
|
splitPath.removeLast();
|
||||||
break;
|
break;
|
||||||
|
@@ -30,9 +30,10 @@
|
|||||||
#include "qmljsbind.h"
|
#include "qmljsbind.h"
|
||||||
#include "qmljsutils.h"
|
#include "qmljsutils.h"
|
||||||
#include "qmljsmodelmanagerinterface.h"
|
#include "qmljsmodelmanagerinterface.h"
|
||||||
#include "qmljsqrcparser.h"
|
|
||||||
#include "qmljsconstants.h"
|
#include "qmljsconstants.h"
|
||||||
|
|
||||||
|
#include <utils/qrcparser.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
using namespace LanguageUtils;
|
using namespace LanguageUtils;
|
||||||
@@ -557,7 +558,7 @@ void LinkPrivate::loadImplicitDirectoryImports(Imports *imports, Document::Ptr d
|
|||||||
foreach (const QString &path,
|
foreach (const QString &path,
|
||||||
ModelManagerInterface::instance()->qrcPathsForFile(doc->fileName())) {
|
ModelManagerInterface::instance()->qrcPathsForFile(doc->fileName())) {
|
||||||
processImport(ImportInfo::qrcDirectoryImport(
|
processImport(ImportInfo::qrcDirectoryImport(
|
||||||
QrcParser::qrcDirectoryPathForQrcFilePath(path)));
|
Utils::QrcParser::qrcDirectoryPathForQrcFilePath(path)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,6 +52,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace QmlJS {
|
namespace QmlJS {
|
||||||
|
|
||||||
QMLJS_EXPORT Q_LOGGING_CATEGORY(qmljsLog, "qtc.qmljs.common", QtWarningMsg)
|
QMLJS_EXPORT Q_LOGGING_CATEGORY(qmljsLog, "qtc.qmljs.common", QtWarningMsg)
|
||||||
|
@@ -28,11 +28,11 @@
|
|||||||
#include "qmljs_global.h"
|
#include "qmljs_global.h"
|
||||||
#include "qmljsbundle.h"
|
#include "qmljsbundle.h"
|
||||||
#include "qmljsdocument.h"
|
#include "qmljsdocument.h"
|
||||||
#include "qmljsqrcparser.h"
|
|
||||||
#include "qmljsdialect.h"
|
#include "qmljsdialect.h"
|
||||||
|
|
||||||
#include <cplusplus/CppDocument.h>
|
#include <cplusplus/CppDocument.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
|
#include <utils/qrcparser.h>
|
||||||
|
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
@@ -255,7 +255,7 @@ private:
|
|||||||
void cleanupFutures();
|
void cleanupFutures();
|
||||||
void iterateQrcFiles(ProjectExplorer::Project *project,
|
void iterateQrcFiles(ProjectExplorer::Project *project,
|
||||||
QrcResourceSelector resources,
|
QrcResourceSelector resources,
|
||||||
std::function<void(QrcParser::ConstPtr)> callback);
|
std::function<void(Utils::QrcParser::ConstPtr)> callback);
|
||||||
|
|
||||||
mutable QMutex m_mutex;
|
mutable QMutex m_mutex;
|
||||||
QmlJS::Snapshot m_validSnapshot;
|
QmlJS::Snapshot m_validSnapshot;
|
||||||
@@ -272,7 +272,7 @@ private:
|
|||||||
QTimer *m_asyncResetTimer = nullptr;
|
QTimer *m_asyncResetTimer = nullptr;
|
||||||
QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > m_queuedCppDocuments;
|
QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > m_queuedCppDocuments;
|
||||||
QFuture<void> m_cppQmlTypesUpdater;
|
QFuture<void> m_cppQmlTypesUpdater;
|
||||||
QrcCache m_qrcCache;
|
Utils::QrcCache m_qrcCache;
|
||||||
QHash<QString, QString> m_qrcContents;
|
QHash<QString, QString> m_qrcContents;
|
||||||
|
|
||||||
CppDataHash m_cppDataHash;
|
CppDataHash m_cppDataHash;
|
||||||
|
@@ -23,22 +23,26 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "qmljsqrcparser.h"
|
#include "qrcparser.h"
|
||||||
#include "qmljsconstants.h"
|
|
||||||
#include <QFile>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QDomDocument>
|
|
||||||
#include <QLocale>
|
|
||||||
#include <QMutex>
|
|
||||||
#include <QSet>
|
|
||||||
#include <QMutexLocker>
|
|
||||||
#include <QMultiHash>
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
namespace QmlJS {
|
#include <QCoreApplication>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QDomDocument>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QLocale>
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
#include <QMultiHash>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QMutexLocker>
|
||||||
|
#include <QSet>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(qrcParserLog, "qtc.qrcParser", QtWarningMsg)
|
||||||
|
|
||||||
|
namespace Utils {
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
/*!
|
/*!
|
||||||
@@ -496,7 +500,7 @@ QrcParser::Ptr QrcCachePrivate::addPath(const QString &path, const QString &cont
|
|||||||
}
|
}
|
||||||
QrcParser::Ptr newParser = QrcParser::parseQrcFile(path, contents);
|
QrcParser::Ptr newParser = QrcParser::parseQrcFile(path, contents);
|
||||||
if (!newParser->isValid())
|
if (!newParser->isValid())
|
||||||
qCWarning(qmljsLog) << "adding invalid qrc " << path << " to the cache:" << newParser->errorMessages();
|
qCWarning(qrcParserLog) << "adding invalid qrc " << path << " to the cache:" << newParser->errorMessages();
|
||||||
{
|
{
|
||||||
QMutexLocker l(&m_mutex);
|
QMutexLocker l(&m_mutex);
|
||||||
QPair<QrcParser::Ptr,int> currentValue = m_cache.value(path, {QrcParser::Ptr(0), 0});
|
QPair<QrcParser::Ptr,int> currentValue = m_cache.value(path, {QrcParser::Ptr(0), 0});
|
@@ -24,7 +24,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "qmljs_global.h"
|
#include "utils_global.h"
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
@@ -33,14 +33,14 @@
|
|||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QLocale)
|
QT_FORWARD_DECLARE_CLASS(QLocale)
|
||||||
|
|
||||||
namespace QmlJS {
|
namespace Utils {
|
||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
class QrcParserPrivate;
|
class QrcParserPrivate;
|
||||||
class QrcCachePrivate;
|
class QrcCachePrivate;
|
||||||
}
|
}
|
||||||
|
|
||||||
class QMLJS_EXPORT QrcParser
|
class QTCREATOR_UTILS_EXPORT QrcParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef QSharedPointer<QrcParser> Ptr;
|
typedef QSharedPointer<QrcParser> Ptr;
|
||||||
@@ -69,7 +69,7 @@ private:
|
|||||||
Internal::QrcParserPrivate *d;
|
Internal::QrcParserPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QMLJS_EXPORT QrcCache
|
class QTCREATOR_UTILS_EXPORT QrcCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QrcCache();
|
QrcCache();
|
@@ -13,7 +13,7 @@ shared {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QT += widgets gui network qml
|
QT += widgets gui network qml xml
|
||||||
|
|
||||||
CONFIG += exceptions # used by portlist.cpp, textfileformat.cpp, and ssh/*
|
CONFIG += exceptions # used by portlist.cpp, textfileformat.cpp, and ssh/*
|
||||||
|
|
||||||
@@ -27,6 +27,7 @@ SOURCES += \
|
|||||||
$$PWD/environment.cpp \
|
$$PWD/environment.cpp \
|
||||||
$$PWD/environmentmodel.cpp \
|
$$PWD/environmentmodel.cpp \
|
||||||
$$PWD/environmentdialog.cpp \
|
$$PWD/environmentdialog.cpp \
|
||||||
|
$$PWD/qrcparser.cpp \
|
||||||
$$PWD/qtcprocess.cpp \
|
$$PWD/qtcprocess.cpp \
|
||||||
$$PWD/reloadpromptutils.cpp \
|
$$PWD/reloadpromptutils.cpp \
|
||||||
$$PWD/settingsaccessor.cpp \
|
$$PWD/settingsaccessor.cpp \
|
||||||
@@ -135,6 +136,7 @@ HEADERS += \
|
|||||||
$$PWD/environmentmodel.h \
|
$$PWD/environmentmodel.h \
|
||||||
$$PWD/environmentdialog.h \
|
$$PWD/environmentdialog.h \
|
||||||
$$PWD/pointeralgorithm.h \
|
$$PWD/pointeralgorithm.h \
|
||||||
|
$$PWD/qrcparser.h \
|
||||||
$$PWD/qtcprocess.h \
|
$$PWD/qtcprocess.h \
|
||||||
$$PWD/utils_global.h \
|
$$PWD/utils_global.h \
|
||||||
$$PWD/reloadpromptutils.h \
|
$$PWD/reloadpromptutils.h \
|
||||||
|
@@ -33,7 +33,7 @@ Project {
|
|||||||
cpp.frameworks: ["Foundation", "AppKit"]
|
cpp.frameworks: ["Foundation", "AppKit"]
|
||||||
}
|
}
|
||||||
|
|
||||||
Depends { name: "Qt"; submodules: ["concurrent", "network", "qml", "widgets"] }
|
Depends { name: "Qt"; submodules: ["concurrent", "network", "qml", "widgets", "xml"] }
|
||||||
Depends { name: "Qt.macextras"; condition: qbs.targetOS.contains("macos") }
|
Depends { name: "Qt.macextras"; condition: qbs.targetOS.contains("macos") }
|
||||||
Depends { name: "app_version_header" }
|
Depends { name: "app_version_header" }
|
||||||
|
|
||||||
@@ -189,6 +189,8 @@ Project {
|
|||||||
"proxycredentialsdialog.cpp",
|
"proxycredentialsdialog.cpp",
|
||||||
"proxycredentialsdialog.h",
|
"proxycredentialsdialog.h",
|
||||||
"proxycredentialsdialog.ui",
|
"proxycredentialsdialog.ui",
|
||||||
|
"qrcparser.cpp",
|
||||||
|
"qrcparser.h",
|
||||||
"qtcassert.cpp",
|
"qtcassert.cpp",
|
||||||
"qtcassert.h",
|
"qtcassert.h",
|
||||||
"qtcolorbutton.cpp",
|
"qtcolorbutton.cpp",
|
||||||
|
@@ -48,10 +48,10 @@
|
|||||||
#include <qmljs/qmljscheck.h>
|
#include <qmljs/qmljscheck.h>
|
||||||
#include <qmljs/qmljsutils.h>
|
#include <qmljs/qmljsutils.h>
|
||||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||||
#include <qmljs/qmljsqrcparser.h>
|
|
||||||
#include <qmljs/qmljsinterpreter.h>
|
#include <qmljs/qmljsinterpreter.h>
|
||||||
#include <qmljs/qmljsvalueowner.h>
|
#include <qmljs/qmljsvalueowner.h>
|
||||||
|
|
||||||
|
#include <utils/qrcparser.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
@@ -456,7 +456,7 @@ public:
|
|||||||
if (!name.isEmpty() && name != QLatin1String("."))
|
if (!name.isEmpty() && name != QLatin1String("."))
|
||||||
typeName.prepend(name + QLatin1Char('.'));
|
typeName.prepend(name + QLatin1Char('.'));
|
||||||
} else if (importInfo.isValid() && importInfo.type() == ImportType::QrcDirectory) {
|
} else if (importInfo.isValid() && importInfo.type() == ImportType::QrcDirectory) {
|
||||||
QString path = QrcParser::normalizedQrcDirectoryPath(importInfo.path());
|
QString path = Utils::QrcParser::normalizedQrcDirectoryPath(importInfo.path());
|
||||||
path = path.mid(1, path.size() - ((path.size() > 1) ? 2 : 1));
|
path = path.mid(1, path.size() - ((path.size() > 1) ? 2 : 1));
|
||||||
const QString name = path.replace(QLatin1Char('/'), QLatin1Char('.'));
|
const QString name = path.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||||
if (!name.isEmpty())
|
if (!name.isEmpty())
|
||||||
|
@@ -43,9 +43,9 @@
|
|||||||
#include <qmljs/parser/qmljsast_p.h>
|
#include <qmljs/parser/qmljsast_p.h>
|
||||||
#include <qmljs/parser/qmljsastfwd_p.h>
|
#include <qmljs/parser/qmljsastfwd_p.h>
|
||||||
#include <qmljs/qmljsutils.h>
|
#include <qmljs/qmljsutils.h>
|
||||||
#include <qmljs/qmljsqrcparser.h>
|
|
||||||
#include <texteditor/texteditor.h>
|
#include <texteditor/texteditor.h>
|
||||||
#include <utils/executeondestruction.h>
|
#include <utils/executeondestruction.h>
|
||||||
|
#include <utils/qrcparser.h>
|
||||||
#include <utils/tooltip/tooltip.h>
|
#include <utils/tooltip/tooltip.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -133,7 +133,7 @@ static inline QString getModuleName(const ScopeChain &scopeChain, const Document
|
|||||||
const QString name = relativeDir.replace(QLatin1Char('/'), QLatin1Char('.'));
|
const QString name = relativeDir.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||||
return name;
|
return name;
|
||||||
} else if (importInfo.isValid() && importInfo.type() == ImportType::QrcDirectory) {
|
} else if (importInfo.isValid() && importInfo.type() == ImportType::QrcDirectory) {
|
||||||
QString path = QrcParser::normalizedQrcDirectoryPath(importInfo.path());
|
QString path = Utils::QrcParser::normalizedQrcDirectoryPath(importInfo.path());
|
||||||
path = path.mid(1, path.size() - ((path.size() > 1) ? 2 : 1));
|
path = path.mid(1, path.size() - ((path.size() > 1) ? 2 : 1));
|
||||||
const QString name = path.replace(QLatin1Char('/'), QLatin1Char('.'));
|
const QString name = path.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||||
return name;
|
return name;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
#include(../shared/shared.pri)
|
#include(../shared/shared.pri)
|
||||||
QTC_PLUGIN_DEPENDS += qmljstools
|
QTC_PLUGIN_DEPENDS += utils
|
||||||
include(../../qttest.pri)
|
include(../../qttest.pri)
|
||||||
#DEFINES+=CPLUSPLUS_BUILD_STATIC_LIB
|
#DEFINES+=CPLUSPLUS_BUILD_STATIC_LIB
|
||||||
include($$IDE_SOURCE_TREE/src/rpath.pri)
|
include($$IDE_SOURCE_TREE/src/rpath.pri)
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
import qbs
|
import qbs
|
||||||
|
|
||||||
QtcAutotest {
|
QtcAutotest {
|
||||||
name: "QML qrc parser autotest"
|
name: "qrc parser autotest"
|
||||||
Depends { name: "QmlJS" }
|
Depends { name: "Utils" }
|
||||||
Depends { name: "QmlJSTools" }
|
|
||||||
files: "tst_qrcparser.cpp"
|
files: "tst_qrcparser.cpp"
|
||||||
cpp.defines: base.concat(['TESTSRCDIR="' + path + '"'])
|
cpp.defines: base.concat(['TESTSRCDIR="' + path + '"'])
|
||||||
}
|
}
|
||||||
|
@@ -27,9 +27,9 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
|
|
||||||
#include <qmljs/qmljsqrcparser.h>
|
#include <utils/qrcparser.h>
|
||||||
|
|
||||||
using namespace QmlJS;
|
using namespace Utils;
|
||||||
|
|
||||||
class tst_QrcParser: public QObject
|
class tst_QrcParser: public QObject
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user