clang  10.0.0svn
Extract.h
Go to the documentation of this file.
1 //===--- Extract.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 #ifndef LLVM_CLANG_TOOLING_REFACTOR_EXTRACT_EXTRACT_H
10 #define LLVM_CLANG_TOOLING_REFACTOR_EXTRACT_EXTRACT_H
11 
14 
15 namespace clang {
16 namespace tooling {
17 
18 /// An "Extract Function" refactoring moves code into a new function that's
19 /// then called from the place where the original code was.
21 public:
22  /// Initiates the extract function refactoring operation.
23  ///
24  /// \param Code The selected set of statements.
25  /// \param DeclName The name name of the extract function. If None,
26  /// "extracted" is used.
29  Optional<std::string> DeclName);
30 
31  static const RefactoringDescriptor &describe();
32 
33 private:
35  : Code(std::move(Code)),
36  DeclName(DeclName ? std::move(*DeclName) : "extracted") {}
37 
39  createSourceReplacements(RefactoringRuleContext &Context) override;
40 
42 
43  // FIXME: Account for naming collisions:
44  // - error when name is specified by user.
45  // - rename to "extractedN" when name is implicit.
46  std::string DeclName;
47 };
48 
49 } // end namespace tooling
50 } // end namespace clang
51 
52 #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:20
An AST selection value that corresponds to a selection of a set of statements that belong to one body...
Definition: ASTSelection.h:94
Dataflow Directional Tag Classes.
static const RefactoringDescriptor & describe()
Definition: Extract.cpp:59
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:69