forked from qt-creator/qt-creator
QmlJS: Proliferate FilePath use
Change-Id: Ifd009ef9c6e15506d173727e84dda966d79bdb01 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -123,13 +123,10 @@ void PluginDumper::onLoadPluginTypes(const Utils::FilePath &libraryPath,
|
|||||||
plugin.importVersion = importVersion;
|
plugin.importVersion = importVersion;
|
||||||
|
|
||||||
// add default qmltypes file if it exists
|
// add default qmltypes file if it exists
|
||||||
QDirIterator it(canonicalLibraryPath.toString(), QStringList { "*.qmltypes" }, QDir::Files);
|
const FilePaths libEntries = canonicalLibraryPath.dirEntries({{"*.qmltypes"}, QDir::Files});
|
||||||
|
for (const FilePath &libEntry : libEntries) {
|
||||||
while (it.hasNext()) {
|
if (!plugin.typeInfoPaths.contains(libEntry))
|
||||||
const FilePath defaultQmltypesPath = canonicalLibraryPath.resolvePath(it.next());
|
plugin.typeInfoPaths += libEntry;
|
||||||
|
|
||||||
if (!plugin.typeInfoPaths.contains(defaultQmltypesPath))
|
|
||||||
plugin.typeInfoPaths += defaultQmltypesPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add typeinfo files listed in qmldir
|
// add typeinfo files listed in qmldir
|
||||||
@@ -142,7 +139,7 @@ void PluginDumper::onLoadPluginTypes(const Utils::FilePath &libraryPath,
|
|||||||
// watch plugin libraries
|
// watch plugin libraries
|
||||||
const QList<QmlDirParser::Plugin> plugins = snapshot.libraryInfo(canonicalLibraryPath).plugins();
|
const QList<QmlDirParser::Plugin> plugins = snapshot.libraryInfo(canonicalLibraryPath).plugins();
|
||||||
for (const QmlDirParser::Plugin &plugin : plugins) {
|
for (const QmlDirParser::Plugin &plugin : plugins) {
|
||||||
const QString pluginLibrary = resolvePlugin(canonicalLibraryPath.toString(), plugin.path, plugin.name);
|
const FilePath pluginLibrary = resolvePlugin(canonicalLibraryPath, plugin.path, plugin.name);
|
||||||
if (!pluginLibrary.isEmpty()) {
|
if (!pluginLibrary.isEmpty()) {
|
||||||
if (!pluginWatcher()->watchesFile(pluginLibrary))
|
if (!pluginWatcher()->watchesFile(pluginLibrary))
|
||||||
pluginWatcher()->addFile(pluginLibrary, FileSystemWatcher::WatchModifiedDate);
|
pluginWatcher()->addFile(pluginLibrary, FileSystemWatcher::WatchModifiedDate);
|
||||||
@@ -155,9 +152,9 @@ void PluginDumper::onLoadPluginTypes(const Utils::FilePath &libraryPath,
|
|||||||
for (const FilePath &path : std::as_const(plugin.typeInfoPaths)) {
|
for (const FilePath &path : std::as_const(plugin.typeInfoPaths)) {
|
||||||
if (!path.exists())
|
if (!path.exists())
|
||||||
continue;
|
continue;
|
||||||
if (!pluginWatcher()->watchesFile(path.toString()))
|
if (!pluginWatcher()->watchesFile(path))
|
||||||
pluginWatcher()->addFile(path.toString(), FileSystemWatcher::WatchModifiedDate);
|
pluginWatcher()->addFile(path, FileSystemWatcher::WatchModifiedDate);
|
||||||
m_libraryToPluginIndex.insert(path.toString(), index);
|
m_libraryToPluginIndex.insert(path, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +316,7 @@ void PluginDumper::qmlPluginTypeDumpDone(QtcProcess *process)
|
|||||||
|
|
||||||
void PluginDumper::pluginChanged(const QString &pluginLibrary)
|
void PluginDumper::pluginChanged(const QString &pluginLibrary)
|
||||||
{
|
{
|
||||||
const int pluginIndex = m_libraryToPluginIndex.value(pluginLibrary, -1);
|
const int pluginIndex = m_libraryToPluginIndex.value(FilePath::fromString(pluginLibrary), -1);
|
||||||
if (pluginIndex == -1)
|
if (pluginIndex == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -666,12 +663,11 @@ void PluginDumper::dump(const Plugin &plugin)
|
|||||||
|
|
||||||
Adapted from QDeclarativeImportDatabase::resolvePlugin.
|
Adapted from QDeclarativeImportDatabase::resolvePlugin.
|
||||||
*/
|
*/
|
||||||
QString PluginDumper::resolvePlugin(const QDir &qmldirPath, const QString &qmldirPluginPath,
|
FilePath PluginDumper::resolvePlugin(const FilePath &qmldirPath, const QString &qmldirPluginPath,
|
||||||
const QString &baseName, const QStringList &suffixes,
|
const QString &baseName, const QStringList &suffixes,
|
||||||
const QString &prefix)
|
const QString &prefix)
|
||||||
{
|
{
|
||||||
QStringList searchPaths;
|
QStringList searchPaths = {"."};
|
||||||
searchPaths.append(QLatin1String("."));
|
|
||||||
|
|
||||||
bool qmldirPluginPathIsRelative = QDir::isRelativePath(qmldirPluginPath);
|
bool qmldirPluginPathIsRelative = QDir::isRelativePath(qmldirPluginPath);
|
||||||
if (!qmldirPluginPathIsRelative)
|
if (!qmldirPluginPathIsRelative)
|
||||||
@@ -679,32 +675,25 @@ QString PluginDumper::resolvePlugin(const QDir &qmldirPath, const QString &qmldi
|
|||||||
|
|
||||||
for (const QString &pluginPath : std::as_const(searchPaths)) {
|
for (const QString &pluginPath : std::as_const(searchPaths)) {
|
||||||
|
|
||||||
QString resolvedPath;
|
FilePath resolvedPath;
|
||||||
|
|
||||||
if (pluginPath == QLatin1String(".")) {
|
if (pluginPath == QLatin1String(".")) {
|
||||||
if (qmldirPluginPathIsRelative)
|
if (qmldirPluginPathIsRelative)
|
||||||
resolvedPath = qmldirPath.absoluteFilePath(qmldirPluginPath);
|
resolvedPath = qmldirPath.resolvePath(qmldirPluginPath);
|
||||||
else
|
else
|
||||||
resolvedPath = qmldirPath.absolutePath();
|
resolvedPath = qmldirPath.absoluteFilePath();
|
||||||
} else {
|
} else {
|
||||||
resolvedPath = pluginPath;
|
resolvedPath = FilePath::fromString(pluginPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir dir(resolvedPath);
|
|
||||||
for (const QString &suffix : suffixes) {
|
for (const QString &suffix : suffixes) {
|
||||||
QString pluginFileName = prefix;
|
FilePath candidate = resolvedPath.pathAppended(prefix + baseName + suffix);
|
||||||
|
if (candidate.exists())
|
||||||
pluginFileName += baseName;
|
return candidate.absoluteFilePath();
|
||||||
pluginFileName += suffix;
|
|
||||||
|
|
||||||
QFileInfo fileInfo(dir, pluginFileName);
|
|
||||||
|
|
||||||
if (fileInfo.exists())
|
|
||||||
return fileInfo.absoluteFilePath();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -723,8 +712,8 @@ QString PluginDumper::resolvePlugin(const QDir &qmldirPath, const QString &qmldi
|
|||||||
|
|
||||||
Version number on unix are ignored.
|
Version number on unix are ignored.
|
||||||
*/
|
*/
|
||||||
QString PluginDumper::resolvePlugin(const QDir &qmldirPath, const QString &qmldirPluginPath,
|
FilePath PluginDumper::resolvePlugin(const FilePath &qmldirPath, const QString &qmldirPluginPath,
|
||||||
const QString &baseName)
|
const QString &baseName)
|
||||||
{
|
{
|
||||||
QStringList validSuffixList;
|
QStringList validSuffixList;
|
||||||
QString prefix;
|
QString prefix;
|
||||||
|
|||||||
@@ -82,11 +82,13 @@ private:
|
|||||||
void loadQmltypesFile(const Utils::FilePaths &qmltypesFilePaths,
|
void loadQmltypesFile(const Utils::FilePaths &qmltypesFilePaths,
|
||||||
const Utils::FilePath &libraryPath,
|
const Utils::FilePath &libraryPath,
|
||||||
QmlJS::LibraryInfo libraryInfo);
|
QmlJS::LibraryInfo libraryInfo);
|
||||||
QString resolvePlugin(const QDir &qmldirPath, const QString &qmldirPluginPath,
|
Utils::FilePath resolvePlugin(const Utils::FilePath &qmldirPath,
|
||||||
const QString &baseName);
|
const QString &qmldirPluginPath,
|
||||||
QString resolvePlugin(const QDir &qmldirPath, const QString &qmldirPluginPath,
|
const QString &baseName);
|
||||||
const QString &baseName, const QStringList &suffixes,
|
Utils::FilePath resolvePlugin(const Utils::FilePath &qmldirPath,
|
||||||
const QString &prefix = QString());
|
const QString &qmldirPluginPath,
|
||||||
|
const QString &baseName, const QStringList &suffixes,
|
||||||
|
const QString &prefix = QString());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utils::FileSystemWatcher *pluginWatcher();
|
Utils::FileSystemWatcher *pluginWatcher();
|
||||||
@@ -102,7 +104,7 @@ private:
|
|||||||
Utils::FileSystemWatcher *m_pluginWatcher;
|
Utils::FileSystemWatcher *m_pluginWatcher;
|
||||||
QHash<Utils::QtcProcess *, Utils::FilePath> m_runningQmldumps;
|
QHash<Utils::QtcProcess *, Utils::FilePath> m_runningQmldumps;
|
||||||
QList<Plugin> m_plugins;
|
QList<Plugin> m_plugins;
|
||||||
QHash<QString, int> m_libraryToPluginIndex;
|
QHash<Utils::FilePath, int> m_libraryToPluginIndex;
|
||||||
QHash<QString, QmlJS::ModelManagerInterface::ProjectInfo> m_qtToInfo;
|
QHash<QString, QmlJS::ModelManagerInterface::ProjectInfo> m_qtToInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user