#include "SourceCode.h"
#include "FuzzyMatch.h"
#include "Preamble.h"
#include "Protocol.h"
#include "support/Context.h"
#include "support/Logger.h"
#include "clang/Basic/FileEntry.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TokenKinds.h"
#include "clang/Driver/Types.h"
#include "clang/Format/Format.h"
#include "clang/Lex/Lexer.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/Token.h"
#include "clang/Tooling/Core/Replacement.h"
#include "clang/Tooling/Syntax/Tokens.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/xxhash.h"
#include <algorithm>
#include <cstddef>
#include <optional>
#include <string>
#include <vector>
namespace clang {
namespace clangd {
template <typename Callback>
static bool iterateCodepoints(llvm::StringRef U8, const Callback &CB) { … }
static size_t measureUnits(llvm::StringRef U8, int Units, OffsetEncoding Enc,
bool &Valid) { … }
Key<OffsetEncoding> kCurrentOffsetEncoding;
static OffsetEncoding lspEncoding() { … }
size_t lspLength(llvm::StringRef Code) { … }
llvm::Expected<size_t> positionToOffset(llvm::StringRef Code, Position P,
bool AllowColumnsBeyondLineLength) { … }
Position offsetToPosition(llvm::StringRef Code, size_t Offset) { … }
Position sourceLocToPosition(const SourceManager &SM, SourceLocation Loc) { … }
bool isSpelledInSource(SourceLocation Loc, const SourceManager &SM) { … }
bool isValidFileRange(const SourceManager &Mgr, SourceRange R) { … }
SourceLocation includeHashLoc(FileID IncludedFile, const SourceManager &SM) { … }
static unsigned getTokenLengthAtLoc(SourceLocation Loc, const SourceManager &SM,
const LangOptions &LangOpts) { … }
static SourceLocation getLocForTokenEnd(SourceLocation BeginLoc,
const SourceManager &SM,
const LangOptions &LangOpts) { … }
static SourceLocation getLocForTokenBegin(SourceLocation EndLoc,
const SourceManager &SM,
const LangOptions &LangOpts) { … }
static SourceRange toTokenRange(CharSourceRange Range, const SourceManager &SM,
const LangOptions &LangOpts) { … }
static SourceRange unionTokenRange(SourceRange R1, SourceRange R2,
const SourceManager &SM,
const LangOptions &LangOpts) { … }
static SourceRange rangeInCommonFile(SourceRange R, const SourceManager &SM,
const LangOptions &LangOpts) { … }
static SourceRange
getExpansionTokenRangeInSameFile(SourceLocation Loc, const SourceManager &SM,
const LangOptions &LangOpts) { … }
static SourceRange getTokenFileRange(SourceLocation Loc,
const SourceManager &SM,
const LangOptions &LangOpts) { … }
bool isInsideMainFile(SourceLocation Loc, const SourceManager &SM) { … }
std::optional<SourceRange> toHalfOpenFileRange(const SourceManager &SM,
const LangOptions &LangOpts,
SourceRange R) { … }
llvm::StringRef toSourceCode(const SourceManager &SM, SourceRange R) { … }
llvm::Expected<SourceLocation> sourceLocationInMainFile(const SourceManager &SM,
Position P) { … }
Range halfOpenToRange(const SourceManager &SM, CharSourceRange R) { … }
void unionRanges(Range &A, Range B) { … }
std::pair<size_t, size_t> offsetToClangLineColumn(llvm::StringRef Code,
size_t Offset) { … }
std::pair<StringRef, StringRef> splitQualifiedName(StringRef QName) { … }
TextEdit replacementToEdit(llvm::StringRef Code,
const tooling::Replacement &R) { … }
std::vector<TextEdit> replacementsToEdits(llvm::StringRef Code,
const tooling::Replacements &Repls) { … }
std::optional<std::string> getCanonicalPath(const FileEntryRef F,
FileManager &FileMgr) { … }
TextEdit toTextEdit(const FixItHint &FixIt, const SourceManager &M,
const LangOptions &L) { … }
FileDigest digest(llvm::StringRef Content) { … }
std::optional<FileDigest> digestFile(const SourceManager &SM, FileID FID) { … }
format::FormatStyle getFormatStyleForFile(llvm::StringRef File,
llvm::StringRef Content,
const ThreadsafeFS &TFS,
bool FormatFile) { … }
llvm::Expected<tooling::Replacements>
cleanupAndFormat(StringRef Code, const tooling::Replacements &Replaces,
const format::FormatStyle &Style) { … }
static void
lex(llvm::StringRef Code, const LangOptions &LangOpts,
llvm::function_ref<void(const syntax::Token &, const SourceManager &SM)>
Action) { … }
llvm::StringMap<unsigned> collectIdentifiers(llvm::StringRef Content,
const format::FormatStyle &Style) { … }
std::vector<Range> collectIdentifierRanges(llvm::StringRef Identifier,
llvm::StringRef Content,
const LangOptions &LangOpts) { … }
bool isKeyword(llvm::StringRef NewName, const LangOptions &LangOpts) { … }
namespace {
struct NamespaceEvent { … };
void parseNamespaceEvents(llvm::StringRef Code, const LangOptions &LangOpts,
llvm::function_ref<void(NamespaceEvent)> Callback) { … }
llvm::SmallVector<llvm::StringRef> ancestorNamespaces(llvm::StringRef NS) { … }
bool isMainFile(llvm::StringRef FileName, const SourceManager &SM) { … }
}
std::vector<std::string> visibleNamespaces(llvm::StringRef Code,
const LangOptions &LangOpts) { … }
llvm::StringSet<> collectWords(llvm::StringRef Content) { … }
static bool isLikelyIdentifier(llvm::StringRef Word, llvm::StringRef Before,
llvm::StringRef After) { … }
std::optional<SpelledWord> SpelledWord::touching(SourceLocation SpelledLoc,
const syntax::TokenBuffer &TB,
const LangOptions &LangOpts) { … }
std::optional<DefinedMacro> locateMacroAt(const syntax::Token &SpelledTok,
Preprocessor &PP) { … }
llvm::Expected<std::string> Edit::apply() const { … }
std::vector<TextEdit> Edit::asTextEdits() const { … }
bool Edit::canApplyTo(llvm::StringRef Code) const { … }
llvm::Error reformatEdit(Edit &E, const format::FormatStyle &Style) { … }
static void inferFinalNewline(llvm::Expected<size_t> &Err,
std::string &Contents, const Position &Pos) { … }
llvm::Error applyChange(std::string &Contents,
const TextDocumentContentChangeEvent &Change) { … }
EligibleRegion getEligiblePoints(llvm::StringRef Code,
llvm::StringRef FullyQualifiedName,
const LangOptions &LangOpts) { … }
bool isHeaderFile(llvm::StringRef FileName,
std::optional<LangOptions> LangOpts) { … }
bool isProtoFile(SourceLocation Loc, const SourceManager &SM) { … }
SourceLocation translatePreamblePatchLocation(SourceLocation Loc,
const SourceManager &SM) { … }
clangd::Range rangeTillEOL(llvm::StringRef Code, unsigned HashOffset) { … }
}
}