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());
|
item.setContainingFunctionName(getContainingFunction(astPath, range).detail());
|
||||||
|
|
||||||
if (search->supportsReplace()) {
|
if (search->supportsReplace()) {
|
||||||
const bool fileInSession = ProjectManager::projectForFile(file);
|
const Node * const node = ProjectTree::nodeForFile(file);
|
||||||
item.setSelectForReplacement(fileInSession);
|
item.setSelectForReplacement(!ProjectManager::hasProjects()
|
||||||
if (fileInSession && file.baseName().compare(replacementData->oldSymbolName,
|
|| (node && !node->isGenerated()));
|
||||||
|
if (node && file.baseName().compare(replacementData->oldSymbolName,
|
||||||
Qt::CaseInsensitive) == 0) {
|
Qt::CaseInsensitive) == 0) {
|
||||||
replacementData->fileRenameCandidates << file;
|
replacementData->fileRenameCandidates << file;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -577,8 +577,9 @@ static void displayResults(SearchResult *search,
|
|||||||
item.setStyle(colorStyleForUsageType(result.tags));
|
item.setStyle(colorStyleForUsageType(result.tags));
|
||||||
item.setUseTextEditorFont(true);
|
item.setUseTextEditorFont(true);
|
||||||
if (search->supportsReplace()) {
|
if (search->supportsReplace()) {
|
||||||
|
const Node * const node = ProjectTree::nodeForFile(result.path);
|
||||||
item.setSelectForReplacement(!ProjectManager::hasProjects()
|
item.setSelectForReplacement(!ProjectManager::hasProjects()
|
||||||
|| ProjectManager::projectForFile(result.path));
|
|| (node && !node->isGenerated()));
|
||||||
}
|
}
|
||||||
search->addResult(item);
|
search->addResult(item);
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/projectmanager.h>
|
#include <projectexplorer/projectmanager.h>
|
||||||
|
#include <projectexplorer/projectnodes.h>
|
||||||
|
#include <projectexplorer/projecttree.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/mimeutils.h>
|
#include <utils/mimeutils.h>
|
||||||
@@ -308,10 +310,10 @@ Utils::SearchResultItems generateSearchResultItems(
|
|||||||
item.setFilePath(filePath);
|
item.setFilePath(filePath);
|
||||||
item.setUseTextEditorFont(true);
|
item.setUseTextEditorFont(true);
|
||||||
if (renaming && limitToProjects) {
|
if (renaming && limitToProjects) {
|
||||||
const bool fileBelongsToProject = ProjectExplorer::ProjectManager::projectForFile(
|
const ProjectExplorer::Node * const node
|
||||||
filePath);
|
= ProjectExplorer::ProjectTree::nodeForFile(filePath);
|
||||||
item.setSelectForReplacement(fileBelongsToProject);
|
item.setSelectForReplacement(node && !node->isGenerated());
|
||||||
if (fileBelongsToProject
|
if (node
|
||||||
&& filePath.baseName().compare(oldSymbolName, Qt::CaseInsensitive) == 0) {
|
&& filePath.baseName().compare(oldSymbolName, Qt::CaseInsensitive) == 0) {
|
||||||
fileRenameCandidates << filePath;
|
fileRenameCandidates << filePath;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user