Skip to content

Commit 06d3d5d

Browse files
committed
Add LSP extension documentation
1 parent 19853ff commit 06d3d5d

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

Contributor Documentation/LSP Extensions.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,58 @@ export interface DoccDocumentationResponse {
153153
}
154154
```
155155
156+
## `textDocument/playgrounds`
157+
158+
New request for return the list of #Playground macro expansions in a given text document.
159+
160+
Primarily designed to allow editors to provide a list of available playgrounds in the project workspace and allow
161+
jumping to the locations where the #Playground macro was expanded.
162+
163+
The request parses a given text document and returns the location, identifier, and optional label when available
164+
for each #Playground macro expansion. The request is intended to be used in combination with the `workspace/playgrounds`
165+
request where the `workspace/playgrounds` provides the full list of playgrounds in the workspace and `textDocument/playgrounds`
166+
can be called after document changes. This way the editor can itself keep the list of playgrounds up to date without needing to
167+
call `workspace/playgrounds` each time a document is changed.
168+
169+
SourceKit-LSP will advertise `textDocument/playgrounds` in its experimental server capabilities if it supports it.
170+
171+
- params: `DocumentPlaygroundParams`
172+
- result: `PlaygroundItem[]`
173+
174+
```ts
175+
export interface DocumentPlaygroundParams {
176+
/**
177+
* The document to parse for playgrounds.
178+
*/
179+
textDocument: TextDocumentIdentifier;
180+
}
181+
/**
182+
* A `PlaygroundItem` represents an expansion of the #Playground macro, providing the editor with the
183+
* location of the playground and identifiers to allow executing the playground through a "swift play" command.
184+
*/
185+
export interface PlaygroundItem {
186+
/**
187+
* Unique identifier for the `PlaygroundItem`. Client can run the playground by executing `swift play <id>`.
188+
*
189+
* This property is always present whether the `PlaygroundItem` has a `label` or not.
190+
*
191+
* Follows the format output by `swift play --list`.
192+
*/
193+
id: string;
194+
195+
/**
196+
* The label that can be used as a display name for the playground. This optional property is only available
197+
* for named playgrounds. For example: `#Playground("hello") { print("Hello!) }` would have a `label` of `"hello"`.
198+
*/
199+
label?: string
200+
201+
/**
202+
* The location of the of where the #Playground macro expansion occured in the source code.
203+
*/
204+
location: Location
205+
}
206+
```
207+
156208
## `textDocument/symbolInfo`
157209
158210
New request for semantic information about the symbol at a given location.

0 commit comments

Comments
 (0)