From: Haojian Wu Date: Tue, 25 Jun 2019 08:43:17 +0000 (+0000) Subject: [clangd] Narrow rename to local symbols. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=075738f9875fc9369e9ba464d9cf81ab6e892cf6;p=clang [clangd] Narrow rename to local symbols. Summary: Previously, we performed rename for all kinds of symbols (local, global). This patch narrows the scope by only renaming symbols not being used outside of the main file (with index asisitance). Renaming global symbols is not supported at the moment (return an error). Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63426 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364283 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Tooling/Refactoring/Rename/RenamingAction.h b/include/clang/Tooling/Refactoring/Rename/RenamingAction.h index 315ce99ebc..b04bc3e2d2 100644 --- a/include/clang/Tooling/Refactoring/Rename/RenamingAction.h +++ b/include/clang/Tooling/Refactoring/Rename/RenamingAction.h @@ -54,6 +54,8 @@ public: static const RefactoringDescriptor &describe(); + const NamedDecl *getRenameDecl() const; + private: RenameOccurrences(const NamedDecl *ND, std::string NewName) : ND(ND), NewName(std::move(NewName)) {} diff --git a/lib/Tooling/Refactoring/Rename/RenamingAction.cpp b/lib/Tooling/Refactoring/Rename/RenamingAction.cpp index 3a9c477210..1649513a07 100644 --- a/lib/Tooling/Refactoring/Rename/RenamingAction.cpp +++ b/lib/Tooling/Refactoring/Rename/RenamingAction.cpp @@ -74,6 +74,8 @@ RenameOccurrences::initiate(RefactoringRuleContext &Context, std::move(NewName)); } +const NamedDecl *RenameOccurrences::getRenameDecl() const { return ND; } + Expected RenameOccurrences::createSourceReplacements(RefactoringRuleContext &Context) { Expected Occurrences = findSymbolOccurrences(ND, Context);