//===--- Extract.cpp - Clang refactoring library --------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// /// \file /// Implements the "extract" refactoring that can pull code into /// new functions, methods or declare new variables. /// //===----------------------------------------------------------------------===// #include "clang/Tooling/Refactoring/Extract/Extract.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprObjC.h" #include "clang/Rewrite/Core/Rewriter.h" #include "clang/Tooling/Refactoring/Extract/SourceExtraction.h" #include <optional> namespace clang { namespace tooling { namespace { /// Returns true if \c E is a simple literal or a reference expression that /// should not be extracted. bool isSimpleExpression(const Expr *E) { … } SourceLocation computeFunctionExtractionLocation(const Decl *D) { … } } // end anonymous namespace const RefactoringDescriptor &ExtractFunction::describe() { … } Expected<ExtractFunction> ExtractFunction::initiate(RefactoringRuleContext &Context, CodeRangeASTSelection Code, std::optional<std::string> DeclName) { … } // FIXME: Support C++ method extraction. // FIXME: Support Objective-C method extraction. Expected<AtomicChanges> ExtractFunction::createSourceReplacements(RefactoringRuleContext &Context) { … } } // end namespace tooling } // end namespace clang