### Concrete LSP Request Examples Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification Provides concrete examples of LSP requests, illustrating how to query for folding ranges and hover information for a given file. The examples show the expected input parameters and the type of result returned. ```TypeScript request( 'file:///Users/dirkb/sample/test.ts', 'textDocument/foldingRange' ) -> FoldingRange[]; ``` ```TypeScript request( 'file:///Users/dirkb/sample/test.ts', { line: 10, character: 17 }, 'textDocument/hover' ) -> Hover; ``` -------------------------------- ### LSP Request Examples Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification Provides concrete examples of LSP requests, demonstrating how to call 'textDocument/foldingRange' and 'textDocument/hover' with different parameters. ```JSON-RPC request( 'file:///Users/dirkb/sample/test.ts', 'textDocument/foldingRange' ) -> FoldingRange[]; request( 'file:///Users/dirkb/sample/test.ts', { line: 10, character: 17 }, 'textDocument/hover' ) -> Hover; ``` -------------------------------- ### TypeScript package.json Example Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification An example of a `package.json` file used in a TypeScript project, defining project metadata such as name, version, description, main file, author, and license. ```JSON { "name": "lsif-ts-sample", "version": "1.0.0", "description": "", "main": "lib/index.js", "author": "MS", "license": "MIT" } ``` -------------------------------- ### TypeScript package.json Example Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification An example of a `package.json` file used in a TypeScript project, defining project metadata such as name, version, description, main file, author, and license. ```json { "name": "lsif-ts-sample", "version": "1.0.0", "description": "", "main": "lib/index.js", "author": "MS", "license": "MIT" } ``` -------------------------------- ### LSP Capabilities Example Source: https://microsoft.github.io/language-server-protocol/specifications/base/0.9/specification Illustrates the concept of capabilities in the Language Server Protocol, where clients and servers announce supported features. This example lists common capability identifiers used within the protocol. ```text callHierarchyProvider codeActionProvider codeLensProvider colorProvider completionProvider declarationProvider definitionProvider diagnosticProvider documentFormattingProvider documentHighlightProvider documentLinkProvider documentOnTypeFormattingProvider documentRangeFormattingProvider documentSymbolProvider executeCommandProvider experimental foldingRangeProvider general hoverProvider implementationProvider inlayHintProvider inlineValueProvider linkedEditingRangeProvider monikerProvider notebookDocument notebookDocumentSync positionEncoding referencesProvider renameProvider selectionRangeProvider semanticTokensProvider signatureHelpProvider textDocument textDocumentSync typeDefinitionProvider typeHierarchyProvider window workspace workspaceSymbolProvider ``` -------------------------------- ### LSP Request Examples Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.4.0/specification Provides concrete examples of LSP requests, demonstrating how URIs and optional positions are used to invoke specific methods and retrieve results. ```TypeScript request('file:///Users/dirkb/sample.ts', 'textDocument/foldingRange') -> FoldingRange[]; request('file:///Users/dirkb/sample.ts', { line: 10, character: 17 }, 'textDocument/hover') -> Hover; ``` -------------------------------- ### Example Semantic Token Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Provides an example of a single semantic token with its properties: line number, start character, length, token type, and modifiers. This illustrates the data structure for representing a token. ```JavaScript { line: 2, startChar: 5, length: 3, tokenType: "property", tokenModifiers: ["private", "static"] } ``` -------------------------------- ### Example JSON RPC for Registering Capability Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 An example JSON RPC message demonstrating how a server can dynamically register a client capability for the `textDocument/willSaveWaitUntil` feature, specifying a document selector for JavaScript files. ```JSON { "method": "client/registerCapability", "params": { "registrations": [ { "id": "79eee87c-c409-4664-8102-e03263673f6f", "method": "textDocument/willSaveWaitUntil", "registerOptions": { "documentSelector": [ { "language": "javascript" } ] } } ] } } ``` -------------------------------- ### Example Register Capability Request (JSON) Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 An example JSON RPC message demonstrating how to dynamically register for the 'textDocument/willSaveWaitUntil' feature for JavaScript documents. ```json { "method": "client/registerCapability", "params": { "registrations": [ { "id": "79eee87c-c409-4664-8102-e03263673f6f", "method": "textDocument/willSaveWaitUntil", "registerOptions": { "documentSelector": [ { "language": "javascript" } ] } } ] } } ``` -------------------------------- ### LSIF Source Vertex Example Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification An example of an LSIF 'source' vertex, which is a root element in an LSIF dump. It contains crucial information like the workspace root and repository details for resolving URIs and linking projects. ```JSON { "id": 2, "type": "vertex", "label": "source", "workspaceRoot": "file:///Users/dirkb/samples/ts-cascade", "repository": { "type": "git", "url": "git+https://github.com/samples/ts-cascade.git" } } ``` -------------------------------- ### Client Initiated Progress Request Parameters Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Example of a client sending a `textDocument/reference` request with a `workDoneToken` to enable progress reporting. ```JSON { "textDocument": { "uri": "file:///folder/file.ts" }, "position": { "line": 9, "character": 5 }, "context": { "includeDeclaration": true }, // The token used to report work done progress. "workDoneToken": "1d546990-40a3-4b77-b134-46622995f6ae" } ``` -------------------------------- ### LSP Base Protocol Message Structure Example Source: https://microsoft.github.io/language-server-protocol/specifications/base/0.9/specification An example demonstrating the structure of a message in the Language Server Protocol's Base Protocol. It shows the required 'Content-Length' header followed by the JSON-RPC payload. ```JSON Content-Length: ...\r\n \r\n { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { ... } } ``` -------------------------------- ### TypeScript Function Example Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification A simple TypeScript function declaration used as an example to illustrate hover behavior and range identification within the Language Server Protocol specifications. ```typescript function bar() { } ``` -------------------------------- ### TypeScript Interface and Class Example for textDocument/references Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification This TypeScript code defines an interface `I` with a method `foo`, and two classes `A` and `B` that implement this interface. It also includes usage examples where an instance of `I` and `B` call the `foo` method, demonstrating a more complex scenario for reference tracking. ```typescript interface I { foo(): void; } class A implements I { foo(): void { } } class B implements I { foo(): void { } } let i: I; i.foo(); let b: B; b.foo(); ``` -------------------------------- ### LSP Message Content Example (JSON) Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 An example of the content part of a Language Server Protocol message, demonstrating the JSON-RPC structure for a 'textDocument/didOpen' request. ```JSON { "jsonrpc": "2.0", "id": 1, "method": "textDocument/didOpen", "params": { ... } } ``` -------------------------------- ### Example Request with Partial Result Token Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Demonstrates a `textDocument/references` request that includes both `workDoneToken` and `partialResultToken` to signal support for progress reporting. ```json { "textDocument": { "uri": "file:///folder/file.ts" }, "position": { "line": 9, "character": 5 }, "context": { "includeDeclaration": true }, // The token used to report work done progress. "workDoneToken": "1d546990-40a3-4b77-b134-46622995f6ae", // The token used to report partial result progress. "partialResultToken": "5f6f349e-4f81-4a3b-afff-ee04bff96804" } ``` -------------------------------- ### Progress Notification for Client Initiated Progress Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Example of a server reporting progress using the `$/progress` notification with a `workDoneToken`. ```JSON { "token": "1d546990-40a3-4b77-b134-46622995f6ae", "value": { "kind": "begin", "title": "Finding references for A#foo", "cancellable": false, "message": "Processing file X.ts", "percentage": 0 } } ``` -------------------------------- ### LSP Request Examples Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification Demonstrates the structure of Language Server Protocol (LSP) requests, which can either take a URI and a method, or a URI, a position, and a method. These requests return specific results based on the method called. ```JSON request(uri, method) -> result request(uri, position, method) -> result ``` -------------------------------- ### TypeScript Example for Multiple Definitions Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification This TypeScript code illustrates a scenario with multiple definitions for an interface 'X'. When 'Go to Definition' is invoked on 'X' in 'let x: X', a dialog allows selection between different interface declarations. ```TypeScript interface X { foo(); } interface X { bar(); } let x: X; ``` -------------------------------- ### TypeScript Import Example Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification A TypeScript code snippet demonstrating the import of an external npm package ('mobx') and the usage of its types, such as `ObservableMap`. This illustrates how external symbols are referenced. ```typescript import * as mobx from 'mobx'; let map: mobx.ObservableMap = new mobx.ObservableMap(); ``` -------------------------------- ### TypeScript Example for Multiple Definitions Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification This TypeScript code demonstrates a scenario with multiple definitions for an interface 'X'. When performing 'Go to Definition' on 'X' in the variable declaration, a dialog allows selection between different interface definitions. ```typescript interface X { foo(); } interface X { bar(); } let x: X; ``` -------------------------------- ### TypeScript Code Example Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification A TypeScript code snippet demonstrating exported elements, including a function `func` and a class `Emitter` with private and public methods. This code serves as an example for LSIF moniker generation. ```TypeScript export function func(): void { } export class Emitter { private doEmit() { } public emit() { this.doEmit(); } } ``` -------------------------------- ### TypeScript Import Example Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification A TypeScript code snippet demonstrating the import of external symbols from the 'mobx' npm package, specifically `ObservableMap`. This illustrates how external dependencies are handled. ```TypeScript import * as mobx from 'mobx'; let map: mobx.ObservableMap = new mobx.ObservableMap(); ``` -------------------------------- ### TypeScript Code Example for textDocument/references Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification This code snippet demonstrates a simple TypeScript structure with two functions, `bar` and `foo`, where `foo` calls `bar`. This serves as a basis for illustrating how references are captured in the LSIF format. ```typescript function bar() { } function foo() { bar(); } ``` -------------------------------- ### TypeScript Interface and Class Example for References Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification This snippet demonstrates a TypeScript interface `I` with a method `foo`, and two classes `A` and `B` that implement this interface. It also shows variable declarations using the interface and class, and method calls, to illustrate complex reference scenarios. ```typescript interface I { foo(): void; } class A implements I { foo(): void { } } class B implements I { foo(): void { } } let i: I; i.foo(); let b: B; b.foo(); ``` -------------------------------- ### TypeScript Code Example for References Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification This snippet shows a simple TypeScript code structure with two functions, `bar` and `foo`, where `foo` calls `bar`. This is used to demonstrate how references are stored and represented in the Language Server Protocol. ```typescript function bar() { } function foo() { bar(); } ``` -------------------------------- ### TypeScript Example for Type Definition Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification A TypeScript code snippet demonstrating an interface `I` and its declaration, used as context for type definition requests in LSP. ```typescript interface I { foo(): void; } let i: I; ``` -------------------------------- ### Server Capability for References Provider Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Example of a server signaling support for work done progress by setting `workDoneProgress: true` in its capabilities. ```JSON { "referencesProvider": { "workDoneProgress": true } } ``` -------------------------------- ### TypeScript Example for Type Definition Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification A simple TypeScript interface and variable declaration used to demonstrate the type definition request in the Language Server Protocol. ```typescript interface I { foo(): void; } let i: I; ``` -------------------------------- ### TypeScript Example for Method Overriding and References Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification Demonstrates a TypeScript scenario with interface method overriding and how references are handled across different implementations. This code illustrates the complexity arising from multiple interface implementations and the need for efficient reference tracking. ```typescript interface I { foo(): void; } interface II { foo(): void; } class B implements I, II { foo(): void { } } let i: I; i.foo(); let b: B; b.foo(); ``` -------------------------------- ### TypeScript Example for Method Overriding and References Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification Demonstrates a TypeScript scenario with interface method overriding and how references are handled across different implementations. This code illustrates the complexity arising from multiple interface implementations and the need for efficient reference tracking. ```typescript interface I { foo(): void; } interface II { foo(): void; } class B implements I, II { foo(): void { } } let i: I; i.foo(); let b: B; b.foo(); ``` -------------------------------- ### Document Structure with ResultSet (LSIF) Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.4.0/specification Provides an example of LSIF output demonstrating the structure of a document, ranges, and their relationship to a ResultSet for consolidated request results. ```json { id: 1, type: "vertex", uri: "file:///Users/dirkb/sample.ts", languageId: "typescript" } { id: 2, type: "vertex", label: "resultSet" } { id: 3, type: "vertex", label: "range", start: { line: 0, character: 9}, end: { line: 0, character: 12 } } { id: 4, type: "edge", label: "contains", outV: 1, inVs: [3] } { id: 5, type: "edge", label: "next", outV: 3, inV: 2 } { id: 6, type: "vertex", label: "hoverResult", result: {"contents":[{"language":"typescript","value":"function bar(): void"},"" ] } } { id: 7, type: "edge", label: "textDocument/hover", outV: 2, inV: 6 } ``` -------------------------------- ### TypeScript Example for Type Definition Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.4.0/specification A TypeScript code snippet demonstrating an interface 'I' and its usage with a variable 'i'. This serves as input for generating type definition information. ```typescript interface I { foo(): void; } let i: I; ``` -------------------------------- ### TypeScript Export Example Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification Demonstrates exporting a function and a class from a TypeScript file. This code serves as the source for generating LSIF monikers. ```typescript export function func(): void { } export class Emitter { private doEmit() { } public emit() { this.doEmit(); } } ``` -------------------------------- ### TypeScript Example for Folding Range Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification A TypeScript code snippet demonstrating functions, used to illustrate the folding range request in the Language Server Protocol. ```typescript function hello() { console.log('Hello'); } function world() { console.log('world'); } function space() { console.log(' '); } hello();space();world(); ``` -------------------------------- ### TypeScript Example for Folding Ranges Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.4.0/specification A TypeScript code snippet containing multiple function definitions and calls, used to demonstrate the generation of folding ranges. ```typescript function hello() { console.log('Hello'); } function world() { console.log('world'); } function space() { console.log(' '); } hello();space();world(); ``` -------------------------------- ### TypeScript Example for textDocument/definition Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification This snippet shows a simple TypeScript function structure used to demonstrate the textDocument/definition request in the Language Server Protocol. It includes two functions, 'bar' and 'foo', where 'foo' calls 'bar'. ```typescript function bar() { } function foo() { bar(); } ``` -------------------------------- ### TypeScript Example for Folding Range Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification A TypeScript code snippet containing multiple function definitions and calls, used to demonstrate folding range capabilities in LSP. ```typescript function hello() { console.log('Hello'); } function world() { console.log('world'); } function space() { console.log(' '); } hello();space();world(); ``` -------------------------------- ### Represent Range in Text Document (JSON) Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Provides an example of a Range object in JSON format, representing a selection within a text document using start and end positions. ```JSON { start: { line: 5, character: 23 }, end : { line: 6, character: 0 } } ``` -------------------------------- ### TypeScript Code Example Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification A TypeScript code snippet demonstrating exported elements, including a function `func` and a class `Emitter` with private and public methods. This code serves as input for moniker generation. ```typescript export function func(): void { } export class Emitter { private doEmit() { } public emit() { this.doEmit(); } } ``` -------------------------------- ### DocumentFilter Examples Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Examples of DocumentFilter objects used to specify criteria for matching documents, such as language ID, URI scheme, or a glob pattern. ```typescript { language: 'typescript', scheme: 'file' } ``` ```typescript { language: 'json', pattern: '**/package.json' } ``` -------------------------------- ### TypeScript: Implementation Registration Options Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Specifies the registration options for the 'Goto Implementation' server capability. It combines text document registration, implementation options, and static registration settings. ```TypeScript export interface ImplementationRegistrationOptions extends TextDocumentRegistrationOptions, ImplementationOptions, StaticRegistrationOptions { } ``` -------------------------------- ### TypeScript Example for textDocument/definition Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification This TypeScript code snippet demonstrates a simple function structure that can be used to illustrate the 'textDocument/definition' request in the Language Server Protocol. It shows two functions, 'bar' and 'foo', where 'foo' calls 'bar'. ```TypeScript function bar() { } function foo() { bar(); } ``` -------------------------------- ### Partial Result Progress Token Example Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Demonstrates the use of `partialResultToken` in a request to signal support for partial result progress notifications. The example shows a `textDocument/references` request with both `workDoneToken` and `partialResultToken`. ```json { "textDocument": { "uri": "file:///folder/file.ts" }, "position": { "line": 9, "character": 5 }, "context": { "includeDeclaration": true }, // The token used to report work done progress. "workDoneToken": "1d546990-40a3-4b77-b134-46622995f6ae", // The token used to report partial result progress. "partialResultToken": "5f6f349e-4f81-4a3b-afff-ee04bff96804" } ``` -------------------------------- ### TypeScript: Implementation Registration Options Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Defines the registration options for the 'Goto Implementation' request in the Language Server Protocol. It combines text document registration, implementation options, and static registration options. ```TypeScript export interface ImplementationRegistrationOptions extends TextDocumentRegistrationOptions, ImplementationOptions, StaticRegistrationOptions { } ``` -------------------------------- ### LSP Message Example Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 An example of a Language Server Protocol (LSP) message, demonstrating the header and content parts separated by '\r\n'. The header includes 'Content-Length' and 'Content-Type', followed by the JSON-RPC payload. ```JSON Content-Length: ...\r\n\r\n{\n\t"jsonrpc": "2.0",\n\t"id": 1,\n\t"method": "textDocument/didOpen",\n\t"params": {\n\t\t...\n\t}\n} ``` -------------------------------- ### TypeScript: Implementation Client Capabilities Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Defines the client capabilities for the 'Goto Implementation' request in the Language Server Protocol. It specifies whether the client supports dynamic registration and additional metadata via definition links. ```TypeScript export interface ImplementationClientCapabilities { /** * Whether implementation supports dynamic registration. * If this is set to `true`, the client supports the new * `ImplementationRegistrationOptions` return value for the * corresponding server capability as well. */ dynamicRegistration?: boolean; /** * The client supports additional metadata in the form of definition links. * * @since 3.14.0 */ linkSupport?: boolean; } ``` -------------------------------- ### TypeScript: Implementation Client Capabilities Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Defines the client capabilities for the 'Goto Implementation' request in the Language Server Protocol. It specifies whether the client supports dynamic registration and additional metadata links for definitions. ```TypeScript export interface ImplementationClientCapabilities { /** * Whether implementation supports dynamic registration. If this is set to * `true` the client supports the new `ImplementationRegistrationOptions` * return value for the corresponding server capability as well. */ dynamicRegistration?: boolean; /** * The client supports additional metadata in the form of definition links. * * @since 3.14.0 */ linkSupport?: boolean; } ``` -------------------------------- ### Define a Range in Text Document Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Defines a range within a text document using zero-based start and end positions. The end position is exclusive, and to include line endings, the end position should denote the start of the next line. ```TypeScript interface Range { /** * The range's start position. */ start: Position; /** * The range's end position. */ end: Position; } ``` -------------------------------- ### Define DocumentFilter Interface and Examples Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Defines a `DocumentFilter` interface used to denote a document through properties like `language`, `scheme`, or `pattern`. Examples show filtering by language and file pattern. The `pattern` property supports glob syntax for flexible file matching. ```typescript { language: 'typescript', scheme: 'file' } { language: 'json', pattern: '**/package.json' } ``` ```typescript export interface DocumentFilter { /** * A language id, like `typescript`. */ language?: string; /** * A Uri scheme, like `file` or `untitled`. */ scheme?: string; /** * A glob pattern, like `*.{ts,js}`. * * Glob patterns can have the following syntax: * - `*` to match one or more characters in a path segment * - `?` to match on one character in a path segment * - `**` to match any number of path segments, including none * - `{}` to group conditions * (e.g. `**/*.{ts,js}` matches all TypeScript and JavaScript files) * - `[]` to declare a range of characters to match in a path segment * (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …) * - `[!...]` to negate a range of characters to match in a path segment * (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, * but not `example.0`) */ pattern?: string; } ``` -------------------------------- ### Definition Registration Options (TypeScript) Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Defines the registration options for the 'Goto Definition' provider. It combines text document registration options with definition-specific options. ```TypeScript export interface DefinitionRegistrationOptions extends TextDocumentRegistrationOptions, DefinitionOptions { } ``` -------------------------------- ### TypeScript Inheritance and Method Overriding Example Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.4.0/specification Demonstrates a TypeScript code snippet showcasing interface inheritance and class implementation of methods. This example is used to illustrate how LSIF handles references across different scopes and implementations. ```typescript interface I { foo(): void; } interface II { foo(): void; } class B implements I, II { foo(): void { } } let i: I; i.foo(); let b: B; b.foo(); ``` -------------------------------- ### Add Diagnostic#tag Support Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Introduces the `tag` property to `Diagnostic`, enabling the categorization of diagnostics, for example, to mark deprecated code. ```json { "range": { "start": { "line": 5, "character": 0 }, "end": { "line": 5, "character": 10 } }, "message": "This function is deprecated.", "severity": 2, "tags": [ 2 ] } ``` -------------------------------- ### DeclarationClientCapabilities Interface Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Defines the client capabilities for the 'Go to Declaration' feature. It specifies whether the client supports dynamic registration and additional metadata via declaration links. ```TypeScript export interface DeclarationClientCapabilities { dynamicRegistration?: boolean; linkSupport?: boolean; } ``` -------------------------------- ### MarkupContent Interface Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Represents a string value whose content can be interpreted based on its kind (plaintext or markdown). Includes an example of constructing markdown content. ```typescript /** * A `MarkupContent` literal represents a string value which content is * interpreted base on its kind flag. Currently the protocol supports * `plaintext` and `markdown` as markup kinds. * * If the kind is `markdown` then the value can contain fenced code blocks like * in GitHub issues. * * Here is an example how such a string can be constructed using * JavaScript / TypeScript: * ```typescript * let markdown: MarkdownContent = { * kind: MarkupKind.Markdown, * value: [ * '# Header', * 'Some text', * '```typescript', * someCode();', * '```' * ].join('\n') * }; * ``` * * *Please Note* that clients might sanitize the return markdown. A client could * decide to remove HTML from the markdown to avoid script execution. */ export interface MarkupContent { /** * The type of the Markup */ kind: MarkupKind; /** * The content itself */ value: string; } ``` -------------------------------- ### Merge Workspace Folder, Configuration, and Color Provider Protocols Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Merges proposed protocols for workspace folders, configuration, go to type definition, go to implementation, and document color provider into the main specification. ```json { "capabilities": { "workspace": { "workspaceFolders": { "supported": true, "changeNotifications": "workspaceFolders" }, "configuration": true }, "textDocument": { "definitionProvider": true, "declarationProvider": true, "implementationProvider": true, "colorProvider": true } } } ``` -------------------------------- ### TypeScript Function Definition Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification A simple TypeScript function declaration used as an example for range identification. ```typescript function bar() { } ``` -------------------------------- ### Folding Range Interface (TypeScript) Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Represents a folding range within a text document, including start and end lines and optional characters and kind. ```TypeScript /** * Represents a folding range. To be valid, start and end line must be bigger * than zero and smaller than the number of lines in the document. Clients * are free to ignore invalid ranges. */ export interface FoldingRange { /** * The zero-based start line of the range to fold. The folded area starts * after the line's last character. To be valid, the end must be zero or * larger and smaller than the number of lines in the document. */ startLine: uinteger; /** * The zero-based character offset from where the folded range starts. If * not defined, defaults to the length of the start line. */ startCharacter?: uinteger; /** * The zero-based end line of the range to fold. The folded area ends with * the line's last character. To be valid, the end must be zero or larger * and smaller than the number of lines in the document. */ endLine: uinteger; /** * The zero-based character offset before the folded range ends. If not * defined, defaults to the length of the end line. */ endCharacter?: uinteger; /** * Describes the kind of the folding range such as `comment` or `region`. * The kind is used to categorize folding ranges and used by commands like * 'Fold all comments'. See [FoldingRangeKind](#FoldingRangeKind) for an * enumeration of standardized kinds. */ kind?: string; } ``` -------------------------------- ### Folding Range Interface Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Represents a folding range within a text document, specifying start and end lines and optional character offsets and kind. ```TypeScript /** * Represents a folding range. */ export interface FoldingRange { /** * The zero-based line number from where the folded range starts. */ startLine: number; /** * The zero-based character offset from where the folded range starts. * If not defined, defaults to the length of the start line. */ startCharacter?: number; /** * The zero-based line number where the folded range ends. */ endLine: number; /** * The zero-based character offset before the folded range ends. * If not defined, defaults to the length of the end line. */ endCharacter?: number; /** * Describes the kind of the folding range such as `comment` or `region`. * The kind is used to categorize folding ranges and used by commands * like 'Fold all comments'. * See [FoldingRangeKind](#FoldingRangeKind) for an enumeration of * standardized kinds. */ kind?: string; } ``` -------------------------------- ### Example TypeScript Code Snippet Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification A simple TypeScript function demonstrating a type error, which would generate diagnostics. ```TypeScript function foo() { let x: string = 10; } ``` -------------------------------- ### LSIF Range Vertex Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification Represents a range within a document in an LSIF dump, defined by start and end positions. ```json { id: 4, type: "vertex", label: "range", start: { line: 0, character: 9}, end: { line: 0, character: 12 } } ``` -------------------------------- ### Definition Client Capabilities (TypeScript) Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Defines the client capabilities for the 'Goto Definition' request. It specifies whether the client supports dynamic registration and additional metadata in the form of definition links. ```TypeScript export interface DefinitionClientCapabilities { /** * Whether definition supports dynamic registration. */ dynamicRegistration?: boolean; /** * The client supports additional metadata in the form of definition links. * * @since 3.14.0 */ linkSupport?: boolean; } ``` -------------------------------- ### Variable Transformation Example Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Demonstrates how to transform a variable, specifically extracting the filename without its extension. It uses a regular expression to capture the part of the filename before the last dot and its extension. ```text ${TM_FILENAME/(.*)\..+$1/} ``` -------------------------------- ### Register Capability Request Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 The `client/registerCapability` request is sent from the server to the client to dynamically register new capabilities. Clients opt-in via the `dynamicRegistration` property. This example shows registering for `textDocument/willSaveWaitUntil`. ```TypeScript /** * General parameters to register for a capability. */ export interface Registration { /** * The id used to register the request. The id can be used to deregister * the request again. */ id: string; /** * The method / capability to register for. */ method: string; /** * Options necessary for the registration. */ registerOptions?: any; } export interface RegistrationParams { registrations: Registration[]; } ``` -------------------------------- ### SignatureHelpClientCapabilities Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Defines the capabilities of a client to support signature help features, including dynamic registration, documentation formats, parameter information support, and context support. ```typescript export interface SignatureHelpClientCapabilities { /** * Whether signature help supports dynamic registration. */ dynamicRegistration?: boolean; /** * The client supports the following `SignatureInformation` * specific properties. */ signatureInformation?: { /** * Client supports the following content formats for the documentation * property. The order describes the preferred format of the client. */ documentationFormat?: MarkupKind[]; /** * Client capabilities specific to parameter information. */ parameterInformation?: { /** * The client supports processing label offsets instead of a * simple label string. * * @since 3.14.0 */ labelOffsetSupport?: boolean; }; /** * The client supports the `activeParameter` property on * `SignatureInformation` literal. * * @since 3.16.0 */ act iveParameterSupport?: boolean; }; /** * The client supports to send additional context information for a * `textDocument/signatureHelp` request. A client that opts into * contextSupport will also support the `retriggerCharacters` on * `SignatureHelpOptions`. * * @since 3.15.0 */ contextSupport?: boolean; } ``` -------------------------------- ### TypeScript Moniker Example Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.6.0/specification Demonstrates the structure of a 'local' moniker for a variable 'x' in TypeScript, including its unique identifier and association with a range. ```JSON { "id": 13, "type": "vertex", "label": "resultSet" } { "id": 14, "type": "vertex", "label": "moniker", "kind": "local", "scheme": "tsc", "identifier": "SfeOP6s53Y2HAkcViolxYA==", "unique": 'document' } { "id": 15, "type": "edge", "label": "moniker", "outV": 13, "inV": 14 } { "id": 16, "type": "vertex", "label": "range", "start": { "line": 0, "character": 13 }, "end": { "line": 0, "character": 14 }, "tag": { "type": "definition", "text": "x", "kind": 7, "fullRange": { "start": { "line": 0, "character": 13 }, "end": { "line": 0, "character": 14 } } } } { "id": 17, "type": "edge", "label": "next", "outV": 16, "inV": 13 } ``` -------------------------------- ### Type Definition Registration Options (TypeScript) Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Defines the registration options for the 'Goto Type Definition' provider. It includes text document registration, definition options, and static registration options. ```TypeScript export interface TypeDefinitionRegistrationOptions extends TextDocumentRegistrationOptions, TypeDefinitionOptions, StaticRegistrationOptions { } ``` -------------------------------- ### Declaration Client Capabilities Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Defines the client capabilities for the 'go to declaration' feature. It specifies whether the client supports dynamic registration and additional metadata via declaration links. ```TypeScript export interface DeclarationClientCapabilities { dynamicRegistration?: boolean; linkSupport?: boolean; } ``` -------------------------------- ### Define Range in Text Document (TypeScript) Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Defines the Range interface for representing a span within a text document using start and end Position objects. The end position is exclusive. ```TypeScript interface Range { /** * The range's start position. */ start: Position; /** * The range's end position. */ end: Position; } ``` -------------------------------- ### DocumentOnTypeFormattingClientCapabilities Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Defines the client capabilities for on-type formatting, specifying whether dynamic registration is supported. ```TypeScript export interface DocumentOnTypeFormattingClientCapabilities { /** * Whether on type formatting supports dynamic registration. */ dynamicRegistration?: boolean; } ``` -------------------------------- ### Definition of Widget#dispose Source: https://microsoft.github.io/language-server-protocol/specifications/lsif/0.5.0/specification Defines the location (start and end character positions) and text of the 'dispose' symbol within a code range. ```json { id: 81, type: "vertex", label: "range", start: { line: 3, character: 8 }, end: { line: 3, character: 15 }, tag: { type: "definition", text: "dispose", kind: 6, fullRange: { start: { line: 3, character: 1 }, end: { line: 4, character: 2 } } } } ``` -------------------------------- ### Add Signature Help Context Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Introduces signature help context, providing additional information to assist with signature completion. ```json { "method": "textDocument/signatureHelp", "params": { "textDocument": { "uri": "file:///path/to/document.txt" }, "position": { "line": 10, "character": 5 }, "context": { "triggerKind": 1, "triggerCharacter": ",", "isSignatureActive": true, "activeSignatureIndex": 0, "activeParameter": 1 } } } ``` -------------------------------- ### Unregister Capability Request (LSP) Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-16 Defines the `client/unregisterCapability` request used by the server to unregister a previously registered capability. It includes the `UnregistrationParams` and `Unregistration` interfaces, along with an example JSON RPC message. ```TypeScript export interface Unregistration { id: string; method: string; } export interface UnregistrationParams { unregisterations: Unregistration[]; } ``` ```JSON { "method": "client/unregisterCapability", "params": { "unregisterations": [ { "id": "79eee87c-c409-4664-8102-e03263673f6f", "method": "textDocument/willSaveWaitUntil" } ] } } ``` -------------------------------- ### Unregister Capability Request (LSP) Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Defines the `client/unregisterCapability` request used by the server to unregister a previously registered capability. It includes the `UnregistrationParams` and `Unregistration` interfaces, along with an example JSON RPC message. ```TypeScript export interface Unregistration { id: string; method: string; } export interface UnregistrationParams { unregisterations: Unregistration[]; } ``` ```JSON { "method": "client/unregisterCapability", "params": { "unregisterations": [ { "id": "79eee87c-c409-4664-8102-e03263673f6f", "method": "textDocument/willSaveWaitUntil" } ] } } ``` -------------------------------- ### TypeScript: Implementation Options Source: https://microsoft.github.io/language-server-protocol/specifications/specification-3-15 Defines the server options for the 'Goto Implementation' request. This interface extends `WorkDoneProgressOptions`, indicating support for progress reporting during the operation. ```TypeScript export interface ImplementationOptions extends WorkDoneProgressOptions { } ```