Skip to content

Commit 934104a

Browse files
committed
Docs/SourceKit: add some documentation for expression type request.
1 parent 74e86a8 commit 934104a

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
@@ -737,7 +737,46 @@ Welcome to SourceKit. Type ':help' for assistance.
737737
}
738738
```
739739

740+
## Expression Type
741+
This request collects the types of all expressions in a source file after type checking.
742+
To fulfill this task, the client must provide the path to the Swift source file under
743+
type checking and the necessary compiler arguments to help resolve all dependencies.
740744

745+
### Request
746+
747+
```
748+
{
749+
<key.request>: (UID) <source.request.expression.type>,
750+
<key.sourcefile>: (string) // Absolute path to the file.
751+
<key.compilerargs>: [string*] // Array of zero or more strings for the compiler arguments,
752+
// e.g ["-sdk", "/path/to/sdk"]. If key.sourcefile is provided,
753+
// these must include the path to that file.
754+
}
755+
```
756+
757+
### Response
758+
```
759+
{
760+
<key.printedtypebuffer>: (string) // A text buffer where all expression types are printed to.
761+
<key.expression_type_list>: (array) [expr-type-info*] // A list of expression and type
762+
}
763+
```
764+
765+
```
766+
expr-type-info ::=
767+
{
768+
<key.expression_offset>: (int64) // Offset of an expression in the source file
769+
<key.expression_length>: (int64) // Length of an expression in the source file
770+
<key.type_offset>: (int64) // Offset of the printed type of the expression in the printed type buffer
771+
<key.type_length>: (int64) // Length of the printed type of the expression in the printed type buffer
772+
}
773+
```
774+
775+
### Testing
776+
777+
```
778+
$ sourcekitd-test -req=collect-type /path/to/file.swift -- /path/to/file.swift
779+
```
741780

742781
# UIDs
743782

0 commit comments

Comments
 (0)