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;
|
||||
|
||||
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)
|
||||
.split(Utils::HostOsInfo::pathListSeparator(), QString::SkipEmptyParts)) {
|
||||
QString canonicalPath = QDir(path).canonicalPath();
|
||||
for (const QString &path : importPaths) {
|
||||
const QString canonicalPath = QDir(path).canonicalPath();
|
||||
if (!canonicalPath.isEmpty() && !paths.contains(canonicalPath))
|
||||
paths.append(canonicalPath);
|
||||
}
|
||||
@@ -97,11 +97,10 @@ static QStringList environmentImportPaths()
|
||||
|
||||
ModelManagerInterface::ModelManagerInterface(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_shouldScanImports(false),
|
||||
m_defaultProject(nullptr),
|
||||
m_defaultImportPaths(environmentImportPaths()),
|
||||
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->setInterval(1000);
|
||||
@@ -123,7 +122,6 @@ ModelManagerInterface::ModelManagerInterface(QObject *parent)
|
||||
m_defaultProjectInfo.qtQmlPath = QFileInfo(
|
||||
QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath();
|
||||
|
||||
m_defaultImportPaths << environmentImportPaths();
|
||||
updateImportPaths();
|
||||
|
||||
Q_ASSERT(! g_instance);
|
||||
@@ -298,7 +296,7 @@ Snapshot ModelManagerInterface::newestSnapshot() const
|
||||
void ModelManagerInterface::updateSourceFiles(const QStringList &files,
|
||||
bool emitDocumentOnDiskChanged)
|
||||
{
|
||||
if (!m_indexerEnabled)
|
||||
if (m_indexerDisabled)
|
||||
return;
|
||||
refreshSourceFiles(files, emitDocumentOnDiskChanged);
|
||||
}
|
||||
@@ -514,7 +512,7 @@ ModelManagerInterface::ProjectInfo ModelManagerInterface::projectInfo(
|
||||
|
||||
void ModelManagerInterface::updateProjectInfo(const ProjectInfo &pinfo, ProjectExplorer::Project *p)
|
||||
{
|
||||
if (! pinfo.isValid() || !p || !m_indexerEnabled)
|
||||
if (! pinfo.isValid() || !p || m_indexerDisabled)
|
||||
return;
|
||||
|
||||
Snapshot snapshot;
|
||||
@@ -1063,7 +1061,7 @@ QmlLanguageBundles ModelManagerInterface::extendedBundles() const
|
||||
|
||||
void ModelManagerInterface::maybeScan(const PathsAndLanguages &importPaths)
|
||||
{
|
||||
if (!m_indexerEnabled)
|
||||
if (m_indexerDisabled)
|
||||
return;
|
||||
PathsAndLanguages pathToScan;
|
||||
{
|
||||
@@ -1086,7 +1084,7 @@ void ModelManagerInterface::maybeScan(const PathsAndLanguages &importPaths)
|
||||
|
||||
void ModelManagerInterface::updateImportPaths()
|
||||
{
|
||||
if (!m_indexerEnabled)
|
||||
if (m_indexerDisabled)
|
||||
return;
|
||||
PathsAndLanguages allImportPaths;
|
||||
QmlLanguageBundles activeBundles;
|
||||
|
@@ -265,11 +265,11 @@ private:
|
||||
QmlJS::QmlLanguageBundles m_activeBundles;
|
||||
QmlJS::QmlLanguageBundles m_extendedBundles;
|
||||
QHash<Dialect, QmlJS::ViewerContext> m_defaultVContexts;
|
||||
bool m_shouldScanImports;
|
||||
bool m_shouldScanImports = false;
|
||||
QSet<QString> m_scannedPaths;
|
||||
|
||||
QTimer *m_updateCppQmlTypesTimer;
|
||||
QTimer *m_asyncResetTimer;
|
||||
QTimer *m_updateCppQmlTypesTimer = nullptr;
|
||||
QTimer *m_asyncResetTimer = nullptr;
|
||||
QHash<QString, QPair<CPlusPlus::Document::Ptr, bool> > m_queuedCppDocuments;
|
||||
QFuture<void> m_cppQmlTypesUpdater;
|
||||
QrcCache m_qrcCache;
|
||||
@@ -282,13 +282,13 @@ private:
|
||||
// project integration
|
||||
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;
|
||||
ProjectInfo m_defaultProjectInfo;
|
||||
ProjectExplorer::Project *m_defaultProject;
|
||||
ProjectExplorer::Project *m_defaultProject = nullptr;
|
||||
QMultiHash<QString, ProjectExplorer::Project *> m_fileToProject;
|
||||
|
||||
PluginDumper *m_pluginDumper;
|
||||
PluginDumper *m_pluginDumper = nullptr;
|
||||
|
||||
QList<QFuture<void>> m_futures;
|
||||
bool m_indexerEnabled;
|
||||
bool m_indexerDisabled = false;
|
||||
};
|
||||
|
||||
} // namespace QmlJS
|
||||
|
@@ -418,7 +418,7 @@ void QrcParserPrivate::collectResourceFilesForSourceFile(const QString &sourceFi
|
||||
QStringList *results,
|
||||
const QLocale *locale) const
|
||||
{
|
||||
// TODO: use FileName from fileutils for file pathes
|
||||
// TODO: use FileName from fileutils for file paths
|
||||
|
||||
QStringList langs = allUiLanguages(locale);
|
||||
SMap::const_iterator file = m_files.find(sourceFile);
|
||||
|
Reference in New Issue
Block a user