QmlJS: Add a way to return just the context of the project of a file

Added ModelManagerInterface::projectVContext() method to return just
the context of the project the file belongs to and nothing more.

To make this possible, fixed caching the file-to-project relationships
and removed automatically adding the currently active project to
list of projects the file belongs to in allProjectInfos().

Task-number: QDS-1495
Change-Id: I949c0202d0280264b6856562a2e7abc2f93d13c0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Miikka Heikkinen
2020-05-20 12:47:09 +03:00
parent 346b28f5f9
commit 7f4bf437da
2 changed files with 35 additions and 11 deletions

View File

@@ -174,6 +174,8 @@ public:
ViewerContext defaultVContext(Dialect language = Dialect::Qml,
const Document::Ptr &doc = Document::Ptr(nullptr),
bool autoComplete = true) const;
ViewerContext projectVContext(Dialect language, const Document::Ptr &doc) const;
void setDefaultVContext(const ViewerContext &vContext);
virtual ProjectInfo defaultProjectInfo() const;
virtual ProjectInfo defaultProjectInfoForProject(ProjectExplorer::Project *project) const;
@@ -241,6 +243,7 @@ private:
void iterateQrcFiles(ProjectExplorer::Project *project,
QrcResourceSelector resources,
const std::function<void(Utils::QrcParser::ConstPtr)> &callback);
ViewerContext getVContext(const ViewerContext &vCtx, const Document::Ptr &doc, bool limitToProject) const;
mutable QMutex m_mutex;
QmlJS::Snapshot m_validSnapshot;