CMakePM: Fix "cm" and "cmo" locator filters

For "cm" (CMake Build) display all targets, including utility targets
like "all", "clean", or "<target>_lupdate" and "<target>_lrelease".

For "cmo" (CMake Open) display only the "real" targets, targets that are
not utility targets and have a backtrace from CMake File-API.

Fixes: QTCREATORBUG-29946
Change-Id: Ica53f4d38bd0c301b6dbfe0754e53c52d1b8d378
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Cristian Adam
2023-12-19 19:34:18 +01:00
parent 1ce56fe0b4
commit 13efeb4c23

View File

@@ -48,10 +48,6 @@ static LocatorMatcherTasks cmakeMatchers(const BuildAcceptor &acceptor)
continue;
const int index = target.title.indexOf(input, 0, Qt::CaseInsensitive);
if (index >= 0) {
const FilePath path = target.backtrace.isEmpty()
? cmakeProject->projectFilePath()
: target.backtrace.last().path;
const int line = target.backtrace.isEmpty() ? 0 : target.backtrace.last().line;
const FilePath projectPath = cmakeProject->projectFilePath();
const QString displayName = target.title;
LocatorFilterEntry entry;
@@ -62,11 +58,20 @@ static LocatorMatcherTasks cmakeMatchers(const BuildAcceptor &acceptor)
return AcceptResult();
};
}
entry.linkForEditor = {path, line};
entry.extraInfo = path.shortNativePath();
bool realTarget = false;
if (!target.backtrace.isEmpty() && target.targetType != UtilityType) {
const FilePath path = target.backtrace.last().path;
const int line = target.backtrace.last().line;
entry.linkForEditor = {path, line};
entry.extraInfo = path.shortNativePath();
realTarget = true;
} else {
entry.extraInfo = projectPath.shortNativePath();
}
entry.highlightInfo = {index, int(input.length())};
entry.filePath = cmakeProject->projectFilePath();
entries.append(entry);
if (acceptor || realTarget)
entries.append(entry);
}
}
}