Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | pmbaty | 1 | //===--- USRFindingAction.h - Clang refactoring library -------------------===// |
2 | // |
||
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
||
4 | // See https://llvm.org/LICENSE.txt for license information. |
||
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
||
6 | // |
||
7 | //===----------------------------------------------------------------------===// |
||
8 | /// |
||
9 | /// \file |
||
10 | /// Provides an action to find all relevant USRs at a point. |
||
11 | /// |
||
12 | //===----------------------------------------------------------------------===// |
||
13 | |||
14 | #ifndef LLVM_CLANG_TOOLING_REFACTORING_RENAME_USRFINDINGACTION_H |
||
15 | #define LLVM_CLANG_TOOLING_REFACTORING_RENAME_USRFINDINGACTION_H |
||
16 | |||
17 | #include "clang/Basic/LLVM.h" |
||
18 | #include "llvm/ADT/ArrayRef.h" |
||
19 | |||
20 | #include <string> |
||
21 | #include <vector> |
||
22 | |||
23 | namespace clang { |
||
24 | class ASTConsumer; |
||
25 | class ASTContext; |
||
26 | class NamedDecl; |
||
27 | |||
28 | namespace tooling { |
||
29 | |||
30 | /// Returns the canonical declaration that best represents a symbol that can be |
||
31 | /// renamed. |
||
32 | /// |
||
33 | /// The following canonicalization rules are currently used: |
||
34 | /// |
||
35 | /// - A constructor is canonicalized to its class. |
||
36 | /// - A destructor is canonicalized to its class. |
||
37 | const NamedDecl *getCanonicalSymbolDeclaration(const NamedDecl *FoundDecl); |
||
38 | |||
39 | /// Returns the set of USRs that correspond to the given declaration. |
||
40 | std::vector<std::string> getUSRsForDeclaration(const NamedDecl *ND, |
||
41 | ASTContext &Context); |
||
42 | |||
43 | struct USRFindingAction { |
||
44 | USRFindingAction(ArrayRef<unsigned> SymbolOffsets, |
||
45 | ArrayRef<std::string> QualifiedNames, bool Force) |
||
46 | : SymbolOffsets(SymbolOffsets), QualifiedNames(QualifiedNames), |
||
47 | ErrorOccurred(false), Force(Force) {} |
||
48 | std::unique_ptr<ASTConsumer> newASTConsumer(); |
||
49 | |||
50 | ArrayRef<std::string> getUSRSpellings() { return SpellingNames; } |
||
51 | ArrayRef<std::vector<std::string>> getUSRList() { return USRList; } |
||
52 | bool errorOccurred() { return ErrorOccurred; } |
||
53 | |||
54 | private: |
||
55 | std::vector<unsigned> SymbolOffsets; |
||
56 | std::vector<std::string> QualifiedNames; |
||
57 | std::vector<std::string> SpellingNames; |
||
58 | std::vector<std::vector<std::string>> USRList; |
||
59 | bool ErrorOccurred; |
||
60 | bool Force; |
||
61 | }; |
||
62 | |||
63 | } // end namespace tooling |
||
64 | } // end namespace clang |
||
65 | |||
66 | #endif // LLVM_CLANG_TOOLING_REFACTORING_RENAME_USRFINDINGACTION_H |