clang  6.0.0svn
Extract.h
Go to the documentation of this file.
1 //===--- Extract.h - Clang refactoring library ----------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_TOOLING_REFACTOR_EXTRACT_EXTRACT_H
11 #define LLVM_CLANG_TOOLING_REFACTOR_EXTRACT_EXTRACT_H
12 
15 
16 namespace clang {
17 namespace tooling {
18 
19 /// An "Extract Function" refactoring moves code into a new function that's
20 /// then called from the place where the original code was.
22 public:
23  /// Initiates the extract function refactoring operation.
24  ///
25  /// \param Code The selected set of statements.
26  /// \param DeclName The name name of the extract function. If None,
27  /// "extracted" is used.
30  Optional<std::string> DeclName);
31 
32  static const RefactoringDescriptor &describe();
33 
34 private:
36  : Code(std::move(Code)),
37  DeclName(DeclName ? std::move(*DeclName) : "extracted") {}
38 
40  createSourceReplacements(RefactoringRuleContext &Context) override;
41 
43 
44  // FIXME: Account for naming collisions:
45  // - error when name is specified by user.
46  // - rename to "extractedN" when name is implicit.
47  std::string DeclName;
48 };
49 
50 } // end namespace tooling
51 } // end namespace clang
52 
53 #endif // LLVM_CLANG_TOOLING_REFACTOR_EXTRACT_EXTRACT_H
The refactoring rule context stores all of the inputs that might be needed by a refactoring action ru...
An "Extract Function" refactoring moves code into a new function that&#39;s then called from the place wh...
Definition: Extract.h:21
An AST selection value that corresponds to a selection of a set of statements that belong to one body...
Definition: ASTSelection.h:95
Dataflow Directional Tag Classes.
static const RefactoringDescriptor & describe()
Definition: Extract.cpp:60
A type of refactoring action rule that produces source replacements in the form of atomic changes...
static Expected< ExtractFunction > initiate(RefactoringRuleContext &Context, CodeRangeASTSelection Code, Optional< std::string > DeclName)
Initiates the extract function refactoring operation.
Definition: Extract.cpp:70