Skip to content

[SourceKit] Document source.request.demangle #3603

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

Merged
merged 1 commit into from
Jul 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion tools/SourceKit/docs/Protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,68 @@ range ::=

Sub-diagnostics are only diagnostic notes currently.

# Demangling

SourceKit is capable of "demangling" mangled Swift symbols. In other words,
it's capable of taking the symbol `_TF13MyCoolPackageg6raichuVS_7Pokemon` as
input, and returning the human-readable
`MyCoolPackage.raichu.getter : MyCoolPackage.Pokemon`.

### Request

```
{
<key.request>: (UID) <source.request.demangle>,
<key.names>: [string*] // An array of names to demangle.
}
```

### Response

```
{
<key.results>: (array) [demangle-result+] // The results for each
// demangling, in the order in
// which they were requested.
}
```

```
demangle-result ::=
{
<key.name>: (string) // The demangled name.
}
```

### Testing

```
$ sourcekitd-test -req=demangle [<names>]
```

For example, to demangle the symbol `_TF13MyCoolPackageg6raichuVS_7Pokemon`:

```
$ sourcekitd-test -req=demangle _TF13MyCoolPackageg6raichuVS_7Pokemon
```

Note that when using `sourcekitd-test`, the output is output in an ad hoc text
format, not JSON.

You could also issue the following request in the `sourcekitd-repl`, which
produces JSON:

```
$ sourcekitd-repl
Welcome to SourceKit. Type ':help' for assistance.
(SourceKit) {
key.request: source.request.demangle,
key.names: [
"_TF13MyCoolPackageg6raichuVS_7Pokemon"
]
}
```

# UIDs

## Keys
Expand All @@ -410,4 +472,3 @@ Sub-diagnostics are only diagnostic notes currently.
- `key.sourcetext`
- `key.typename`
- `key.usr`