Skip to content

Commit 183cb54

Browse files
modocachenkcsgexi
authored andcommitted
[SourceKit] Document source.request.demangle (#3603)
1 parent dd893e8 commit 183cb54

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

tools/SourceKit/docs/Protocol.md

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,68 @@ range ::=
393393

394394
Sub-diagnostics are only diagnostic notes currently.
395395

396+
# Demangling
397+
398+
SourceKit is capable of "demangling" mangled Swift symbols. In other words,
399+
it's capable of taking the symbol `_TF13MyCoolPackageg6raichuVS_7Pokemon` as
400+
input, and returning the human-readable
401+
`MyCoolPackage.raichu.getter : MyCoolPackage.Pokemon`.
402+
403+
### Request
404+
405+
```
406+
{
407+
<key.request>: (UID) <source.request.demangle>,
408+
<key.names>: [string*] // An array of names to demangle.
409+
}
410+
```
411+
412+
### Response
413+
414+
```
415+
{
416+
<key.results>: (array) [demangle-result+] // The results for each
417+
// demangling, in the order in
418+
// which they were requested.
419+
}
420+
```
421+
422+
```
423+
demangle-result ::=
424+
{
425+
<key.name>: (string) // The demangled name.
426+
}
427+
```
428+
429+
### Testing
430+
431+
```
432+
$ sourcekitd-test -req=demangle [<names>]
433+
```
434+
435+
For example, to demangle the symbol `_TF13MyCoolPackageg6raichuVS_7Pokemon`:
436+
437+
```
438+
$ sourcekitd-test -req=demangle _TF13MyCoolPackageg6raichuVS_7Pokemon
439+
```
440+
441+
Note that when using `sourcekitd-test`, the output is output in an ad hoc text
442+
format, not JSON.
443+
444+
You could also issue the following request in the `sourcekitd-repl`, which
445+
produces JSON:
446+
447+
```
448+
$ sourcekitd-repl
449+
Welcome to SourceKit. Type ':help' for assistance.
450+
(SourceKit) {
451+
key.request: source.request.demangle,
452+
key.names: [
453+
"_TF13MyCoolPackageg6raichuVS_7Pokemon"
454+
]
455+
}
456+
```
457+
396458
# UIDs
397459

398460
## Keys
@@ -410,4 +472,3 @@ Sub-diagnostics are only diagnostic notes currently.
410472
- `key.sourcetext`
411473
- `key.typename`
412474
- `key.usr`
413-

0 commit comments

Comments
 (0)