Documentation
¶
Index ¶
Constants ¶
const ( TitleDelimiter = "### TITLE ###" DocumentDelimiter = "### DOCUMENT ###" ChangeDelimiter = "### CHANGE ###" CompletionDelimiter = "### COMPLETION" // "### COMPLETION 0:0 ###" CodeActionDelimiter = "### CODE_ACTION" // "### CODE_ACTION 0:0 0:0 ###" HoverDelimiter = "### HOVER" // "### HOVER 0:0 ###" DefinitionDelimiter = "### DEFINITION" // "### DEFINITION 0:0 ###" DocumentSymbolDelimiter = "### DOCUMENT_SYMBOL" // "### DOCUMENT_SYMBOL ###" ReferencesDelimiter = "### REFERENCES" // "### REFERENCES 0:0 [decl] ###" RenameDelimiter = "### RENAME" // "### RENAME 0:0 newName ###" SemanticTokensDelimiter = "### SEMANTIC_TOKENS" // "### SEMANTIC_TOKENS ###" StdoutDelimiter = "### STDOUT ###" )
Action delimiters. Each request-shaped action has its own header because the LSP wire methods take different parameter shapes - trying to overload one delimiter would make the snap files harder to read than the small constant table here. Headers that carry no position/range trail with just "###"; positioned ones embed "line:char [line:char]" before the closing "###".
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run(tc *SnapshotCase) (string, error)
Run executes a single snapshot test case against a real in-process server. It handles the full LSP lifecycle: initialization, didOpen, actions, and shutdown. Returns the normalized JSON output of all server messages after the init handshake.
func WriteSnapshotFile ¶
func WriteSnapshotFile(path string, cases []SnapshotCase) error
WriteSnapshotFile writes test cases back to a .snap file.
Types ¶
type Action ¶
type Action struct {
Type ActionType
Content string // For CHANGE: new document text
Position *lsp.Pos // For COMPLETION / HOVER / DEFINITION / REFERENCES / RENAME
Range *lsp.Range // For CODE_ACTION: selected range
IncludeDeclaration bool // For REFERENCES: matches LSP context flag
NewName string // For RENAME: the rename target name
}
Action carries one snapshot action's parameters. Different ActionTypes use different sub-fields; the omitted fields are just left zero. We don't bother with a discriminated-union because each Action is short-lived and the fields are small.
type ActionType ¶
type ActionType int
const ( ActionChange ActionType = iota ActionCompletion ActionCodeAction ActionHover ActionDefinition ActionDocumentSymbol ActionReferences ActionRename ActionSemanticTokens )
type SnapshotCase ¶
func ParseSnapshotFile ¶
func ParseSnapshotFile(path string) ([]SnapshotCase, error)
ParseSnapshotFile reads a .snap file and extracts LSP test cases.
Format:
### TITLE ### <test name> ### DOCUMENT ### <rad source code> ### CHANGE ### (optional, repeatable) <new document text> ### COMPLETION 0:0 ### (optional, repeatable, header-only) ### CODE_ACTION 0:0 0:0 ### (optional, repeatable, header-only) ### STDOUT ### <expected server output as normalized JSON>