Skip to content

Commit

Permalink
internal/lsp: fix watched file protocol constants
Browse files Browse the repository at this point in the history
The "Create" and "Delete" WatchKind values were missing from the
generated code because their names were colliding with other
constants. Add "WatchKind" to go.ts prefix map to disambiguate.

Updates golang/go#31553

Change-Id: I60269969831c0822896e87b3f2332ded71748f42
GitHub-Last-Rev: 6d85cf9
GitHub-Pull-Request: golang#136
Reviewed-on: https://go-review.googlesource.com/c/tools/+/186097
Run-TryBot: Rebecca Stambler <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Rebecca Stambler <[email protected]>
  • Loading branch information
muirdm authored and stamblerre committed Jul 31, 2019
1 parent 09f9cfa commit dddb761
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
6 changes: 4 additions & 2 deletions internal/lsp/protocol/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var (
namesInitializeError [int(UnknownProtocolVersion) + 1]string
namesMessageType [int(Log) + 1]string
namesFileChangeType [int(Deleted) + 1]string
namesWatchKind [int(Change) + 1]string
namesWatchKind [int(WatchDelete) + 1]string
namesCompletionTriggerKind [int(TriggerForIncompleteCompletions) + 1]string
namesDiagnosticSeverity [int(SeverityHint) + 1]string
namesDiagnosticTag [int(Unnecessary) + 1]string
Expand All @@ -40,7 +40,9 @@ func init() {
namesFileChangeType[int(Changed)] = "Changed"
namesFileChangeType[int(Deleted)] = "Deleted"

namesWatchKind[int(Change)] = "Change"
namesWatchKind[int(WatchCreate)] = "WatchCreate"
namesWatchKind[int(WatchChange)] = "WatchChange"
namesWatchKind[int(WatchDelete)] = "WatchDelete"

namesCompletionTriggerKind[int(Invoked)] = "Invoked"
namesCompletionTriggerKind[int(TriggerCharacter)] = "TriggerCharacter"
Expand Down
16 changes: 13 additions & 3 deletions internal/lsp/protocol/tsprotocol.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions internal/lsp/protocol/typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

1. Make sure `node` is installed.
As explained at the [node site](<https://nodejs.org> Node)
you may need `node install @types/node` for the node runtime types
2. Install the typescript compiler, with `node install typescript`.
you may need `npm install @types/node` for the node runtime types
2. Install the typescript compiler, with `npm install typescript`.
3. Make sure `tsc` and `node` are in your execution path.
4. Get the typescript code for the jsonrpc protocol with `git clone vscode-lanuageserver-node.git`
4. Get the typescript code for the jsonrpc protocol with `git clone [email protected]:microsoft/vscode-languageserver-node.git`

## Usage

Expand All @@ -31,4 +31,4 @@ To generate the client and server boilerplate (tsclient.go and tsserver.go)

## Note

`go.ts` uses the Typescript compiler's API, which is [introduced](<https://github.com/Microsoft/TypeScript/wiki/Architectural-Overview> API) in their wiki.
`go.ts` uses the Typescript compiler's API, which is [introduced](<https://github.com/Microsoft/TypeScript/wiki/Architectural-Overview> API) in their wiki.
2 changes: 1 addition & 1 deletion internal/lsp/protocol/typescript/go.ts
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ let byName = new Map<string, Struct>();
// consts are unique. (Go consts are package-level, but Typescript's are
// not.) Use suffixes to minimize changes to gopls.
let pref = new Map<string, string>(
[['DiagnosticSeverity', 'Severity']]) // typeName->prefix
[['DiagnosticSeverity', 'Severity'], ['WatchKind', 'Watch']]) // typeName->prefix
let suff = new Map<string, string>([
['CompletionItemKind', 'Completion'], ['InsertTextFormat', 'TextFormat']
])
Expand Down

0 comments on commit dddb761

Please sign in to comment.