forked from qt-creator/qt-creator
QmlJS: Use canonical paths for matching of import directories
We rely on string comparison for detection of QML import paths. Therefore make sure that all paths are canonical. Change-Id: I416bc31915644a888c416d726049668b0e71f29a Task-number: QTCREATORBUG-12902 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
This commit is contained in:
@@ -534,6 +534,7 @@ void Snapshot::insert(const Document::Ptr &document, bool allowInvalid)
|
||||
|
||||
void Snapshot::insertLibraryInfo(const QString &path, const LibraryInfo &info)
|
||||
{
|
||||
QTC_CHECK(!path.isEmpty());
|
||||
QTC_CHECK(info.fingerprint() == info.calculateFingerprint());
|
||||
_libraries.insert(QDir::cleanPath(path), info);
|
||||
if (!info.wasFound()) return;
|
||||
|
||||
@@ -438,15 +438,21 @@ Import LinkPrivate::importNonFile(Document::Ptr doc, const ImportInfo &importInf
|
||||
}
|
||||
|
||||
bool LinkPrivate::importLibrary(Document::Ptr doc,
|
||||
const QString &libraryPath,
|
||||
const QString &libraryPath_,
|
||||
Import *import,
|
||||
const QString &importPath)
|
||||
{
|
||||
const ImportInfo &importInfo = import->info;
|
||||
QString libraryPath = libraryPath_;
|
||||
|
||||
const LibraryInfo libraryInfo = snapshot.libraryInfo(libraryPath);
|
||||
LibraryInfo libraryInfo = snapshot.libraryInfo(libraryPath);
|
||||
if (!libraryInfo.isValid()) {
|
||||
// try canonical path
|
||||
libraryPath = QFileInfo(libraryPath).canonicalFilePath();
|
||||
libraryInfo = snapshot.libraryInfo(libraryPath);
|
||||
if (!libraryInfo.isValid())
|
||||
return false;
|
||||
}
|
||||
|
||||
import->libraryPath = libraryPath;
|
||||
|
||||
|
||||
@@ -114,9 +114,11 @@ ModelManagerInterface::ModelManagerInterface(QObject *parent)
|
||||
qRegisterMetaType<QmlJS::Document::Ptr>("QmlJS::Document::Ptr");
|
||||
qRegisterMetaType<QmlJS::LibraryInfo>("QmlJS::LibraryInfo");
|
||||
|
||||
m_defaultProjectInfo.qtImportsPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
|
||||
m_defaultProjectInfo.qtImportsPath = QFileInfo(
|
||||
QLibraryInfo::location(QLibraryInfo::ImportsPath)).canonicalFilePath();
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
m_defaultProjectInfo.qtQmlPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
|
||||
m_defaultProjectInfo.qtQmlPath = QFileInfo(
|
||||
QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath();
|
||||
#endif
|
||||
|
||||
m_defaultImportPaths << environmentImportPaths();
|
||||
|
||||
@@ -112,14 +112,14 @@ ModelManagerInterface::ProjectInfo QmlJSTools::defaultProjectInfoForProject(
|
||||
projectInfo.tryQmlDump = project && (
|
||||
qtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)
|
||||
|| qtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT));
|
||||
projectInfo.qtQmlPath = qtVersion->qmakeProperty("QT_INSTALL_QML");
|
||||
projectInfo.qtImportsPath = qtVersion->qmakeProperty("QT_INSTALL_IMPORTS");
|
||||
projectInfo.qtQmlPath = QFileInfo(qtVersion->qmakeProperty("QT_INSTALL_QML")).canonicalFilePath();
|
||||
projectInfo.qtImportsPath = QFileInfo(qtVersion->qmakeProperty("QT_INSTALL_IMPORTS")).canonicalFilePath();
|
||||
projectInfo.qtVersionString = qtVersion->qtVersionString();
|
||||
} else {
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
projectInfo.qtQmlPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath);
|
||||
projectInfo.qtQmlPath = QFileInfo(QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath)).canonicalFilePath();
|
||||
#endif
|
||||
projectInfo.qtImportsPath = QLibraryInfo::location(QLibraryInfo::ImportsPath);
|
||||
projectInfo.qtImportsPath = QFileInfo(QLibraryInfo::location(QLibraryInfo::ImportsPath)).canonicalFilePath();
|
||||
projectInfo.qtVersionString = QLatin1String(qVersion());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user