src/lsp/main.cpp

src/lsp/main.cpp

file · Source (opens in a new tab)

No documentation comment.

Namespaces

Types

Members

analyzeDiagnostics

public · function · Source (opens in a new tab)

llvm::json::Array sun::lsp::analyzeDiagnostics(const OpenDocument &document)

Analyzes the current document text and collects compiler diagnostics.

Related: OpenDocument

appendDiagnostic

public · function · Source (opens in a new tab)

void sun::lsp::appendDiagnostic(llvm::json::Array &diagnostics, const OpenDocument &document, const std::string &message, const std::optional< sun::support::Position > &location, int severity, const std::string &knownSourceLine="")

Add one diagnostic for a message and the place it points at.

A location in this document is marked where it happened; one in another file (a manifest sibling, or a library body instantiated from a bundle) is shown at the top of this document, naming where it came from.

Related: OpenDocument, sun::support::Position

computeSemanticTokens

public · function · Source (opens in a new tab)

std::vector< int > sun::lsp::computeSemanticTokens(const std::string &source)

Compute semantic tokens for a document Returns encoded token data as per LSP spec: [deltaLine, deltaStartChar, length, tokenType, tokenModifiers]...

getAnalyzedDocument

public · function · Source (opens in a new tab)

const AnalyzedDocument * sun::lsp::getAnalyzedDocument(const OpenDocument &document)

Analyzed tree for the document's current text, or null when it cannot be parsed.

Analysis errors keep the partial tree: everything typed before the error still answers hover requests.

Related: AnalyzedDocument, OpenDocument

main

public · function · Source (opens in a new tab)

int main()

Reads editor requests and runs the Sun language server message loop.

makePosition

public · function · Source (opens in a new tab)

llvm::json::Object sun::lsp::makePosition(int line, int character)

Builds a JSON source position for the language server protocol.

makeRange

public · function · Source (opens in a new tab)

llvm::json::Object sun::lsp::makeRange(int startLine, int startCharacter, int endLine, int endCharacter)

Builds a JSON source range for the language server protocol.

pathToUri

public · function · Source (opens in a new tab)

std::string sun::lsp::pathToUri(const std::string &path)

file:// URI for an absolute path; bytes outside the unreserved set are percent-encoded (the inverse of uriToPath)

percentDecode

public · function · Source (opens in a new tab)

std::string sun::lsp::percentDecode(std::string_view encoded)

Decodes percent-escaped bytes in a URI component.

publishDiagnostics

public · function · Source (opens in a new tab)

void sun::lsp::publishDiagnostics(const std::string &uri, llvm::json::Array diagnostics, int version)

Notifies the editor of diagnostics for a specific document version.

readMessageBody

public · function · Source (opens in a new tab)

std::optional< std::string > sun::lsp::readMessageBody()

Reads the next framed language server message from standard input.

sendErrorResponse

public · function · Source (opens in a new tab)

void sun::lsp::sendErrorResponse(const llvm::json::Value &id, int code, const std::string &message)

Sends a JSON-RPC error response with its code and message.

sendResponse

public · function · Source (opens in a new tab)

void sun::lsp::sendResponse(const llvm::json::Value &id, llvm::json::Value result)

Sends a successful JSON-RPC response for the supplied request identifier.

startsWith

public · function · Source (opens in a new tab)

bool sun::lsp::startsWith(const std::string &text, const std::string &prefix)

Reports whether text begins with the supplied prefix.

toJsonPayload

public · function · Source (opens in a new tab)

std::string sun::lsp::toJsonPayload(llvm::json::Value value)

Serializes a JSON value for a language server message.

trimCR

public · function · Source (opens in a new tab)

std::string sun::lsp::trimCR(std::string line)

Removes the carriage return from a protocol header line.

uriToPath

public · function · Source (opens in a new tab)

std::string sun::lsp::uriToPath(const std::string &uri)

Converts a file URI to a filesystem path.

writeLSPMessage

public · function · Source (opens in a new tab)

void sun::lsp::writeLSPMessage(llvm::json::Value value)

Writes a JSON message with language server framing headers.

analyzedDocuments

public · variable · static · Source (opens in a new tab)

std::unordered_map<std::string, AnalyzedDocument> sun::lsp::analyzedDocuments

No documentation comment.

Related: AnalyzedDocument