clang
22.0.0git
include
clang
Tooling
Refactoring
Extract
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_REFACTORING_EXTRACT_EXTRACT_H
10
#define LLVM_CLANG_TOOLING_REFACTORING_EXTRACT_EXTRACT_H
11
12
#include "
clang/Tooling/Refactoring/ASTSelection.h
"
13
#include "
clang/Tooling/Refactoring/RefactoringActionRules.h
"
14
#include <optional>
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.
21
class
ExtractFunction final :
public
SourceChangeRefactoringRule
{
22
public
:
23
/// Initiates the extract function refactoring operation.
24
///
25
/// \param Code The selected set of statements.
26
/// \param DeclName The name of the extract function. If None,
27
/// "extracted" is used.
28
static
Expected<ExtractFunction>
29
initiate
(
RefactoringRuleContext
&Context,
CodeRangeASTSelection
Code,
30
std::optional<std::string> DeclName);
31
32
static
const
RefactoringDescriptor
&
describe
();
33
34
private
:
35
ExtractFunction(
CodeRangeASTSelection
Code,
36
std::optional<std::string> DeclName)
37
: Code(std::move(Code)),
38
DeclName(DeclName ? std::move(*DeclName) :
"extracted"
) {}
39
40
Expected<AtomicChanges>
41
createSourceReplacements(
RefactoringRuleContext
&Context)
override
;
42
43
CodeRangeASTSelection
Code;
44
45
// FIXME: Account for naming collisions:
46
// - error when name is specified by user.
47
// - rename to "extractedN" when name is implicit.
48
std::string DeclName;
49
};
50
51
}
// end namespace tooling
52
}
// end namespace clang
53
54
#endif
// LLVM_CLANG_TOOLING_REFACTORING_EXTRACT_EXTRACT_H
ASTSelection.h
RefactoringActionRules.h
clang::tooling::CodeRangeASTSelection
An AST selection value that corresponds to a selection of a set of statements that belong to one body...
Definition
ASTSelection.h:96
clang::tooling::ExtractFunction::initiate
static Expected< ExtractFunction > initiate(RefactoringRuleContext &Context, CodeRangeASTSelection Code, std::optional< std::string > DeclName)
Initiates the extract function refactoring operation.
Definition
Extract.cpp:70
clang::tooling::ExtractFunction::describe
static const RefactoringDescriptor & describe()
Definition
Extract.cpp:60
clang::tooling::RefactoringRuleContext
The refactoring rule context stores all of the inputs that might be needed by a refactoring action ru...
Definition
RefactoringRuleContext.h:33
clang::tooling::SourceChangeRefactoringRule
A type of refactoring action rule that produces source replacements in the form of atomic changes.
Definition
RefactoringActionRules.h:52
llvm::Expected
Definition
LLVM.h:37
clang::tooling
Definition
AllTUsExecution.h:22
clang
The JSON file list parser is used to communicate input to InstallAPI.
Definition
CalledOnceCheck.h:17
clang::tooling::RefactoringDescriptor
Definition
RefactoringActionRule.h:22
Generated on
for clang by
1.14.0