MCPcopy Create free account
hub / github.com/KDE/kdevelop / modulePath

Method modulePath

plugins/qmljs/duchain/cache.cpp:65–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65QString QmlJS::Cache::modulePath(const KDevelop::IndexedString& baseFile, const QString& uri, const QString& version)
66{
67 QMutexLocker lock(&m_mutex);
68 QString cacheKey = uri + version;
69 QString path = m_modulePaths.value(cacheKey, QString());
70
71 if (!path.isEmpty()) {
72 return path;
73 }
74
75 // Find the path for which <path>/u/r/i exists
76 QString fragment = QString(uri).replace(QLatin1Char('.'), QDir::separator());
77 bool isVersion1 = version.startsWith(QLatin1String("1."));
78 bool isQtQuick = (uri == QLatin1String("QtQuick"));
79
80 const QStringList modulesWithoutVersionSuffix{
81 QStringLiteral("QtQml"),
82 QStringLiteral("QtMultimedia"),
83 QStringLiteral("QtQuick.LocalStorage"),
84 QStringLiteral("QtQuick.XmlListModel"),
85 };
86
87 if (!isVersion1 && !fragment.isEmpty() && !fragment.endsWith(QLatin1Char('/')) && !version.isEmpty()
88 && !modulesWithoutVersionSuffix.contains(uri)) {
89 // Modules having a version greater or equal to 2 are stored in a directory
90 // name like QtQuick.2
91 fragment += QLatin1Char('.') + version.section(QLatin1Char('.'), 0, 0);
92 }
93
94 const auto paths = libraryPaths_internal(baseFile);
95 for (auto& p : paths) {
96 QString pathString = p.cd(fragment).path();
97
98 // HACK: QtQuick 1.0 is put in $LIB/qt5/imports/builtins.qmltypes. The "QtQuick"
99 // identifier appears nowhere.
100 if (isQtQuick && isVersion1) {
101 if (QFile::exists(p.cd(QStringLiteral("builtins.qmltypes")).path())) {
102 path = p.path();
103 break;
104 }
105 } else if (QFile::exists(pathString + QLatin1String("/plugins.qmltypes"))) {
106 path = pathString;
107 break;
108 }
109 }
110
111 m_modulePaths.insert(cacheKey, path);
112 return path;
113}
114
115QStringList QmlJS::Cache::getFileNames(const QFileInfoList& fileInfos)
116{

Callers 3

importModuleMethod · 0.45
importCompletionMethod · 0.45

Calls 10

endsWithMethod · 0.80
sectionMethod · 0.80
cdMethod · 0.80
QStringClass · 0.50
valueMethod · 0.45
isEmptyMethod · 0.45
replaceMethod · 0.45
containsMethod · 0.45
pathMethod · 0.45
insertMethod · 0.45

Tested by 1