forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.0'
Conflicts: qtcreator.pri qtcreator.qbs src/plugins/debugger/debuggerruncontrol.cpp Change-Id: I81b43480a1369e3d7be60ae26e812dda6b962b0b
This commit is contained in:
@@ -2277,6 +2277,14 @@ ImportInfo ImportInfo::implicitDirectoryImport(const QString &directory)
|
||||
return info;
|
||||
}
|
||||
|
||||
ImportInfo ImportInfo::qrcDirectoryImport(const QString &directory)
|
||||
{
|
||||
ImportInfo info;
|
||||
info.m_type = ImportType::QrcDirectory;
|
||||
info.m_path = directory;
|
||||
return info;
|
||||
}
|
||||
|
||||
bool ImportInfo::isValid() const
|
||||
{
|
||||
return m_type != ImportType::Invalid;
|
||||
|
||||
@@ -1001,6 +1001,7 @@ public:
|
||||
const QString &as, AST::UiImport *ast = 0);
|
||||
static ImportInfo invalidImport(AST::UiImport *ast = 0);
|
||||
static ImportInfo implicitDirectoryImport(const QString &directory);
|
||||
static ImportInfo qrcDirectoryImport(const QString &directory);
|
||||
|
||||
bool isValid() const;
|
||||
ImportType::Enum type() const;
|
||||
|
||||
@@ -575,16 +575,23 @@ void LinkPrivate::loadQmldirComponents(ObjectValue *import, ComponentVersion ver
|
||||
|
||||
void LinkPrivate::loadImplicitDirectoryImports(Imports *imports, Document::Ptr doc)
|
||||
{
|
||||
ImportInfo implcitDirectoryImportInfo = ImportInfo::implicitDirectoryImport(doc->path());
|
||||
|
||||
Import directoryImport = importCache.value(ImportCacheKey(implcitDirectoryImportInfo));
|
||||
if (!directoryImport.object) {
|
||||
directoryImport = importFileOrDirectory(doc, implcitDirectoryImportInfo);
|
||||
auto processImport = [this, imports, doc](const ImportInfo &importInfo){
|
||||
Import directoryImport = importCache.value(ImportCacheKey(importInfo));
|
||||
if (!directoryImport.object) {
|
||||
directoryImport = importFileOrDirectory(doc, importInfo);
|
||||
if (directoryImport.object)
|
||||
importCache.insert(ImportCacheKey(importInfo), directoryImport);
|
||||
}
|
||||
if (directoryImport.object)
|
||||
importCache.insert(ImportCacheKey(implcitDirectoryImportInfo), directoryImport);
|
||||
imports->append(directoryImport);
|
||||
};
|
||||
|
||||
processImport(ImportInfo::implicitDirectoryImport(doc->path()));
|
||||
foreach (const QString &path,
|
||||
ModelManagerInterface::instance()->qrcPathsForFile(doc->fileName())) {
|
||||
processImport(ImportInfo::qrcDirectoryImport(
|
||||
QrcParser::qrcDirectoryPathForQrcFilePath(path)));
|
||||
}
|
||||
if (directoryImport.object)
|
||||
imports->append(directoryImport);
|
||||
}
|
||||
|
||||
void LinkPrivate::loadImplicitDefaultImports(Imports *imports)
|
||||
|
||||
@@ -427,46 +427,10 @@ bool pInfoLessThanImports(const ModelManagerInterface::ProjectInfo &p1, const Mo
|
||||
|
||||
}
|
||||
|
||||
QStringList ModelManagerInterface::filesAtQrcPath(const QString &path, const QLocale *locale,
|
||||
ProjectExplorer::Project *project,
|
||||
QrcResourceSelector resources)
|
||||
void ModelManagerInterface::iterateQrcFiles(ProjectExplorer::Project *project,
|
||||
QrcResourceSelector resources,
|
||||
std::function<void(QrcParser::ConstPtr)> callback)
|
||||
{
|
||||
QString normPath = QrcParser::normalizedQrcFilePath(path);
|
||||
QList<ProjectInfo> pInfos;
|
||||
if (project)
|
||||
pInfos.append(projectInfo(project));
|
||||
else
|
||||
pInfos = projectInfos();
|
||||
|
||||
QStringList res;
|
||||
QSet<QString> pathsChecked;
|
||||
foreach (const ModelManagerInterface::ProjectInfo &pInfo, pInfos) {
|
||||
QStringList qrcFilePaths;
|
||||
if (resources == ActiveQrcResources)
|
||||
qrcFilePaths = pInfo.activeResourceFiles;
|
||||
else
|
||||
qrcFilePaths = pInfo.allResourceFiles;
|
||||
foreach (const QString &qrcFilePath, qrcFilePaths) {
|
||||
if (pathsChecked.contains(qrcFilePath))
|
||||
continue;
|
||||
pathsChecked.insert(qrcFilePath);
|
||||
QrcParser::ConstPtr qrcFile = m_qrcCache.parsedPath(qrcFilePath);
|
||||
if (qrcFile.isNull())
|
||||
continue;
|
||||
qrcFile->collectFilesAtPath(normPath, &res, locale);
|
||||
}
|
||||
}
|
||||
res.sort(); // make the result predictable
|
||||
return res;
|
||||
}
|
||||
|
||||
QMap<QString, QStringList> ModelManagerInterface::filesInQrcPath(const QString &path,
|
||||
const QLocale *locale,
|
||||
ProjectExplorer::Project *project,
|
||||
bool addDirs,
|
||||
QrcResourceSelector resources)
|
||||
{
|
||||
QString normPath = QrcParser::normalizedQrcDirectoryPath(path);
|
||||
QList<ProjectInfo> pInfos;
|
||||
if (project) {
|
||||
pInfos.append(projectInfo(project));
|
||||
@@ -477,7 +441,7 @@ QMap<QString, QStringList> ModelManagerInterface::filesInQrcPath(const QString &
|
||||
else
|
||||
qSort(pInfos.begin(), pInfos.end(), &pInfoLessThanAll);
|
||||
}
|
||||
QMap<QString, QStringList> res;
|
||||
|
||||
QSet<QString> pathsChecked;
|
||||
foreach (const ModelManagerInterface::ProjectInfo &pInfo, pInfos) {
|
||||
QStringList qrcFilePaths;
|
||||
@@ -490,12 +454,47 @@ QMap<QString, QStringList> ModelManagerInterface::filesInQrcPath(const QString &
|
||||
continue;
|
||||
pathsChecked.insert(qrcFilePath);
|
||||
QrcParser::ConstPtr qrcFile = m_qrcCache.parsedPath(qrcFilePath);
|
||||
|
||||
if (qrcFile.isNull())
|
||||
continue;
|
||||
qrcFile->collectFilesInPath(normPath, &res, addDirs, locale);
|
||||
callback(qrcFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QStringList ModelManagerInterface::qrcPathsForFile(const QString &file, const QLocale *locale,
|
||||
ProjectExplorer::Project *project,
|
||||
QrcResourceSelector resources)
|
||||
{
|
||||
QStringList res;
|
||||
iterateQrcFiles(project, resources, [&](QrcParser::ConstPtr qrcFile) {
|
||||
qrcFile->collectResourceFilesForSourceFile(file, &res, locale);
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
QStringList ModelManagerInterface::filesAtQrcPath(const QString &path, const QLocale *locale,
|
||||
ProjectExplorer::Project *project,
|
||||
QrcResourceSelector resources)
|
||||
{
|
||||
QString normPath = QrcParser::normalizedQrcFilePath(path);
|
||||
QStringList res;
|
||||
iterateQrcFiles(project, resources, [&](QrcParser::ConstPtr qrcFile) {
|
||||
qrcFile->collectFilesAtPath(normPath, &res, locale);
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
QMap<QString, QStringList> ModelManagerInterface::filesInQrcPath(const QString &path,
|
||||
const QLocale *locale,
|
||||
ProjectExplorer::Project *project,
|
||||
bool addDirs,
|
||||
QrcResourceSelector resources)
|
||||
{
|
||||
QString normPath = QrcParser::normalizedQrcDirectoryPath(path);
|
||||
QMap<QString, QStringList> res;
|
||||
iterateQrcFiles(project, resources, [&](QrcParser::ConstPtr qrcFile) {
|
||||
qrcFile->collectFilesInPath(normPath, &res, addDirs, locale);
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,6 +152,9 @@ public:
|
||||
bool emitDocumentOnDiskChanged);
|
||||
void fileChangedOnDisk(const QString &path);
|
||||
void removeFiles(const QStringList &files);
|
||||
QStringList qrcPathsForFile(const QString &file, const QLocale *locale = 0,
|
||||
ProjectExplorer::Project *project = 0,
|
||||
QrcResourceSelector resources = AllQrcResources);
|
||||
QStringList filesAtQrcPath(const QString &path, const QLocale *locale = 0,
|
||||
ProjectExplorer::Project *project = 0,
|
||||
QrcResourceSelector resources = AllQrcResources);
|
||||
@@ -249,6 +252,9 @@ protected:
|
||||
|
||||
private:
|
||||
void cleanupFutures();
|
||||
void iterateQrcFiles(ProjectExplorer::Project *project,
|
||||
QrcResourceSelector resources,
|
||||
std::function<void(QrcParser::ConstPtr)> callback);
|
||||
|
||||
mutable QMutex m_mutex;
|
||||
QmlJS::Snapshot m_validSnapshot;
|
||||
|
||||
@@ -74,6 +74,9 @@ public:
|
||||
bool hasDirAtPath(const QString &path, const QLocale *locale = 0) const;
|
||||
void collectFilesInPath(const QString &path, QMap<QString,QStringList> *res, bool addDirs = false,
|
||||
const QLocale *locale = 0) const;
|
||||
void collectResourceFilesForSourceFile(const QString &sourceFile, QStringList *res,
|
||||
const QLocale *locale = 0) const;
|
||||
|
||||
QStringList errorMessages() const;
|
||||
QStringList languages() const;
|
||||
private:
|
||||
@@ -81,6 +84,7 @@ private:
|
||||
QStringList allUiLanguages(const QLocale *locale) const;
|
||||
|
||||
SMap m_resources;
|
||||
SMap m_files;
|
||||
QStringList m_languages;
|
||||
QStringList m_errorMessages;
|
||||
};
|
||||
@@ -130,6 +134,11 @@ QString QrcParser::normalizedQrcDirectoryPath(const QString &path) {
|
||||
return normPath;
|
||||
}
|
||||
|
||||
QString QrcParser::qrcDirectoryPathForQrcFilePath(const QString &file)
|
||||
{
|
||||
return file.left(file.lastIndexOf(QLatin1Char('/')));
|
||||
}
|
||||
|
||||
QrcParser::QrcParser()
|
||||
{
|
||||
d = new Internal::QrcParserPrivate(this);
|
||||
@@ -181,6 +190,12 @@ void QrcParser::collectFilesInPath(const QString &path, QMap<QString,QStringList
|
||||
d->collectFilesInPath(path, res, addDirs, locale);
|
||||
}
|
||||
|
||||
void QrcParser::collectResourceFilesForSourceFile(const QString &sourceFile, QStringList *res,
|
||||
const QLocale *locale) const
|
||||
{
|
||||
d->collectResourceFilesForSourceFile(sourceFile, res, locale);
|
||||
}
|
||||
|
||||
/*! \brief returns the errors found while parsing
|
||||
*/
|
||||
QStringList QrcParser::errorMessages() const
|
||||
@@ -297,13 +312,12 @@ bool QrcParserPrivate::parseFile(const QString &path)
|
||||
accessPath = language + prefix + alias;
|
||||
else
|
||||
accessPath = language + prefix + fileName;
|
||||
if (m_resources.contains(accessPath)) {
|
||||
QStringList &val = m_resources[accessPath];
|
||||
if (!val.contains(filePath))
|
||||
val.append(filePath);
|
||||
} else {
|
||||
m_resources.insert(accessPath, QStringList(filePath));
|
||||
}
|
||||
QStringList &resources = m_resources[accessPath];
|
||||
if (!resources.contains(filePath))
|
||||
resources.append(filePath);
|
||||
QStringList &files = m_files[filePath];
|
||||
if (!files.contains(accessPath))
|
||||
files.append(accessPath);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -388,6 +402,24 @@ void QrcParserPrivate::collectFilesInPath(const QString &path, QMap<QString,QStr
|
||||
}
|
||||
}
|
||||
|
||||
void QrcParserPrivate::collectResourceFilesForSourceFile(const QString &sourceFile,
|
||||
QStringList *results,
|
||||
const QLocale *locale) const
|
||||
{
|
||||
QTC_CHECK(sourceFile.startsWith(QLatin1Char('/')));
|
||||
QTC_CHECK(!sourceFile.endsWith(QLatin1Char('/')));
|
||||
QStringList langs = allUiLanguages(locale);
|
||||
SMap::const_iterator file = m_files.find(sourceFile);
|
||||
if (file == m_files.end())
|
||||
return;
|
||||
foreach (const QString &resource, file.value()) {
|
||||
foreach (const QString &language, langs) {
|
||||
if (resource.startsWith(language) && !results->contains(resource))
|
||||
results->append(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QStringList QrcParserPrivate::errorMessages() const
|
||||
{
|
||||
return m_errorMessages;
|
||||
|
||||
@@ -52,6 +52,9 @@ public:
|
||||
bool hasDirAtPath(const QString &path, const QLocale *locale = 0) const;
|
||||
void collectFilesInPath(const QString &path, QMap<QString,QStringList> *res, bool addDirs = false,
|
||||
const QLocale *locale = 0) const;
|
||||
void collectResourceFilesForSourceFile(const QString &sourceFile, QStringList *results,
|
||||
const QLocale *locale = 0) const;
|
||||
|
||||
QStringList errorMessages() const;
|
||||
QStringList languages() const;
|
||||
bool isValid() const;
|
||||
@@ -59,6 +62,7 @@ public:
|
||||
static Ptr parseQrcFile(const QString &path);
|
||||
static QString normalizedQrcFilePath(const QString &path);
|
||||
static QString normalizedQrcDirectoryPath(const QString &path);
|
||||
static QString qrcDirectoryPathForQrcFilePath(const QString &file);
|
||||
private:
|
||||
QrcParser();
|
||||
QrcParser(const QrcParser &);
|
||||
|
||||
Reference in New Issue
Block a user