clang-tools 20.0.0git
Namespaces | Functions | Variables
SourceCode.cpp File Reference
#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>

Go to the source code of this file.

Namespaces

namespace  clang
 ===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
 
namespace  clang::clangd
 FIXME: Skip testing on windows temporarily due to the different escaping code mode.
 

Functions

template<typename Callback >
static bool clang::clangd::iterateCodepoints (llvm::StringRef U8, const Callback &CB)
 
static size_t clang::clangd::measureUnits (llvm::StringRef U8, int Units, OffsetEncoding Enc, bool &Valid)
 
static OffsetEncoding clang::clangd::lspEncoding ()
 
size_t clang::clangd::lspLength (llvm::StringRef Code)
 
llvm::Expected< size_t > clang::clangd::positionToOffset (llvm::StringRef Code, Position P, bool AllowColumnsBeyondLineLength=true)
 Turn a [line, column] pair into an offset in Code.
 
Position clang::clangd::offsetToPosition (llvm::StringRef Code, size_t Offset)
 Turn an offset in Code into a [line, column] pair.
 
Position clang::clangd::sourceLocToPosition (const SourceManager &SM, SourceLocation Loc)
 Turn a SourceLocation into a [line, column] pair.
 
bool clang::clangd::isSpelledInSource (SourceLocation Loc, const SourceManager &SM)
 Returns true if the token at Loc is spelled in the source code.
 
bool clang::clangd::isValidFileRange (const SourceManager &Mgr, SourceRange R)
 Returns true iff all of the following conditions hold:
 
SourceLocation clang::clangd::includeHashLoc (FileID IncludedFile, const SourceManager &SM)
 Returns the #include location through which IncludedFIle was loaded.
 
static unsigned clang::clangd::getTokenLengthAtLoc (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
 
static SourceLocation clang::clangd::getLocForTokenEnd (SourceLocation BeginLoc, const SourceManager &SM, const LangOptions &LangOpts)
 
static SourceLocation clang::clangd::getLocForTokenBegin (SourceLocation EndLoc, const SourceManager &SM, const LangOptions &LangOpts)
 
static SourceRange clang::clangd::toTokenRange (CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts)
 
static SourceRange clang::clangd::unionTokenRange (SourceRange R1, SourceRange R2, const SourceManager &SM, const LangOptions &LangOpts)
 
static SourceRange clang::clangd::rangeInCommonFile (SourceRange R, const SourceManager &SM, const LangOptions &LangOpts)
 
static SourceRange clang::clangd::getExpansionTokenRangeInSameFile (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
 
static SourceRange clang::clangd::getTokenFileRange (SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
 
bool clang::clangd::isInsideMainFile (SourceLocation Loc, const SourceManager &SM)
 Returns true iff Loc is inside the main file.
 
std::optional< SourceRange > clang::clangd::toHalfOpenFileRange (const SourceManager &Mgr, const LangOptions &LangOpts, SourceRange R)
 Turns a token range into a half-open range and checks its correctness.
 
llvm::StringRef clang::clangd::toSourceCode (const SourceManager &SM, SourceRange R)
 Returns the source code covered by the source range.
 
llvm::Expected< SourceLocation > clang::clangd::sourceLocationInMainFile (const SourceManager &SM, Position P)
 Return the file location, corresponding to P.
 
Range clang::clangd::halfOpenToRange (const SourceManager &SM, CharSourceRange R)
 
void clang::clangd::unionRanges (Range &A, Range B)
 
std::pair< size_t, size_t > clang::clangd::offsetToClangLineColumn (llvm::StringRef Code, size_t Offset)
 
std::pair< StringRef, StringRef > clang::clangd::splitQualifiedName (StringRef QName)
 
TextEdit clang::clangd::replacementToEdit (llvm::StringRef Code, const tooling::Replacement &R)
 
std::vector< TextEdit > clang::clangd::replacementsToEdits (llvm::StringRef Code, const tooling::Replacements &Repls)
 
std::optional< std::string > clang::clangd::getCanonicalPath (const FileEntryRef F, FileManager &FileMgr)
 Get the canonical path of F.
 
TextEdit clang::clangd::toTextEdit (const FixItHint &FixIt, const SourceManager &M, const LangOptions &L)
 
FileDigest clang::clangd::digest (llvm::StringRef Content)
 
std::optional< FileDigest > clang::clangd::digestFile (const SourceManager &SM, FileID FID)
 
format::FormatStyle clang::clangd::getFormatStyleForFile (llvm::StringRef File, llvm::StringRef Content, const ThreadsafeFS &TFS, bool FormatFile)
 Choose the clang-format style we should apply to a certain file.
 
llvm::Expected< tooling::Replacements > clang::clangd::cleanupAndFormat (StringRef Code, const tooling::Replacements &Replaces, const format::FormatStyle &Style)
 Cleanup and format the given replacements.
 
static void clang::clangd::lex (llvm::StringRef Code, const LangOptions &LangOpts, llvm::function_ref< void(const syntax::Token &, const SourceManager &SM)> Action)
 
llvm::StringMap< unsigned > clang::clangd::collectIdentifiers (llvm::StringRef Content, const format::FormatStyle &Style)
 Collects identifiers with counts in the source code.
 
std::vector< Rangeclang::clangd::collectIdentifierRanges (llvm::StringRef Identifier, llvm::StringRef Content, const LangOptions &LangOpts)
 Collects all ranges of the given identifier in the source code.
 
bool clang::clangd::isKeyword (llvm::StringRef TokenName, const LangOptions &LangOpts)
 Return true if the TokenName is in the list of reversed keywords of the language.
 
std::vector< std::string > clang::clangd::visibleNamespaces (llvm::StringRef Code, const LangOptions &LangOpts)
 Heuristically determine namespaces visible at a point, without parsing Code.
 
llvm::StringSet clang::clangd::collectWords (llvm::StringRef Content)
 Collects words from the source code.
 
static bool clang::clangd::isLikelyIdentifier (llvm::StringRef Word, llvm::StringRef Before, llvm::StringRef After)
 
std::optional< DefinedMacro > clang::clangd::locateMacroAt (const syntax::Token &SpelledTok, Preprocessor &PP)
 Gets the macro referenced by SpelledTok.
 
llvm::Error clang::clangd::reformatEdit (Edit &E, const format::FormatStyle &Style)
 Formats the edits and code around it according to Style.
 
static void clang::clangd::inferFinalNewline (llvm::Expected< size_t > &Err, std::string &Contents, const Position &Pos)
 
llvm::Error clang::clangd::applyChange (std::string &Contents, const TextDocumentContentChangeEvent &Change)
 Apply an incremental update to a text document.
 
EligibleRegion clang::clangd::getEligiblePoints (llvm::StringRef Code, llvm::StringRef FullyQualifiedName, const LangOptions &LangOpts)
 Returns most eligible region to insert a definition for FullyQualifiedName in the Code.
 
bool clang::clangd::isHeaderFile (llvm::StringRef FileName, std::optional< LangOptions > LangOpts=std::nullopt)
 Infers whether this is a header from the FileName and LangOpts (if presents).
 
bool clang::clangd::isProtoFile (SourceLocation Loc, const SourceManager &SourceMgr)
 Returns true if the given location is in a generated protobuf file.
 
SourceLocation clang::clangd::translatePreamblePatchLocation (SourceLocation Loc, const SourceManager &SM)
 Translates locations inside preamble patch to their main-file equivalent using presumed locations.
 
clangd::Range clang::clangd::rangeTillEOL (llvm::StringRef Code, unsigned HashOffset)
 Returns the range starting at offset and spanning the whole line.
 

Variables

Key< OffsetEncoding > clang::clangd::kCurrentOffsetEncoding
 

Variable Documentation

◆ Payload

std::string Payload

◆ Pos

Position Pos

Definition at line 674 of file SourceCode.cpp.

◆ 

enum { ... } Trigger