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/qmljssimplereader.h \
|
||||
$$PWD/persistenttrie.h \
|
||||
$$PWD/qmljsqrcparser.h \
|
||||
$$PWD/qmljsconstants.h \
|
||||
$$PWD/qmljsimportdependencies.h \
|
||||
$$PWD/qmljsviewercontext.h \
|
||||
@@ -70,7 +69,6 @@ SOURCES += \
|
||||
$$PWD/jsoncheck.cpp \
|
||||
$$PWD/qmljssimplereader.cpp \
|
||||
$$PWD/persistenttrie.cpp \
|
||||
$$PWD/qmljsqrcparser.cpp \
|
||||
$$PWD/qmljsimportdependencies.cpp \
|
||||
$$PWD/qmljsviewercontext.cpp \
|
||||
$$PWD/qmljsdialect.cpp
|
||||
|
@@ -42,7 +42,6 @@ Project {
|
||||
"qmljsmodelmanagerinterface.cpp", "qmljsmodelmanagerinterface.h",
|
||||
"qmljsplugindumper.cpp", "qmljsplugindumper.h",
|
||||
"qmljspropertyreader.cpp", "qmljspropertyreader.h",
|
||||
"qmljsqrcparser.cpp", "qmljsqrcparser.h",
|
||||
"qmljsreformatter.cpp", "qmljsreformatter.h",
|
||||
"qmljsrewriter.cpp", "qmljsrewriter.h",
|
||||
"qmljsscanner.cpp", "qmljsscanner.h",
|
||||
|
@@ -25,9 +25,9 @@
|
||||
|
||||
#include "qmljsimportdependencies.h"
|
||||
#include "qmljsinterpreter.h"
|
||||
#include "qmljsqrcparser.h"
|
||||
#include "qmljsviewercontext.h"
|
||||
|
||||
#include <utils/qrcparser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QCryptographicHash>
|
||||
@@ -139,10 +139,10 @@ ImportKey::ImportKey(ImportType::Enum type, const QString &path, int majorVersio
|
||||
break;
|
||||
case ImportType::File:
|
||||
case ImportType::QrcFile:
|
||||
splitPath = QrcParser::normalizedQrcFilePath(path).split(QLatin1Char('/'));
|
||||
splitPath = Utils::QrcParser::normalizedQrcFilePath(path).split(QLatin1Char('/'));
|
||||
break;
|
||||
case ImportType::QrcDirectory:
|
||||
splitPath = QrcParser::normalizedQrcDirectoryPath(path).split(QLatin1Char('/'));
|
||||
splitPath = Utils::QrcParser::normalizedQrcDirectoryPath(path).split(QLatin1Char('/'));
|
||||
if (splitPath.length() > 1 && splitPath.last().isEmpty())
|
||||
splitPath.removeLast();
|
||||
break;
|
||||
|
@@ -30,9 +30,10 @@
|
||||
#include "qmljsbind.h"
|
||||
#include "qmljsutils.h"
|
||||
#include "qmljsmodelmanagerinterface.h"
|
||||
#include "qmljsqrcparser.h"
|
||||
#include "qmljsconstants.h"
|
||||
|
||||
#include <utils/qrcparser.h>
|
||||
|
||||
#include <QDir>
|
||||
|
||||
using namespace LanguageUtils;
|
||||
@@ -557,7 +558,7 @@ void LinkPrivate::loadImplicitDirectoryImports(Imports *imports, Document::Ptr d
|
||||
foreach (const QString &path,
|
||||
ModelManagerInterface::instance()->qrcPathsForFile(doc->fileName())) {
|
||||
processImport(ImportInfo::qrcDirectoryImport(
|
||||
QrcParser::qrcDirectoryPathForQrcFilePath(path)));
|
||||
Utils::QrcParser::qrcDirectoryPathForQrcFilePath(path)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -52,6 +52,8 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace QmlJS {
|
||||
|
||||
QMLJS_EXPORT Q_LOGGING_CATEGORY(qmljsLog, "qtc.qmljs.common", QtWarningMsg)
|
||||
|
@@ -28,11 +28,11 @@
|
||||
#include "qmljs_global.h"
|
||||
#include "qmljsbundle.h"
|
||||
#include "qmljsdocument.h"
|
||||
#include "qmljsqrcparser.h"
|
||||
#include "qmljsdialect.h"
|
||||
|
||||
#include <cplusplus/CppDocument.h>
|
||||
#include <utils/environment.h>
|
||||
#include <utils/qrcparser.h>
|
||||
|
||||
#include <QFuture>
|
||||
#include <QHash>
|
||||
@@ -255,7 +255,7 @@ private:
|
||||
void cleanupFutures();
|
||||
void iterateQrcFiles(ProjectExplorer::Project *project,
|
||||
QrcResourceSelector resources,
|
||||
std::function<void(QrcParser::ConstPtr)> callback);
|
||||
std::function<void(Utils::QrcParser::ConstPtr)> callback);
|
||||
|
||||
mutable QMutex m_mutex;
|
||||
QmlJS::Snapshot m_validSnapshot;
|
||||
@@ -272,7 +272,7 @@ private:
|
||||
QTimer *m_asyncResetTimer = nullptr;
|
||||
QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > m_queuedCppDocuments;
|
||||
QFuture<void> m_cppQmlTypesUpdater;
|
||||
QrcCache m_qrcCache;
|
||||
Utils::QrcCache m_qrcCache;
|
||||
QHash<QString, QString> m_qrcContents;
|
||||
|
||||
CppDataHash m_cppDataHash;
|
||||
|
@@ -23,22 +23,26 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qmljsqrcparser.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 "qrcparser.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 {
|
||||
/*!
|
||||
@@ -496,7 +500,7 @@ QrcParser::Ptr QrcCachePrivate::addPath(const QString &path, const QString &cont
|
||||
}
|
||||
QrcParser::Ptr newParser = QrcParser::parseQrcFile(path, contents);
|
||||
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);
|
||||
QPair<QrcParser::Ptr,int> currentValue = m_cache.value(path, {QrcParser::Ptr(0), 0});
|
@@ -24,7 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include "qmljs_global.h"
|
||||
#include "utils_global.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QSharedPointer>
|
||||
@@ -33,14 +33,14 @@
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QLocale)
|
||||
|
||||
namespace QmlJS {
|
||||
namespace Utils {
|
||||
|
||||
namespace Internal {
|
||||
class QrcParserPrivate;
|
||||
class QrcCachePrivate;
|
||||
}
|
||||
|
||||
class QMLJS_EXPORT QrcParser
|
||||
class QTCREATOR_UTILS_EXPORT QrcParser
|
||||
{
|
||||
public:
|
||||
typedef QSharedPointer<QrcParser> Ptr;
|
||||
@@ -69,7 +69,7 @@ private:
|
||||
Internal::QrcParserPrivate *d;
|
||||
};
|
||||
|
||||
class QMLJS_EXPORT QrcCache
|
||||
class QTCREATOR_UTILS_EXPORT QrcCache
|
||||
{
|
||||
public:
|
||||
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/*
|
||||
|
||||
@@ -27,6 +27,7 @@ SOURCES += \
|
||||
$$PWD/environment.cpp \
|
||||
$$PWD/environmentmodel.cpp \
|
||||
$$PWD/environmentdialog.cpp \
|
||||
$$PWD/qrcparser.cpp \
|
||||
$$PWD/qtcprocess.cpp \
|
||||
$$PWD/reloadpromptutils.cpp \
|
||||
$$PWD/settingsaccessor.cpp \
|
||||
@@ -135,6 +136,7 @@ HEADERS += \
|
||||
$$PWD/environmentmodel.h \
|
||||
$$PWD/environmentdialog.h \
|
||||
$$PWD/pointeralgorithm.h \
|
||||
$$PWD/qrcparser.h \
|
||||
$$PWD/qtcprocess.h \
|
||||
$$PWD/utils_global.h \
|
||||
$$PWD/reloadpromptutils.h \
|
||||
|
@@ -33,7 +33,7 @@ Project {
|
||||
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: "app_version_header" }
|
||||
|
||||
@@ -189,6 +189,8 @@ Project {
|
||||
"proxycredentialsdialog.cpp",
|
||||
"proxycredentialsdialog.h",
|
||||
"proxycredentialsdialog.ui",
|
||||
"qrcparser.cpp",
|
||||
"qrcparser.h",
|
||||
"qtcassert.cpp",
|
||||
"qtcassert.h",
|
||||
"qtcolorbutton.cpp",
|
||||
|
@@ -48,10 +48,10 @@
|
||||
#include <qmljs/qmljscheck.h>
|
||||
#include <qmljs/qmljsutils.h>
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
#include <qmljs/qmljsqrcparser.h>
|
||||
#include <qmljs/qmljsinterpreter.h>
|
||||
#include <qmljs/qmljsvalueowner.h>
|
||||
|
||||
#include <utils/qrcparser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QSet>
|
||||
@@ -456,7 +456,7 @@ public:
|
||||
if (!name.isEmpty() && name != QLatin1String("."))
|
||||
typeName.prepend(name + QLatin1Char('.'));
|
||||
} 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));
|
||||
const QString name = path.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||
if (!name.isEmpty())
|
||||
|
@@ -43,9 +43,9 @@
|
||||
#include <qmljs/parser/qmljsast_p.h>
|
||||
#include <qmljs/parser/qmljsastfwd_p.h>
|
||||
#include <qmljs/qmljsutils.h>
|
||||
#include <qmljs/qmljsqrcparser.h>
|
||||
#include <texteditor/texteditor.h>
|
||||
#include <utils/executeondestruction.h>
|
||||
#include <utils/qrcparser.h>
|
||||
#include <utils/tooltip/tooltip.h>
|
||||
|
||||
#include <QDir>
|
||||
@@ -133,7 +133,7 @@ static inline QString getModuleName(const ScopeChain &scopeChain, const Document
|
||||
const QString name = relativeDir.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||
return name;
|
||||
} 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));
|
||||
const QString name = path.replace(QLatin1Char('/'), QLatin1Char('.'));
|
||||
return name;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include(../shared/shared.pri)
|
||||
QTC_PLUGIN_DEPENDS += qmljstools
|
||||
QTC_PLUGIN_DEPENDS += utils
|
||||
include(../../qttest.pri)
|
||||
#DEFINES+=CPLUSPLUS_BUILD_STATIC_LIB
|
||||
include($$IDE_SOURCE_TREE/src/rpath.pri)
|
||||
|
@@ -1,9 +1,8 @@
|
||||
import qbs
|
||||
|
||||
QtcAutotest {
|
||||
name: "QML qrc parser autotest"
|
||||
Depends { name: "QmlJS" }
|
||||
Depends { name: "QmlJSTools" }
|
||||
name: "qrc parser autotest"
|
||||
Depends { name: "Utils" }
|
||||
files: "tst_qrcparser.cpp"
|
||||
cpp.defines: base.concat(['TESTSRCDIR="' + path + '"'])
|
||||
}
|
||||
|
@@ -27,9 +27,9 @@
|
||||
#include <QDebug>
|
||||
#include <QLocale>
|
||||
|
||||
#include <qmljs/qmljsqrcparser.h>
|
||||
#include <utils/qrcparser.h>
|
||||
|
||||
using namespace QmlJS;
|
||||
using namespace Utils;
|
||||
|
||||
class tst_QrcParser: public QObject
|
||||
{
|
||||
|
Reference in New Issue
Block a user