| 113 | } |
| 114 | |
| 115 | QStringList QmlJS::Cache::getFileNames(const QFileInfoList& fileInfos) |
| 116 | { |
| 117 | QStringList result; |
| 118 | |
| 119 | for (const QFileInfo& fileInfo : fileInfos) { |
| 120 | QString filePath = fileInfo.canonicalFilePath(); |
| 121 | |
| 122 | // If the module directory contains a plugins.qmltypes files, use it |
| 123 | // and skip everything else |
| 124 | if (filePath.endsWith(QLatin1String("plugins.qmltypes"))) { |
| 125 | return QStringList() << filePath; |
| 126 | } else if (fileInfo.dir().exists(QStringLiteral("plugins.qmltypes"))) { |
| 127 | return {fileInfo.dir().filePath(QStringLiteral("plugins.qmltypes"))}; |
| 128 | } |
| 129 | |
| 130 | // Non-so files don't need any treatment |
| 131 | if (!filePath.endsWith(QLatin1String(".so"))) { |
| 132 | result.append(filePath); |
| 133 | continue; |
| 134 | } |
| 135 | |
| 136 | // Use the cache to speed-up reparses |
| 137 | { |
| 138 | QMutexLocker lock(&m_mutex); |
| 139 | |
| 140 | const auto modulePathIt = m_modulePaths.constFind(filePath); |
| 141 | if (modulePathIt != m_modulePaths.constEnd()) { |
| 142 | const QString& cachedFilePath = *modulePathIt; |
| 143 | |
| 144 | if (!cachedFilePath.isEmpty()) { |
| 145 | result.append(cachedFilePath); |
| 146 | } |
| 147 | |
| 148 | continue; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // Locate an existing dump of the file |
| 153 | QString dumpFile = QStringLiteral("kdevqmljssupport/%1.qml").arg( |
| 154 | QString::fromLatin1(QCryptographicHash::hash(filePath.toUtf8(), QCryptographicHash::Md5).toHex()) |
| 155 | ); |
| 156 | QString dumpPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, |
| 157 | dumpFile |
| 158 | ); |
| 159 | |
| 160 | if (!dumpPath.isEmpty()) { |
| 161 | QMutexLocker lock(&m_mutex); |
| 162 | |
| 163 | result.append(dumpPath); |
| 164 | m_modulePaths.insert(filePath, dumpPath); |
| 165 | continue; |
| 166 | } |
| 167 | |
| 168 | // Create a dump of the file |
| 169 | const QStringList args = {QStringLiteral("-noinstantiate"), QStringLiteral("-path"), filePath}; |
| 170 | |
| 171 | for (const PluginDumpExecutable& executable : std::as_const(m_pluginDumpExecutables)) { |
| 172 | QProcess qmlplugindump; |
no test coverage detected