forked from qt-creator/qt-creator
CppEditor: Adapt include locations when renaming ui files
Fixes: QTCREATORBUG-14259 Change-Id: I5e8209338b531f0e65d85b423053bd19a8b47652 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -784,15 +784,31 @@ QSet<QString> Snapshot::allIncludesForDocument(const QString &fileName) const
|
||||
return result;
|
||||
}
|
||||
|
||||
QList<Snapshot::IncludeLocation> Snapshot::includeLocationsOfDocument(const QString &fileName) const
|
||||
QList<Snapshot::IncludeLocation> Snapshot::includeLocationsOfDocument(
|
||||
const QString &fileNameOrPath) const
|
||||
{
|
||||
const bool matchFullPath = Utils::FilePath::fromString(fileNameOrPath).isAbsolutePath();
|
||||
const auto isMatch = [&](const Document::Include &include) {
|
||||
if (matchFullPath)
|
||||
return include.resolvedFileName() == fileNameOrPath;
|
||||
return Utils::FilePath::fromString(include.resolvedFileName()).fileName() == fileNameOrPath;
|
||||
};
|
||||
QList<IncludeLocation> result;
|
||||
for (const_iterator cit = begin(), citEnd = end(); cit != citEnd; ++cit) {
|
||||
const Document::Ptr doc = cit.value();
|
||||
const QList<Document::Include> includeFiles = doc->resolvedIncludes();
|
||||
bool foundMatch = false;
|
||||
for (const Document::Include &includeFile : includeFiles) {
|
||||
if (includeFile.resolvedFileName() == fileName)
|
||||
if (isMatch(includeFile)) {
|
||||
foundMatch = true;
|
||||
result.push_back({doc, includeFile.line()});
|
||||
}
|
||||
}
|
||||
if (!matchFullPath && !foundMatch) {
|
||||
for (const auto &includeFile : cit.value()->unresolvedIncludes()) {
|
||||
if (includeFile.unresolvedFileName() == fileNameOrPath)
|
||||
result.push_back({doc, includeFile.line()});
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user