forked from qt-creator/qt-creator
CppEditor/LanguageClient: Do not rename in generated files by default
Fixes: QTCREATORBUG-29778 Change-Id: I4e56b6bda4e22c71995ab19ac6469ea88d22ee11 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -456,9 +456,10 @@ void ClangdFindReferences::Private::addSearchResultsForFile(const FilePath &file
|
||||
item.setContainingFunctionName(getContainingFunction(astPath, range).detail());
|
||||
|
||||
if (search->supportsReplace()) {
|
||||
const bool fileInSession = ProjectManager::projectForFile(file);
|
||||
item.setSelectForReplacement(fileInSession);
|
||||
if (fileInSession && file.baseName().compare(replacementData->oldSymbolName,
|
||||
const Node * const node = ProjectTree::nodeForFile(file);
|
||||
item.setSelectForReplacement(!ProjectManager::hasProjects()
|
||||
|| (node && !node->isGenerated()));
|
||||
if (node && file.baseName().compare(replacementData->oldSymbolName,
|
||||
Qt::CaseInsensitive) == 0) {
|
||||
replacementData->fileRenameCandidates << file;
|
||||
}
|
||||
|
||||
@@ -577,8 +577,9 @@ static void displayResults(SearchResult *search,
|
||||
item.setStyle(colorStyleForUsageType(result.tags));
|
||||
item.setUseTextEditorFont(true);
|
||||
if (search->supportsReplace()) {
|
||||
const Node * const node = ProjectTree::nodeForFile(result.path);
|
||||
item.setSelectForReplacement(!ProjectManager::hasProjects()
|
||||
|| ProjectManager::projectForFile(result.path));
|
||||
|| (node && !node->isGenerated()));
|
||||
}
|
||||
search->addResult(item);
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/projectmanager.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/mimeutils.h>
|
||||
@@ -308,10 +310,10 @@ Utils::SearchResultItems generateSearchResultItems(
|
||||
item.setFilePath(filePath);
|
||||
item.setUseTextEditorFont(true);
|
||||
if (renaming && limitToProjects) {
|
||||
const bool fileBelongsToProject = ProjectExplorer::ProjectManager::projectForFile(
|
||||
filePath);
|
||||
item.setSelectForReplacement(fileBelongsToProject);
|
||||
if (fileBelongsToProject
|
||||
const ProjectExplorer::Node * const node
|
||||
= ProjectExplorer::ProjectTree::nodeForFile(filePath);
|
||||
item.setSelectForReplacement(node && !node->isGenerated());
|
||||
if (node
|
||||
&& filePath.baseName().compare(oldSymbolName, Qt::CaseInsensitive) == 0) {
|
||||
fileRenameCandidates << filePath;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user