@@ -49,8 +49,7 @@ func (s *Server) computeSemanticTokens(ctx context.Context, td protocol.TextDocu
49
49
ans := protocol.SemanticTokens {
50
50
Data : []uint32 {},
51
51
}
52
- kind := source .DetectLanguage ("" , td .URI .SpanURI ().Filename ())
53
- snapshot , _ , ok , release , err := s .beginFileRequest (ctx , td .URI , kind )
52
+ snapshot , fh , ok , release , err := s .beginFileRequest (ctx , td .URI , source .UnknownKind )
54
53
defer release ()
55
54
if ! ok {
56
55
return nil , err
@@ -61,7 +60,7 @@ func (s *Server) computeSemanticTokens(ctx context.Context, td protocol.TextDocu
61
60
// the client won't remember the wrong answer
62
61
return nil , errors .Errorf ("semantictokens are disabled" )
63
62
}
64
- if kind == source .Tmpl {
63
+ if fh . Kind () == source .Tmpl {
65
64
// this is a little cumbersome to avoid both exporting 'encoded' and its methods
66
65
// and to avoid import cycles
67
66
e := & encoded {
@@ -76,14 +75,14 @@ func (s *Server) computeSemanticTokens(ctx context.Context, td protocol.TextDocu
76
75
data := func () ([]uint32 , error ) {
77
76
return e .Data ()
78
77
}
79
- return template .SemanticTokens (ctx , snapshot , td .URI . SpanURI (), add , data )
78
+ return template .SemanticTokens (ctx , snapshot , fh .URI (), add , data )
80
79
}
81
- pkg , err := snapshot .PackageForFile (ctx , td .URI . SpanURI (), source .TypecheckFull , source .WidestPackage )
80
+ pkg , err := snapshot .PackageForFile (ctx , fh .URI (), source .TypecheckFull , source .WidestPackage )
82
81
if err != nil {
83
82
return nil , err
84
83
}
85
84
info := pkg .GetTypesInfo ()
86
- pgf , err := pkg .File (td .URI . SpanURI ())
85
+ pgf , err := pkg .File (fh .URI ())
87
86
if err != nil {
88
87
return nil , err
89
88
}
@@ -92,7 +91,7 @@ func (s *Server) computeSemanticTokens(ctx context.Context, td protocol.TextDocu
92
91
}
93
92
if rng == nil && len (pgf .Src ) > maxFullFileSize {
94
93
err := fmt .Errorf ("semantic tokens: file %s too large for full (%d>%d)" ,
95
- td .URI . SpanURI ().Filename (), len (pgf .Src ), maxFullFileSize )
94
+ fh .URI ().Filename (), len (pgf .Src ), maxFullFileSize )
96
95
return nil , err
97
96
}
98
97
e := & encoded {
0 commit comments