File: README.md

package info (click to toggle)
golang-golang-x-tools 1%3A0.1.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,588 kB
  • sloc: javascript: 2,011; asm: 1,458; sh: 174; yacc: 155; makefile: 21; ansic: 17
file content (33 lines) | stat: -rw-r--r-- 1,263 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Generate server_gen.go

`helper` generates boilerplate code for server.go by processing the
generated code in `protocol/tsserver.go`.

First, build `helper` in this directory (`go build .`).

In directory `lsp`, executing `go generate server.go` generates the stylized file
`server_gen.go` that contains stubs for type `Server`.

It decides what stubs are needed and their signatures
by looking at the `Server` interface (`-t` flag). These all look somewhat like
`Resolve(context.Context, *CompletionItem) (*CompletionItem, error)`.

It then parses the `lsp` directory (`-u` flag) to see if there is a corresponding
implementation function (which in this case would be named `resolve`). If so
it discovers the parameter names needed, and generates (in `server_gen.go`) code
like

``` go
func (s *Server) resolve(ctx context.Context, params *protocol.CompletionItem) (*protocol.CompletionItem, error) {
    return s.resolve(ctx, params)
}
```

If `resolve` is not defined (and it is not), then the body of the generated function is

```go
    return nil, notImplemented("resolve")
```

So to add a capability currently not implemented, just define it somewhere in `lsp`.
In this case, just define `func (s *Server) resolve(...)` and re-generate `server_gen.go`.