forked from qt-creator/qt-creator
qmljs: fix projectInfoForPath and fileToPath mapping
m_fileToPath was not always updated correctly which lead projectInfoForPath to return a wrong/invalid project info, messing up the paths used by the code model. Change-Id: If5e144f1ef2c7353b9077deb1b9c9aa9d1708651 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com> Reviewed-by: Fawzi Mohamed <fawzi.mohamed@theqtcompany.com>
This commit is contained in:
committed by
Fawzi Mohamed
parent
ecfe8329eb
commit
cfe29cc936
@@ -563,9 +563,9 @@ void ModelManagerInterface::updateProjectInfo(const ProjectInfo &pinfo, ProjectE
|
|||||||
if (!snapshot.document(file))
|
if (!snapshot.document(file))
|
||||||
newFiles += file;
|
newFiles += file;
|
||||||
}
|
}
|
||||||
updateSourceFiles(newFiles, false);
|
foreach (const QString &newFile, newFiles)
|
||||||
foreach (const QString &newFile, deletedFiles)
|
|
||||||
m_fileToProject.insert(newFile, p);
|
m_fileToProject.insert(newFile, p);
|
||||||
|
updateSourceFiles(newFiles, false);
|
||||||
|
|
||||||
// update qrc cache
|
// update qrc cache
|
||||||
foreach (const QString &newQrc, pinfo.allResourceFiles)
|
foreach (const QString &newQrc, pinfo.allResourceFiles)
|
||||||
@@ -608,6 +608,10 @@ ModelManagerInterface::ProjectInfo ModelManagerInterface::projectInfoForPath(QSt
|
|||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
projects = m_fileToProject.values(path);
|
projects = m_fileToProject.values(path);
|
||||||
|
if (projects.isEmpty()) {
|
||||||
|
QFileInfo fInfo(path);
|
||||||
|
projects = m_fileToProject.values(fInfo.canonicalFilePath());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QList<ProjectInfo> infos;
|
QList<ProjectInfo> infos;
|
||||||
foreach (ProjectExplorer::Project *project, projects) {
|
foreach (ProjectExplorer::Project *project, projects) {
|
||||||
@@ -616,6 +620,7 @@ ModelManagerInterface::ProjectInfo ModelManagerInterface::projectInfoForPath(QSt
|
|||||||
infos.append(info);
|
infos.append(info);
|
||||||
}
|
}
|
||||||
std::sort(infos.begin(), infos.end(), &pInfoLessThanImports);
|
std::sort(infos.begin(), infos.end(), &pInfoLessThanImports);
|
||||||
|
infos.append(m_defaultProjectInfo);
|
||||||
|
|
||||||
ProjectInfo res;
|
ProjectInfo res;
|
||||||
foreach (const ProjectInfo &pInfo, infos) {
|
foreach (const ProjectInfo &pInfo, infos) {
|
||||||
@@ -1321,7 +1326,7 @@ ModelManagerInterface::CppDataHash ModelManagerInterface::cppData() const
|
|||||||
|
|
||||||
LibraryInfo ModelManagerInterface::builtins(const Document::Ptr &doc) const
|
LibraryInfo ModelManagerInterface::builtins(const Document::Ptr &doc) const
|
||||||
{
|
{
|
||||||
ProjectInfo info = projectInfoForPath(doc->path());
|
ProjectInfo info = projectInfoForPath(doc->fileName());
|
||||||
if (!info.isValid())
|
if (!info.isValid())
|
||||||
return LibraryInfo();
|
return LibraryInfo();
|
||||||
if (!info.qtQmlPath.isEmpty())
|
if (!info.qtQmlPath.isEmpty())
|
||||||
@@ -1343,7 +1348,7 @@ ViewerContext ModelManagerInterface::completeVContext(const ViewerContext &vCtx,
|
|||||||
res.language = doc->language();
|
res.language = doc->language();
|
||||||
ProjectInfo info;
|
ProjectInfo info;
|
||||||
if (!doc.isNull())
|
if (!doc.isNull())
|
||||||
info = projectInfoForPath(doc->path());
|
info = projectInfoForPath(doc->fileName());
|
||||||
ViewerContext defaultVCtx = defaultVContext(res.language, Document::Ptr(0), false);
|
ViewerContext defaultVCtx = defaultVContext(res.language, Document::Ptr(0), false);
|
||||||
ProjectInfo defaultInfo = defaultProjectInfo();
|
ProjectInfo defaultInfo = defaultProjectInfo();
|
||||||
if (info.qtImportsPath.isEmpty())
|
if (info.qtImportsPath.isEmpty())
|
||||||
|
|||||||
Reference in New Issue
Block a user