@@ -31,6 +31,7 @@ import (
3131 "github.com/microsoft/typescript-go/internal/lsp/lsproto"
3232 "github.com/microsoft/typescript-go/internal/module"
3333 "github.com/microsoft/typescript-go/internal/packagejson"
34+ "github.com/microsoft/typescript-go/internal/parser"
3435 "github.com/microsoft/typescript-go/internal/project"
3536 "github.com/microsoft/typescript-go/internal/project/ata"
3637 "github.com/microsoft/typescript-go/internal/sourcemap"
@@ -215,7 +216,7 @@ func (h *DenoLanguageServiceHost) FormatOptions() *format.FormatCodeSettings {
215216
216217func (h * DenoLanguageServiceHost ) GetECMALineInfo (fileName string ) * sourcemap.ECMALineInfo {
217218 if data := h .vfs .GetDocument (fileName ); data != nil {
218- return sourcemap .CreateECMALineInfo (* data .Text , data .LineStarts )
219+ return sourcemap .CreateECMALineInfo (data .Text , data .LineStarts )
219220 }
220221 return nil
221222}
@@ -268,7 +269,7 @@ func (v *DenoVFS) GetDocument(path string) *lsproto.DenoDocumentData {
268269 }
269270 var response lsproto.DenoDocumentData
270271 err := v .server .sendRequestSync (v .ctx , lsproto .MethodDenoCallback , params , & response )
271- if err != nil || response . Text == nil {
272+ if err != nil {
272273 return nil
273274 }
274275 if v .server .deno .documentCache != nil {
@@ -279,7 +280,7 @@ func (v *DenoVFS) GetDocument(path string) *lsproto.DenoDocumentData {
279280
280281func (v * DenoVFS ) ReadFile (path string ) (contents string , ok bool ) {
281282 if data := v .GetDocument (path ); data != nil {
282- return * data .Text , true
283+ return data .Text , true
283284 }
284285 return "" , false
285286}
@@ -362,7 +363,7 @@ func (h *denoAutoImportHost) Dispose() {
362363type denoCompilerHost struct {
363364 inner compiler.CompilerHost
364365 server * Server
365- ctx context. Context
366+ vfs * DenoVFS
366367 compilerOptionsKey string
367368 notebookUri * string
368369}
@@ -386,7 +387,19 @@ func (h *denoCompilerHost) Trace(msg *diagnostics.Message, args ...any) {
386387}
387388
388389func (h * denoCompilerHost ) GetSourceFile (opts ast.SourceFileParseOptions ) * ast.SourceFile {
389- return h .inner .GetSourceFile (opts )
390+ data := h .vfs .GetDocument (opts .FileName )
391+ if data == nil {
392+ return nil
393+ }
394+ scriptKind := data .ScriptKind
395+ if scriptKind == core .ScriptKindUnknown {
396+ scriptKind = core .GetScriptKindFromFileName (opts .FileName )
397+ }
398+ sourceFile := parser .ParseSourceFile (opts , data .Text , scriptKind )
399+ if data .IsNotebookCell {
400+ sourceFile .ExternalModuleIndicator = nil
401+ }
402+ return sourceFile
390403}
391404
392405func (h * denoCompilerHost ) GetResolvedProjectReference (fileName string , path tspath.Path ) * tsoptions.ParsedCommandLine {
@@ -408,7 +421,7 @@ func (h *denoCompilerHost) MakeResolver(host module.ResolutionHost, options *cor
408421 return & denoResolver {
409422 inner : baseResolver ,
410423 server : h .server ,
411- ctx : h .ctx ,
424+ ctx : h .vfs . ctx ,
412425 compilerOptionsKey : h .compilerOptionsKey ,
413426 notebookUri : h .notebookUri ,
414427 }
@@ -1384,7 +1397,7 @@ func (s *Server) handleDenoRequest(ctx context.Context, params *lsproto.DenoRequ
13841397 newHost := & denoCompilerHost {
13851398 inner : baseHost ,
13861399 server : s ,
1387- ctx : pe .vfs . ctx ,
1400+ vfs : pe .vfs ,
13881401 compilerOptionsKey : pe .compilerOptionsKey ,
13891402 notebookUri : pe .notebookUri ,
13901403 }
@@ -1596,7 +1609,7 @@ func (s *Server) createDenoProgramEntry(ctx context.Context, compilerOptionsKey
15961609 compilerHost := & denoCompilerHost {
15971610 inner : baseHost ,
15981611 server : s ,
1599- ctx : ctx ,
1612+ vfs : denoVFS ,
16001613 compilerOptionsKey : compilerOptionsKey ,
16011614 notebookUri : notebookUri ,
16021615 }
0 commit comments