forked from qt-creator/qt-creator
QmlJS: improve code
- no behavior change Change-Id: I61e515876be768309e5647261ffbe2732de423b9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -83,11 +83,11 @@ static QStringList environmentImportPaths()
|
|||||||
{
|
{
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
|
|
||||||
QByteArray envImportPath = qgetenv("QML_IMPORT_PATH");
|
const QStringList importPaths = QString::fromLocal8Bit(qgetenv("QML_IMPORT_PATH")).split(
|
||||||
|
Utils::HostOsInfo::pathListSeparator(), QString::SkipEmptyParts);
|
||||||
|
|
||||||
foreach (const QString &path, QString::fromLatin1(envImportPath)
|
for (const QString &path : importPaths) {
|
||||||
.split(Utils::HostOsInfo::pathListSeparator(), QString::SkipEmptyParts)) {
|
const QString canonicalPath = QDir(path).canonicalPath();
|
||||||
QString canonicalPath = QDir(path).canonicalPath();
|
|
||||||
if (!canonicalPath.isEmpty() && !paths.contains(canonicalPath))
|
if (!canonicalPath.isEmpty() && !paths.contains(canonicalPath))
|
||||||
paths.append(canonicalPath);
|
paths.append(canonicalPath);
|
||||||
}
|
}
|
||||||
@@ -97,11 +97,10 @@ static QStringList environmentImportPaths()
|
|||||||
|
|
||||||
ModelManagerInterface::ModelManagerInterface(QObject *parent)
|
ModelManagerInterface::ModelManagerInterface(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_shouldScanImports(false),
|
m_defaultImportPaths(environmentImportPaths()),
|
||||||
m_defaultProject(nullptr),
|
|
||||||
m_pluginDumper(new PluginDumper(this))
|
m_pluginDumper(new PluginDumper(this))
|
||||||
{
|
{
|
||||||
m_indexerEnabled = qgetenv("QTC_NO_CODE_INDEXER") != "1";
|
m_indexerDisabled = qEnvironmentVariableIsSet("QTC_NO_CODE_INDEXER");
|
||||||
|
|
||||||
m_updateCppQmlTypesTimer = new QTimer(this);
|
m_updateCppQmlTypesTimer = new QTimer(this);
|
||||||
m_updateCppQmlTypesTimer->setInterval(1000);
|
m_updateCppQmlTypesTimer->setInterval(1000);
|
||||||
@@ -123,7 +122,6 @@ ModelManagerInterface::ModelManagerInterface(QObject *parent)
|
|||||||
m_defaultProjectInfo.qtQmlPath = QFileInfo(
|
m_defaultProjectInfo.qtQmlPath = QFileInfo(
|
||||||
QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath();
|
QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath();
|
||||||
|
|
||||||
m_defaultImportPaths << environmentImportPaths();
|
|
||||||
updateImportPaths();
|
updateImportPaths();
|
||||||
|
|
||||||
Q_ASSERT(! g_instance);
|
Q_ASSERT(! g_instance);
|
||||||
@@ -298,7 +296,7 @@ Snapshot ModelManagerInterface::newestSnapshot() const
|
|||||||
void ModelManagerInterface::updateSourceFiles(const QStringList &files,
|
void ModelManagerInterface::updateSourceFiles(const QStringList &files,
|
||||||
bool emitDocumentOnDiskChanged)
|
bool emitDocumentOnDiskChanged)
|
||||||
{
|
{
|
||||||
if (!m_indexerEnabled)
|
if (m_indexerDisabled)
|
||||||
return;
|
return;
|
||||||
refreshSourceFiles(files, emitDocumentOnDiskChanged);
|
refreshSourceFiles(files, emitDocumentOnDiskChanged);
|
||||||
}
|
}
|
||||||
@@ -514,7 +512,7 @@ ModelManagerInterface::ProjectInfo ModelManagerInterface::projectInfo(
|
|||||||
|
|
||||||
void ModelManagerInterface::updateProjectInfo(const ProjectInfo &pinfo, ProjectExplorer::Project *p)
|
void ModelManagerInterface::updateProjectInfo(const ProjectInfo &pinfo, ProjectExplorer::Project *p)
|
||||||
{
|
{
|
||||||
if (! pinfo.isValid() || !p || !m_indexerEnabled)
|
if (! pinfo.isValid() || !p || m_indexerDisabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Snapshot snapshot;
|
Snapshot snapshot;
|
||||||
@@ -1063,7 +1061,7 @@ QmlLanguageBundles ModelManagerInterface::extendedBundles() const
|
|||||||
|
|
||||||
void ModelManagerInterface::maybeScan(const PathsAndLanguages &importPaths)
|
void ModelManagerInterface::maybeScan(const PathsAndLanguages &importPaths)
|
||||||
{
|
{
|
||||||
if (!m_indexerEnabled)
|
if (m_indexerDisabled)
|
||||||
return;
|
return;
|
||||||
PathsAndLanguages pathToScan;
|
PathsAndLanguages pathToScan;
|
||||||
{
|
{
|
||||||
@@ -1086,7 +1084,7 @@ void ModelManagerInterface::maybeScan(const PathsAndLanguages &importPaths)
|
|||||||
|
|
||||||
void ModelManagerInterface::updateImportPaths()
|
void ModelManagerInterface::updateImportPaths()
|
||||||
{
|
{
|
||||||
if (!m_indexerEnabled)
|
if (m_indexerDisabled)
|
||||||
return;
|
return;
|
||||||
PathsAndLanguages allImportPaths;
|
PathsAndLanguages allImportPaths;
|
||||||
QmlLanguageBundles activeBundles;
|
QmlLanguageBundles activeBundles;
|
||||||
|
@@ -265,11 +265,11 @@ private:
|
|||||||
QmlJS::QmlLanguageBundles m_activeBundles;
|
QmlJS::QmlLanguageBundles m_activeBundles;
|
||||||
QmlJS::QmlLanguageBundles m_extendedBundles;
|
QmlJS::QmlLanguageBundles m_extendedBundles;
|
||||||
QHash<Dialect, QmlJS::ViewerContext> m_defaultVContexts;
|
QHash<Dialect, QmlJS::ViewerContext> m_defaultVContexts;
|
||||||
bool m_shouldScanImports;
|
bool m_shouldScanImports = false;
|
||||||
QSet<QString> m_scannedPaths;
|
QSet<QString> m_scannedPaths;
|
||||||
|
|
||||||
QTimer *m_updateCppQmlTypesTimer;
|
QTimer *m_updateCppQmlTypesTimer = nullptr;
|
||||||
QTimer *m_asyncResetTimer;
|
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;
|
QrcCache m_qrcCache;
|
||||||
@@ -282,13 +282,13 @@ private:
|
|||||||
// project integration
|
// project integration
|
||||||
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;
|
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;
|
||||||
ProjectInfo m_defaultProjectInfo;
|
ProjectInfo m_defaultProjectInfo;
|
||||||
ProjectExplorer::Project *m_defaultProject;
|
ProjectExplorer::Project *m_defaultProject = nullptr;
|
||||||
QMultiHash<QString, ProjectExplorer::Project *> m_fileToProject;
|
QMultiHash<QString, ProjectExplorer::Project *> m_fileToProject;
|
||||||
|
|
||||||
PluginDumper *m_pluginDumper;
|
PluginDumper *m_pluginDumper = nullptr;
|
||||||
|
|
||||||
QList<QFuture<void>> m_futures;
|
QList<QFuture<void>> m_futures;
|
||||||
bool m_indexerEnabled;
|
bool m_indexerDisabled = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlJS
|
} // namespace QmlJS
|
||||||
|
@@ -418,7 +418,7 @@ void QrcParserPrivate::collectResourceFilesForSourceFile(const QString &sourceFi
|
|||||||
QStringList *results,
|
QStringList *results,
|
||||||
const QLocale *locale) const
|
const QLocale *locale) const
|
||||||
{
|
{
|
||||||
// TODO: use FileName from fileutils for file pathes
|
// TODO: use FileName from fileutils for file paths
|
||||||
|
|
||||||
QStringList langs = allUiLanguages(locale);
|
QStringList langs = allUiLanguages(locale);
|
||||||
SMap::const_iterator file = m_files.find(sourceFile);
|
SMap::const_iterator file = m_files.find(sourceFile);
|
||||||
|
Reference in New Issue
Block a user