Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SourceKit] docs for complete.open #5645

Merged
merged 5 commits into from Nov 14, 2016
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions tools/SourceKit/docs/Protocol.md
Expand Up @@ -38,6 +38,11 @@ must be given either the path to a file (`key.sourcefile`), or some text
(`key.sourcetext`). `key.sourcefile` is ignored when `key.sourcetext` is also
provided.

| Request Name | Request Key | Description |
| -------------:|:------------|:------------|
| `codecomplete` | `codecomplete` | Given a file will open a code-completion session which can be filtered upon using `codecomplete.update`. Each session must be closed using `codecomplete.close`.|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a description of codecomplete.open. codecomplete just returns completions and does not filter or create a session. Also, you could remove the word "upon" entirely.

| `open` | `codecomplete.open` | Open a code-completion session for the given input file and offset, and return the initial list of completions. |

### Request

```
Expand All @@ -54,6 +59,22 @@ provided.
}
```

`codecomplete.open`
```
{
<key.request>: (UID) <source.request.codecomplete.open>
[opt] <key.sourcetext>: (string) // Source contents.
[opt] <key.sourcefile>: (string) // Absolute path to the file.
<key.offset>: (int64) // Byte offset of code-completion point inside the source contents.
[opt] <key.options>: (dict) // An options dictionary containing keys.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key.codecomplete.options

[opt] <key.compilerargs> [string*] // Array of zero or more strings for the compiler arguments,
// e.g ["-sdk", "/path/to/sdk"]. If key.sourcefile is provided,
// these must include the path to that file.
[opt] <key.not_recommended> [bool] // True if this result is to be avoided, e.g. because
// the declaration is unavailable.
}
```

### Response

```
Expand All @@ -75,6 +96,24 @@ completion-result ::=
}
```

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

### Testing

```
Expand Down