Commit 329b1535 authored by Fawzi Mohamed's avatar Fawzi Mohamed

Revert "qmljs: better defaults, more uniform handling of paths"

moving to master

This reverts commit 0c46692244def9edb89c2914b9b1e5eff10cb6ce

Change-Id: Ie09f6db02058f4a5539221f1a0cc4f9225f38300
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 29958b57
......@@ -178,7 +178,7 @@ public:
void updateLibraryInfo(const QString &path, const QmlJS::LibraryInfo &info);
void emitDocumentChangedOnDisk(QmlJS::Document::Ptr doc);
void updateQrcFile(const QString &path);
ProjectInfo projectInfoForPath(QString path) const;
ProjectInfo projectInfoForPath(QString path);
QStringList importPaths() const;
QmlJS::QmlLanguageBundles activeBundles() const;
......@@ -189,16 +189,17 @@ public:
CppDataHash cppData() const;
LibraryInfo builtins(const Document::Ptr &doc) const;
ViewerContext completeVContext(const ViewerContext &vCtx,
const Document::Ptr &doc = Document::Ptr(0)) const;
ViewerContext defaultVContext(Language::Enum language = Language::Qml,
const Document::Ptr &doc = Document::Ptr(0),
bool autoComplete = true) const;
void setDefaultVContext(const ViewerContext &vContext);
virtual ProjectInfo defaultProjectInfo() const;
virtual ViewerContext completeVContext(const ViewerContext &vCtx,
const Document::Ptr &doc = Document::Ptr(0)) const;
virtual ViewerContext defaultVContext(bool autoComplete = true,
const Document::Ptr &doc = Document::Ptr(0)) const;
virtual void setDefaultVContext(const ViewerContext &vContext);
// Blocks until all parsing threads are done. Used for testing.
void joinAllThreads();
virtual ModelManagerInterface::ProjectInfo defaultProjectInfo() const;
public slots:
virtual void resetCodeModel();
void removeProjectInfo(ProjectExplorer::Project *project);
......@@ -256,7 +257,7 @@ private:
QStringList m_defaultImportPaths;
QmlJS::QmlLanguageBundles m_activeBundles;
QmlJS::QmlLanguageBundles m_extendedBundles;
QHash<Language::Enum, QmlJS::ViewerContext> m_defaultVContexts;
QmlJS::ViewerContext m_vContext;
bool m_shouldScanImports;
QSet<QString> m_scannedPaths;
......
......@@ -76,10 +76,4 @@ bool ViewerContext::languageIsCompatible(Language::Enum l) const
return true;
}
void ViewerContext::maybeAddPath(const QString &path)
{
if (!path.isEmpty() && !paths.contains(path))
paths.append(path);
}
} // namespace QmlJS
......@@ -42,10 +42,8 @@ class QMLJS_EXPORT ViewerContext
public:
enum Flags {
Complete,
AddAllPathsAndDefaultSelectors,
AddAllPaths,
AddDefaultPaths,
AddDefaultPathsAndSelectors
AddQtPath
};
ViewerContext();
......@@ -54,7 +52,6 @@ public:
Flags flags = AddAllPaths);
bool languageIsCompatible(Language::Enum l) const;
void maybeAddPath(const QString &path);
QStringList selectors;
QStringList paths;
......
......@@ -103,7 +103,7 @@ static inline bool checkIfDerivedFromItem(const QString &fileName)
snapshot.insert(document);
QmlJS::Link link(snapshot, modelManager->defaultVContext(document->language(), document), QmlJS::ModelManagerInterface::instance()->builtins(document));
QmlJS::Link link(snapshot, modelManager->defaultVContext(), QmlJS::ModelManagerInterface::instance()->builtins(document));
QList<QmlJS::DiagnosticMessage> diagnosticLinkMessages;
QmlJS::ContextPtr context = link(document, &diagnosticLinkMessages);
......
......@@ -831,7 +831,7 @@ static void find_helper(QFutureInterface<FindReferences::Usage> &future,
QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance();
Link link(snapshot, modelManager->defaultVContext(doc->language(), doc), modelManager->builtins(doc));
Link link(snapshot, modelManager->defaultVContext(), modelManager->builtins(doc));
ContextPtr context = link();
ScopeChain scopeChain(doc, context);
......
......@@ -122,7 +122,7 @@ QmlJSTools::SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const QmlJS::D
ModelManagerInterface *modelManager = ModelManagerInterface::instance();
Link link(semanticInfo.snapshot, modelManager->defaultVContext(doc->language(), doc), modelManager->builtins(doc));
Link link(semanticInfo.snapshot, modelManager->defaultVContext(), modelManager->builtins(doc));
semanticInfo.context = link(doc, &semanticInfo.semanticMessages);
ScopeChain *scopeChain = new ScopeChain(doc, semanticInfo.context);
......
......@@ -161,7 +161,7 @@ void QmlTaskManager::updateMessagesNow(bool updateSemantic)
QFuture<FileErrorMessages> future =
QtConcurrent::run<FileErrorMessages>(
&collectMessages, modelManager->newestSnapshot(), modelManager->projectInfos(),
modelManager->defaultVContext(Language::Unknown), updateSemantic);
modelManager->defaultVContext(), updateSemantic);
m_messageCollector.setFuture(future);
}
......
......@@ -61,8 +61,6 @@
#include <QTimer>
#include <QRegExp>
#include <QtAlgorithms>
#include <QLibraryInfo>
#include <qglobal.h>
#include <QDebug>
......@@ -89,8 +87,8 @@ ModelManagerInterface::ProjectInfo QmlJSTools::defaultProjectInfoForProject(
globs.append(MimeGlobPattern(QLatin1String("*.qmltypes")));
globs.append(MimeGlobPattern(QLatin1String("*.qmlproject")));
}
foreach (const QString &filePath,
project->files(ProjectExplorer::Project::ExcludeGeneratedFiles))
foreach (const QString &filePath
, project->files(ProjectExplorer::Project::ExcludeGeneratedFiles))
foreach (const MimeGlobPattern &glob, globs)
if (glob.matches(filePath))
projectInfo.sourceFiles << filePath;
......@@ -119,10 +117,6 @@ ModelManagerInterface::ProjectInfo QmlJSTools::defaultProjectInfoForProject(
projectInfo.qtQmlPath = qtVersion->qmakeProperty("QT_INSTALL_QML");
projectInfo.qtImportsPath = qtVersion->qmakeProperty("QT_INSTALL_IMPORTS");
projectInfo.qtVersionString = qtVersion->qtVersionString();
} else {
projectInfo.qtQmlPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
projectInfo.qtImportsPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
projectInfo.qtVersionString = QLatin1String(qVersion());
}
if (projectInfo.tryQmlDump) {
......@@ -257,9 +251,11 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopyInternal() const
ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfo() const
{
// needs to be performed in the ui therad (change?)
ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::currentProject();
return defaultProjectInfoForProject(currentProject);
ProjectExplorer::Project *activeProject = ProjectExplorer::SessionManager::startupProject();
if (!activeProject)
return ModelManagerInterface::ProjectInfo();
return projectInfo(activeProject);
}
// Check whether fileMimeType is the same or extends knownMimeType
......@@ -283,3 +279,4 @@ void ModelManager::addTaskInternal(QFuture<void> result, const QString &msg, con
{
ProgressManager::addTask(result, msg, taskId);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment