Skip to content

Commit 5fc00b4

Browse files
committed
gopls/internal: move Options and FileKind from View to Snapshot
In preparation for making snapshots truly idempotent, move certain methods that depend on settings into the snapshot. Nothing should access settings through the View. For golang/go#42814 Change-Id: Ib3ced985dc89515f5a6e6049c7be316342706e54 Reviewed-on: https://go-review.googlesource.com/c/tools/+/524837 Run-TryBot: Robert Findley <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
1 parent 1bfa8e3 commit 5fc00b4

39 files changed

+92
-87
lines changed

gopls/internal/lsp/cache/load.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (s *snapshot) load(ctx context.Context, allowNetwork bool, scopes ...loadSc
6767
panic(fmt.Sprintf("internal error: load called with multiple scopes when a file scope is present (file: %s)", uri))
6868
}
6969
fh := s.FindFile(uri)
70-
if fh == nil || s.View().FileKind(fh) != source.Go {
70+
if fh == nil || s.FileKind(fh) != source.Go {
7171
// Don't try to load a file that doesn't exist, or isn't a go file.
7272
continue
7373
}

gopls/internal/lsp/cache/mod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func sumFilename(modURI span.URI) string {
213213
func (s *snapshot) ModWhy(ctx context.Context, fh source.FileHandle) (map[string]string, error) {
214214
uri := fh.URI()
215215

216-
if s.View().FileKind(fh) != source.Mod {
216+
if s.FileKind(fh) != source.Mod {
217217
return nil, fmt.Errorf("%s is not a go.mod file", uri)
218218
}
219219

gopls/internal/lsp/cache/mod_tidy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func modTidyDiagnostics(ctx context.Context, snapshot *snapshot, pm *source.Pars
168168
for _, req := range wrongDirectness {
169169
// Handle dependencies that are incorrectly labeled indirect and
170170
// vice versa.
171-
srcDiag, err := directnessDiagnostic(pm.Mapper, req, snapshot.View().Options().ComputeEdits)
171+
srcDiag, err := directnessDiagnostic(pm.Mapper, req, snapshot.Options().ComputeEdits)
172172
if err != nil {
173173
// We're probably in a bad state if we can't compute a
174174
// directnessDiagnostic, but try to keep going so as to not suppress

gopls/internal/lsp/cache/snapshot.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,14 @@ func (s *snapshot) View() source.View {
283283
return s.view
284284
}
285285

286+
func (s *snapshot) FileKind(h source.FileHandle) source.FileKind {
287+
return s.view.FileKind(h)
288+
}
289+
290+
func (s *snapshot) Options() *source.Options {
291+
return s.view.Options() // temporarily return view options.
292+
}
293+
286294
func (s *snapshot) BackgroundContext() context.Context {
287295
return s.backgroundCtx
288296
}
@@ -894,7 +902,7 @@ const fileExtensions = "go,mod,sum,work"
894902

895903
func (s *snapshot) fileWatchingGlobPatterns(ctx context.Context) map[string]struct{} {
896904
extensions := fileExtensions
897-
for _, ext := range s.View().Options().TemplateExtensions {
905+
for _, ext := range s.Options().TemplateExtensions {
898906
extensions += "," + ext
899907
}
900908
// Work-around microsoft/vscode#100870 by making sure that we are,

gopls/internal/lsp/code_action.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ func (s *Server) codeAction(ctx context.Context, params *protocol.CodeActionPara
3838
uri := fh.URI()
3939

4040
// Determine the supported actions for this file kind.
41-
kind := snapshot.View().FileKind(fh)
42-
supportedCodeActions, ok := snapshot.View().Options().SupportedCodeActions[kind]
41+
kind := snapshot.FileKind(fh)
42+
supportedCodeActions, ok := snapshot.Options().SupportedCodeActions[kind]
4343
if !ok {
4444
return nil, fmt.Errorf("no supported code actions for %v file kind", kind)
4545
}
@@ -185,7 +185,7 @@ func (s *Server) codeAction(ctx context.Context, params *protocol.CodeActionPara
185185
}
186186

187187
var stubMethodsDiagnostics []protocol.Diagnostic
188-
if wantQuickFixes && snapshot.View().Options().IsAnalyzerEnabled(stubmethods.Analyzer.Name) {
188+
if wantQuickFixes && snapshot.Options().IsAnalyzerEnabled(stubmethods.Analyzer.Name) {
189189
for _, pd := range diagnostics {
190190
if stubmethods.MatchesMessage(pd.Message) {
191191
stubMethodsDiagnostics = append(stubMethodsDiagnostics, pd)
@@ -453,7 +453,7 @@ func refactorRewrite(ctx context.Context, snapshot source.Snapshot, pkg source.P
453453
//
454454
// TODO: Consider removing the inspection after convenienceAnalyzers are removed.
455455
inspect := inspector.New([]*ast.File{pgf.File})
456-
if snapshot.View().Options().IsAnalyzerEnabled(fillstruct.Analyzer.Name) {
456+
if snapshot.Options().IsAnalyzerEnabled(fillstruct.Analyzer.Name) {
457457
for _, d := range fillstruct.DiagnoseFillableStructs(inspect, start, end, pkg.GetTypes(), pkg.GetTypesInfo()) {
458458
rng, err := pgf.Mapper.PosRange(pgf.Tok, d.Pos, d.End)
459459
if err != nil {
@@ -480,7 +480,7 @@ func refactorRewrite(ctx context.Context, snapshot source.Snapshot, pkg source.P
480480
})
481481
}
482482

483-
if snapshot.View().Options().IsAnalyzerEnabled(infertypeargs.Analyzer.Name) {
483+
if snapshot.Options().IsAnalyzerEnabled(infertypeargs.Analyzer.Name) {
484484
for _, d := range infertypeargs.DiagnoseInferableTypeArgs(pkg.FileSet(), inspect, start, end, pkg.GetTypes(), pkg.GetTypesInfo()) {
485485
if len(d.SuggestedFixes) != 1 {
486486
panic(fmt.Sprintf("unexpected number of suggested fixes from infertypeargs: %v", len(d.SuggestedFixes)))

gopls/internal/lsp/code_lens.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (s *Server) codeLens(ctx context.Context, params *protocol.CodeLensParams)
2727
return nil, err
2828
}
2929
var lenses map[command.Command]source.LensFunc
30-
switch snapshot.View().FileKind(fh) {
30+
switch snapshot.FileKind(fh) {
3131
case source.Mod:
3232
lenses = mod.LensFuncs()
3333
case source.Go:
@@ -38,7 +38,7 @@ func (s *Server) codeLens(ctx context.Context, params *protocol.CodeLensParams)
3838
}
3939
var result []protocol.CodeLens
4040
for cmd, lf := range lenses {
41-
if !snapshot.View().Options().Codelenses[string(cmd)] {
41+
if !snapshot.Options().Codelenses[string(cmd)] {
4242
continue
4343
}
4444
added, err := lf(ctx, snapshot, fh)

gopls/internal/lsp/command.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ func dropDependency(snapshot source.Snapshot, pm *source.ParsedModule, modulePat
426426
return nil, err
427427
}
428428
// Calculate the edits to be made due to the change.
429-
diff := snapshot.View().Options().ComputeEdits(string(pm.Mapper.Content), string(newContent))
429+
diff := snapshot.Options().ComputeEdits(string(pm.Mapper.Content), string(newContent))
430430
return source.ToProtocolEdits(pm.Mapper, diff)
431431
}
432432

@@ -633,7 +633,7 @@ func collectFileEdits(ctx context.Context, snapshot source.Snapshot, uri span.UR
633633
}
634634

635635
m := protocol.NewMapper(fh.URI(), oldContent)
636-
diff := snapshot.View().Options().ComputeEdits(string(oldContent), string(newContent))
636+
diff := snapshot.Options().ComputeEdits(string(oldContent), string(newContent))
637637
edits, err := source.ToProtocolEdits(m, diff)
638638
if err != nil {
639639
return nil, err
@@ -899,7 +899,7 @@ type pkgLoadConfig struct {
899899
func (c *commandHandler) FetchVulncheckResult(ctx context.Context, arg command.URIArg) (map[protocol.DocumentURI]*govulncheck.Result, error) {
900900
ret := map[protocol.DocumentURI]*govulncheck.Result{}
901901
err := c.run(ctx, commandConfig{forURI: arg.URI}, func(ctx context.Context, deps commandDeps) error {
902-
if deps.snapshot.View().Options().Vulncheck == source.ModeVulncheckImports {
902+
if deps.snapshot.Options().Vulncheck == source.ModeVulncheckImports {
903903
for _, modfile := range deps.snapshot.ModFiles() {
904904
res, err := deps.snapshot.ModVuln(ctx, modfile)
905905
if err != nil {
@@ -936,8 +936,7 @@ func (c *commandHandler) RunGovulncheck(ctx context.Context, args command.Vulnch
936936
}, func(ctx context.Context, deps commandDeps) error {
937937
tokenChan <- deps.work.Token()
938938

939-
view := deps.snapshot.View()
940-
opts := view.Options()
939+
opts := deps.snapshot.Options()
941940
// quickly test if gopls is compiled to support govulncheck
942941
// by checking vulncheck.Main. Alternatively, we can continue and
943942
// let the `gopls vulncheck` command fail. This is lighter-weight.

gopls/internal/lsp/completion.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func (s *Server) completion(ctx context.Context, params *protocol.CompletionPara
2929
}
3030
var candidates []completion.CompletionItem
3131
var surrounding *completion.Selection
32-
switch snapshot.View().FileKind(fh) {
32+
switch snapshot.FileKind(fh) {
3333
case source.Go:
3434
candidates, surrounding, err = completion.Completion(ctx, snapshot, fh, params.Position, params.Context)
3535
case source.Mod:
@@ -65,7 +65,7 @@ func (s *Server) completion(ctx context.Context, params *protocol.CompletionPara
6565

6666
// When using deep completions/fuzzy matching, report results as incomplete so
6767
// client fetches updated completions after every key stroke.
68-
options := snapshot.View().Options()
68+
options := snapshot.Options()
6969
incompleteResults := options.DeepCompletion || options.Matcher == source.Fuzzy
7070

7171
items := toProtocolCompletionItems(candidates, rng, options)

gopls/internal/lsp/definition.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func (s *Server) definition(ctx context.Context, params *protocol.DefinitionPara
2626
if !ok {
2727
return nil, err
2828
}
29-
switch kind := snapshot.View().FileKind(fh); kind {
29+
switch kind := snapshot.FileKind(fh); kind {
3030
case source.Tmpl:
3131
return template.Definition(snapshot, fh, params.Position)
3232
case source.Go:
@@ -51,7 +51,7 @@ func (s *Server) typeDefinition(ctx context.Context, params *protocol.TypeDefini
5151
if !ok {
5252
return nil, err
5353
}
54-
switch kind := snapshot.View().FileKind(fh); kind {
54+
switch kind := snapshot.FileKind(fh); kind {
5555
case source.Go:
5656
return source.TypeDefinition(ctx, snapshot, fh, params.Position)
5757
default:

gopls/internal/lsp/diagnostics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (s *Server) diagnoseSnapshots(snapshots map[source.Snapshot][]span.URI, onD
161161
diagnosticWG.Add(1)
162162
go func(snapshot source.Snapshot, uris []span.URI) {
163163
defer diagnosticWG.Done()
164-
s.diagnoseSnapshot(snapshot, uris, onDisk, snapshot.View().Options().DiagnosticsDelay)
164+
s.diagnoseSnapshot(snapshot, uris, onDisk, snapshot.Options().DiagnosticsDelay)
165165
}(snapshot, uris)
166166
}
167167
diagnosticWG.Wait()

gopls/internal/lsp/folding_range.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (s *Server) foldingRange(ctx context.Context, params *protocol.FoldingRange
2323
return nil, err
2424
}
2525

26-
ranges, err := source.FoldingRange(ctx, snapshot, fh, snapshot.View().Options().LineFoldingOnly)
26+
ranges, err := source.FoldingRange(ctx, snapshot, fh, snapshot.Options().LineFoldingOnly)
2727
if err != nil {
2828
return nil, err
2929
}

gopls/internal/lsp/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (s *Server) formatting(ctx context.Context, params *protocol.DocumentFormat
2424
if !ok {
2525
return nil, err
2626
}
27-
switch snapshot.View().FileKind(fh) {
27+
switch snapshot.FileKind(fh) {
2828
case source.Mod:
2929
return mod.Format(ctx, snapshot, fh)
3030
case source.Go:

gopls/internal/lsp/highlight.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (s *Server) documentHighlight(ctx context.Context, params *protocol.Documen
2424
return nil, err
2525
}
2626

27-
if snapshot.View().FileKind(fh) == source.Tmpl {
27+
if snapshot.FileKind(fh) == source.Tmpl {
2828
return template.Highlight(ctx, snapshot, fh, params.Position)
2929
}
3030

gopls/internal/lsp/hover.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (s *Server) hover(ctx context.Context, params *protocol.HoverParams) (*prot
2525
if !ok {
2626
return nil, err
2727
}
28-
switch snapshot.View().FileKind(fh) {
28+
switch snapshot.FileKind(fh) {
2929
case source.Mod:
3030
return mod.Hover(ctx, snapshot, fh, params.Position)
3131
case source.Go:

gopls/internal/lsp/inlay_hint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (s *Server) inlayHint(ctx context.Context, params *protocol.InlayHintParams
2323
if !ok {
2424
return nil, err
2525
}
26-
switch snapshot.View().FileKind(fh) {
26+
switch snapshot.FileKind(fh) {
2727
case source.Mod:
2828
return mod.InlayHint(ctx, snapshot, fh, params.Range)
2929
case source.Go:

gopls/internal/lsp/link.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (s *Server) documentLink(ctx context.Context, params *protocol.DocumentLink
3232
if !ok {
3333
return nil, err
3434
}
35-
switch snapshot.View().FileKind(fh) {
35+
switch snapshot.FileKind(fh) {
3636
case source.Mod:
3737
links, err = modLinks(ctx, snapshot, fh)
3838
case source.Go:
@@ -69,7 +69,7 @@ func modLinks(ctx context.Context, snapshot source.Snapshot, fh source.FileHandl
6969
}
7070
// Shift the start position to the location of the
7171
// dependency within the require statement.
72-
target := source.BuildLink(snapshot.View().Options().LinkTarget, "mod/"+req.Mod.String(), "")
72+
target := source.BuildLink(snapshot.Options().LinkTarget, "mod/"+req.Mod.String(), "")
7373
l, err := toProtocolLink(pm.Mapper, target, start+i, start+i+len(dep))
7474
if err != nil {
7575
return nil, err
@@ -82,7 +82,7 @@ func modLinks(ctx context.Context, snapshot source.Snapshot, fh source.FileHandl
8282
}
8383

8484
// Get all the links that are contained in the comments of the file.
85-
urlRegexp := snapshot.View().Options().URLRegexp
85+
urlRegexp := snapshot.Options().URLRegexp
8686
for _, expr := range pm.File.Syntax.Stmt {
8787
comments := expr.Comment()
8888
if comments == nil {
@@ -103,7 +103,6 @@ func modLinks(ctx context.Context, snapshot source.Snapshot, fh source.FileHandl
103103

104104
// goLinks returns the set of hyperlink annotations for the specified Go file.
105105
func goLinks(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle) ([]protocol.DocumentLink, error) {
106-
view := snapshot.View()
107106

108107
pgf, err := snapshot.ParseGo(ctx, fh, source.ParseFull)
109108
if err != nil {
@@ -113,12 +112,12 @@ func goLinks(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle
113112
var links []protocol.DocumentLink
114113

115114
// Create links for import specs.
116-
if view.Options().ImportShortcut.ShowLinks() {
115+
if snapshot.Options().ImportShortcut.ShowLinks() {
117116

118117
// If links are to pkg.go.dev, append module version suffixes.
119118
// This requires the import map from the package metadata. Ignore errors.
120119
var depsByImpPath map[source.ImportPath]source.PackageID
121-
if strings.ToLower(view.Options().LinkTarget) == "pkg.go.dev" {
120+
if strings.ToLower(snapshot.Options().LinkTarget) == "pkg.go.dev" {
122121
if meta, err := source.NarrowestMetadataForFile(ctx, snapshot, fh.URI()); err == nil {
123122
depsByImpPath = meta.DepsByImpPath
124123
}
@@ -130,7 +129,7 @@ func goLinks(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle
130129
continue // bad import
131130
}
132131
// See golang/go#36998: don't link to modules matching GOPRIVATE.
133-
if view.IsGoPrivatePath(string(importPath)) {
132+
if snapshot.View().IsGoPrivatePath(string(importPath)) {
134133
continue
135134
}
136135

@@ -145,7 +144,7 @@ func goLinks(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle
145144
if err != nil {
146145
return nil, err
147146
}
148-
targetURL := source.BuildLink(view.Options().LinkTarget, urlPath, "")
147+
targetURL := source.BuildLink(snapshot.Options().LinkTarget, urlPath, "")
149148
// Account for the quotation marks in the positions.
150149
l, err := toProtocolLink(pgf.Mapper, targetURL, start+len(`"`), end-len(`"`))
151150
if err != nil {
@@ -155,7 +154,7 @@ func goLinks(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle
155154
}
156155
}
157156

158-
urlRegexp := snapshot.View().Options().URLRegexp
157+
urlRegexp := snapshot.Options().URLRegexp
159158

160159
// Gather links found in string literals.
161160
var str []*ast.BasicLit

gopls/internal/lsp/mod/diagnostics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func ModVulnerabilityDiagnostics(ctx context.Context, snapshot source.Snapshot,
192192

193193
diagSource := source.Govulncheck
194194
vs := snapshot.View().Vulnerabilities(fh.URI())[fh.URI()]
195-
if vs == nil && snapshot.View().Options().Vulncheck == source.ModeVulncheckImports {
195+
if vs == nil && snapshot.Options().Vulncheck == source.ModeVulncheckImports {
196196
vs, err = snapshot.ModVuln(ctx, fh.URI())
197197
if err != nil {
198198
return nil, err

gopls/internal/lsp/mod/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ func Format(ctx context.Context, snapshot source.Snapshot, fh source.FileHandle)
2525
return nil, err
2626
}
2727
// Calculate the edits to be made due to the change.
28-
diffs := snapshot.View().Options().ComputeEdits(string(pm.Mapper.Content), string(formatted))
28+
diffs := snapshot.Options().ComputeEdits(string(pm.Mapper.Content), string(formatted))
2929
return source.ToProtocolEdits(pm.Mapper, diffs)
3030
}

gopls/internal/lsp/mod/hover.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func hoverOnRequireStatement(ctx context.Context, pm *source.ParsedModule, offse
8282
// Get the vulnerability info.
8383
fromGovulncheck := true
8484
vs := snapshot.View().Vulnerabilities(fh.URI())[fh.URI()]
85-
if vs == nil && snapshot.View().Options().Vulncheck == source.ModeVulncheckImports {
85+
if vs == nil && snapshot.Options().Vulncheck == source.ModeVulncheckImports {
8686
var err error
8787
vs, err = snapshot.ModVuln(ctx, fh.URI())
8888
if err != nil {
@@ -109,7 +109,7 @@ func hoverOnRequireStatement(ctx context.Context, pm *source.ParsedModule, offse
109109
if err != nil {
110110
return nil, err
111111
}
112-
options := snapshot.View().Options()
112+
options := snapshot.Options()
113113
isPrivate := snapshot.View().IsGoPrivatePath(req.Mod.Path)
114114
header := formatHeader(req.Mod.Path, options)
115115
explanation = formatExplanation(explanation, req, options, isPrivate)
@@ -140,7 +140,7 @@ func hoverOnModuleStatement(ctx context.Context, pm *source.ParsedModule, offset
140140
fromGovulncheck := true
141141
vs := snapshot.View().Vulnerabilities(fh.URI())[fh.URI()]
142142

143-
if vs == nil && snapshot.View().Options().Vulncheck == source.ModeVulncheckImports {
143+
if vs == nil && snapshot.Options().Vulncheck == source.ModeVulncheckImports {
144144
vs, err = snapshot.ModVuln(ctx, fh.URI())
145145
if err != nil {
146146
return nil, false
@@ -150,7 +150,7 @@ func hoverOnModuleStatement(ctx context.Context, pm *source.ParsedModule, offset
150150
modpath := "stdlib"
151151
goVersion := snapshot.View().GoVersionString()
152152
affecting, nonaffecting := lookupVulns(vs, modpath, goVersion)
153-
options := snapshot.View().Options()
153+
options := snapshot.Options()
154154
vulns := formatVulnerabilities(modpath, affecting, nonaffecting, options, fromGovulncheck)
155155

156156
return &protocol.Hover{

gopls/internal/lsp/references.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (s *Server) references(ctx context.Context, params *protocol.ReferenceParam
2323
if !ok {
2424
return nil, err
2525
}
26-
if snapshot.View().FileKind(fh) == source.Tmpl {
26+
if snapshot.FileKind(fh) == source.Tmpl {
2727
return template.References(ctx, snapshot, fh, params)
2828
}
2929
return source.References(ctx, snapshot, fh, params.Position, params.Context.IncludeDeclaration)

gopls/internal/lsp/semantic.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,12 @@ func (s *Server) computeSemanticTokens(ctx context.Context, td protocol.TextDocu
6363
if !ok {
6464
return nil, err
6565
}
66-
vv := snapshot.View()
67-
if !vv.Options().SemanticTokens {
66+
if !snapshot.Options().SemanticTokens {
6867
// return an error, so if the option changes
6968
// the client won't remember the wrong answer
7069
return nil, fmt.Errorf("semantictokens are disabled")
7170
}
72-
kind := snapshot.View().FileKind(fh)
71+
kind := snapshot.FileKind(fh)
7372
if kind == source.Tmpl {
7473
// this is a little cumbersome to avoid both exporting 'encoded' and its methods
7574
// and to avoid import cycles
@@ -111,8 +110,8 @@ func (s *Server) computeSemanticTokens(ctx context.Context, td protocol.TextDocu
111110
fset: pkg.FileSet(),
112111
tokTypes: s.session.Options().SemanticTypes,
113112
tokMods: s.session.Options().SemanticMods,
114-
noStrings: vv.Options().NoSemanticString,
115-
noNumbers: vv.Options().NoSemanticNumber,
113+
noStrings: snapshot.Options().NoSemanticString,
114+
noNumbers: snapshot.Options().NoSemanticNumber,
116115
}
117116
if err := e.init(); err != nil {
118117
// e.init should never return an error, unless there's some

0 commit comments

Comments
 (0)