Skip to content

Commit

Permalink
internal/lsp/semantic: only return token types the client asked for
Browse files Browse the repository at this point in the history
The old code mistakenly presumed all clients would want the standard
set of semantic tokens in the LSP specification, but clients have the
option of asking for fewer, so gopls should only use those.

Change-Id: Ic396bf3a2ba1fc3c9b48a380265a6cfded0a8bf6
Reviewed-on: https://go-review.googlesource.com/c/tools/+/321470
Run-TryBot: Peter Weinberger <[email protected]>
gopls-CI: kokoro <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Trust: Peter Weinberger <[email protected]>
Reviewed-by: Rebecca Stambler <[email protected]>
  • Loading branch information
pjweinbgo committed May 20, 2021
1 parent 0886cdd commit 3063790
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/lsp/semantic.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,14 @@ func (e *encoded) Data() []uint32 {
x[j+1] = e.items[i].start - e.items[i-1].start
}
x[j+2] = e.items[i].len
x[j+3] = uint32(typeMap[e.items[i].typeStr])
typ, ok := typeMap[e.items[i].typeStr]
if !ok {
continue // client doesn't want typeStr
}
x[j+3] = uint32(typ)
mask := 0
for _, s := range e.items[i].mods {
// modMpa[s] is 0 if the client doesn't want this modifier
mask |= modMap[s]
}
x[j+4] = uint32(mask)
Expand Down

0 comments on commit 3063790

Please sign in to comment.