Skip to content

Commit beaf946

Browse files
authored
Merge pull request #5645 from Aghassi/sourcekit-docs-complete.open
2 parents 6e404e4 + da61111 commit beaf946

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tools/SourceKit/docs/Protocol.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ must be given either the path to a file (`key.sourcefile`), or some text
3838
(`key.sourcetext`). `key.sourcefile` is ignored when `key.sourcetext` is also
3939
provided.
4040

41+
| Request Name | Request Key | Description |
42+
| -------------:|:------------|:------------|
43+
| `codecomplete` | `codecomplete` | Returns a list of completions. |
44+
| `open` | `codecomplete.open` | Given a file will open a code-completion session which can be filtered using `codecomplete.update`. Each session must be closed using `codecomplete.close`. |
45+
4146
### Request
4247

4348
```
@@ -54,6 +59,22 @@ provided.
5459
}
5560
```
5661

62+
`codecomplete.open`
63+
```
64+
{
65+
<key.request>: (UID) <source.request.codecomplete.open>
66+
[opt] <key.sourcetext>: (string) // Source contents.
67+
[opt] <key.sourcefile>: (string) // Absolute path to the file.
68+
<key.offset>: (int64) // Byte offset of code-completion point inside the source contents.
69+
[opt] <key.codecomplete.options>: (dict) // An options dictionary containing keys.
70+
[opt] <key.compilerargs> [string*] // Array of zero or more strings for the compiler arguments,
71+
// e.g ["-sdk", "/path/to/sdk"]. If key.sourcefile is provided,
72+
// these must include the path to that file.
73+
[opt] <key.not_recommended> [bool] // True if this result is to be avoided, e.g. because
74+
// the declaration is unavailable.
75+
}
76+
```
77+
5778
### Response
5879

5980
```
@@ -75,6 +96,24 @@ completion-result ::=
7596
}
7697
```
7798

99+
```
100+
completion.open-result ::=
101+
{
102+
<key.kind>: (UID) // UID for the declaration kind (function, class, etc.).
103+
<key.name>: (string) // Name of the word being completed
104+
<key.sourcetext>: (string) // Text to be inserted in source.
105+
<key.description>: (string) // Text to be displayed in code-completion window.
106+
<key.typename>: (string) // Text describing the type of the result.
107+
<key.context>: (UID) // Semantic context of the code completion result.
108+
<key.num_bytes_to_erase>: (int64) // Number of bytes to the left of the cursor that should be erased before inserting this completion result.
109+
<key.substructure>: (dictionary) // Contains an array of dictionaries representing ranges of structural elements in the result description, such as the parameters of a function
110+
- <key.nameoffset> (int64) // The offset location of the given parameter
111+
- <key.namelength> (int64) // The length of the given parameter
112+
- <key.bodyoffset> (int64) // The `nameoffset` + the indentation inside the body of the file
113+
- <key.bodylength> (int64) // The `namelength` + the indentation inside the body of the file
114+
}
115+
```
116+
78117
### Testing
79118

80119
```

0 commit comments

Comments
 (0)