Skip to content

[SourceKit] Document source.request.mangle_simple_class #4733

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
Jan 11, 2017
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
72 changes: 72 additions & 0 deletions tools/SourceKit/docs/Protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The protocol is documented in the following format:
| [Code Completion](#code-completion) | source.request.codecomplete |
| [Cursor Info](#cursor-info) | source.request.cursorinfo |
| [Demangling](#demangling) | source.request.demangle |
| [Mangling](#simple-class-mangling) | source.request.mangle_simple_class |
| [Documentation](#documentation) | source.request.docinfo |
| [Module interface generation](#module-interface-generation) | source.request.editor.open.interface |
| [Indexing](#indexing) | source.request.indexsource |
Expand Down Expand Up @@ -506,6 +507,77 @@ Welcome to SourceKit. Type ':help' for assistance.
}
```

## Simple Class Mangling

SourceKit is capable of "mangling" Swift class names. In other words,
it's capable of taking the human-readable `UIKit.ViewController` as input and returning the symbol `_TtC5UIKit14ViewController`.

### Request

```
{
<key.request>: (UID) <source.request.mangle_simple_class>,
<key.names>: [mangle-request*] // An array of requests to mangle.
}
```

```
mangle-request ::=
{
<key.modulename>: (string) // The Swift module name
<key.name>: (string) // The class name
}
```

### Response

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

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

### Testing

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

For example, to mangle the name `UIKit.ViewController`:

```
$ sourcekitd-test -req=mangle UIKit.ViewController
```

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.mangle_simple_class,
key.names: [
{
key.modulename: "UIKit",
key.name: "ViewController"
}
]
}
```

## Protocol Version

SourceKit can provide information about the version of the protocol that is being used.
Expand Down