]> granicus.if.org Git - clang/commitdiff
[clangd] Narrow rename to local symbols.
authorHaojian Wu <hokein@google.com>
Tue, 25 Jun 2019 08:43:17 +0000 (08:43 +0000)
committerHaojian Wu <hokein@google.com>
Tue, 25 Jun 2019 08:43:17 +0000 (08:43 +0000)
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

include/clang/Tooling/Refactoring/Rename/RenamingAction.h
lib/Tooling/Refactoring/Rename/RenamingAction.cpp

index 315ce99ebc61c9eff21210e31d260ef5c82b2915..b04bc3e2d202385a89d918140afb4080ba1b116c 100644 (file)
@@ -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)) {}
index 3a9c477210e947fa447f6633f4682eddd4a1fb11..1649513a077a23306185d512cd156571f7ea50d8 100644 (file)
@@ -74,6 +74,8 @@ RenameOccurrences::initiate(RefactoringRuleContext &Context,
                            std::move(NewName));
 }
 
+const NamedDecl *RenameOccurrences::getRenameDecl() const { return ND; }
+
 Expected<AtomicChanges>
 RenameOccurrences::createSourceReplacements(RefactoringRuleContext &Context) {
   Expected<SymbolOccurrences> Occurrences = findSymbolOccurrences(ND, Context);