9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_RENAME_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_REFACTOR_RENAME_H
14#include "clang/Basic/IdentifierTable.h"
15#include "clang/Basic/LangOptions.h"
16#include "llvm/ADT/SmallVector.h"
17#include "llvm/Support/Error.h"
48 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
FS =
nullptr;
96 llvm::StringRef InitialCode,
97 std::vector<SymbolRange> Occurrences,
98 llvm::ArrayRef<llvm::StringRef> NewNames);
110std::optional<std::vector<SymbolRange>>
112 std::vector<Range> Indexed,
const LangOptions &LangOpts,
113 std::optional<Selector> Selector);
121std::optional<std::vector<SymbolRange>>
130 ArrayRef<SymbolRange> Lexed,
131 ArrayRef<size_t> MappedIndex);
Stores and provides access to parsed AST.
Interface for symbol indexes that can be used for searching or matching symbols among a set of symbol...
llvm::StringMap< Edit > FileEdits
A mapping from absolute file path (the one used for accessing the underlying VFS) to edits.
llvm::Expected< Edit > buildRenameEdit(llvm::StringRef AbsFilePath, llvm::StringRef InitialCode, std::vector< SymbolRange > Occurrences, llvm::ArrayRef< llvm::StringRef > NewNames)
Generates rename edits that replaces all given occurrences with the NewName.
llvm::Expected< RenameResult > rename(const RenameInputs &RInputs)
Renames all occurrences of the symbol.
std::optional< std::vector< SymbolRange > > adjustRenameRanges(llvm::StringRef DraftCode, llvm::StringRef Identifier, std::vector< Range > Indexed, const LangOptions &LangOpts, std::optional< Selector > Selector)
Adjusts indexed occurrences to match the current state of the file.
size_t renameRangeAdjustmentCost(ArrayRef< Range > Indexed, ArrayRef< SymbolRange > Lexed, ArrayRef< size_t > MappedIndex)
Evaluates how good the mapped result is.
std::optional< std::vector< SymbolRange > > getMappedRanges(ArrayRef< Range > Indexed, ArrayRef< SymbolRange > Lexed)
Calculates the lexed occurrences that the given indexed occurrences map to.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
size_t LimitFiles
The maximum number of affected files (0 means no limit), only meaningful when AllowCrossFile = true.
bool WantFormat
If true, format the rename edits, only meaningful in ClangdServer layer.
bool RenameVirtual
Allow rename of virtual method hierarchies.
std::vector< Range > LocalChanges
Represents a symbol range where the symbol can potentially have multiple tokens.
friend bool operator==(const SymbolRange &LHS, const SymbolRange &RHS)
friend bool operator!=(const SymbolRange &LHS, const SymbolRange &RHS)
std::vector< Range > Ranges
Ranges for the tokens that make up the symbol's name.
friend bool operator<(const SymbolRange &LHS, const SymbolRange &RHS)
Range range() const
Returns the first range.