Skip to content

Commit d381d13

Browse files
committed
Also delete GetGlobalDiagnostics
1 parent 401c4ba commit d381d13

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

internal/compiler/program.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,11 @@ func (p *Program) GetBindDiagnostics(ctx context.Context, sourceFile *ast.Source
456456
}
457457

458458
func (p *Program) GetSemanticDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic {
459-
return p.collectDiagnostics(ctx, sourceFile, true /*concurrent*/, p.getSemanticDiagnosticsForFile)
459+
diags := p.collectDiagnostics(ctx, sourceFile, true /*concurrent*/, p.getSemanticDiagnosticsForFile)
460+
if sourceFile == nil {
461+
diags = core.Concatenate(diags, p.getGlobalDiagnostics())
462+
}
463+
return SortAndDeduplicateDiagnostics(diags)
460464
}
461465

462466
func (p *Program) GetSemanticDiagnosticsWithoutNoEmitFiltering(ctx context.Context, sourceFiles []*ast.SourceFile) map[*ast.SourceFile][]*ast.Diagnostic {
@@ -1026,7 +1030,7 @@ func emitModuleKindIsNonNodeESM(moduleKind core.ModuleKind) bool {
10261030
return moduleKind >= core.ModuleKindES2015 && moduleKind <= core.ModuleKindESNext
10271031
}
10281032

1029-
func (p *Program) GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic {
1033+
func (p *Program) getGlobalDiagnostics() []*ast.Diagnostic {
10301034
if len(p.files) == 0 {
10311035
return nil
10321036
}
@@ -1041,7 +1045,7 @@ func (p *Program) GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic {
10411045
globalDiagnostics[idx] = checker.GetGlobalDiagnostics()
10421046
})
10431047

1044-
return SortAndDeduplicateDiagnostics(slices.Concat(globalDiagnostics...))
1048+
return slices.Concat(globalDiagnostics...)
10451049
}
10461050

10471051
func (p *Program) GetDeclarationDiagnostics(ctx context.Context, sourceFile *ast.SourceFile) []*ast.Diagnostic {
@@ -1438,7 +1442,6 @@ type ProgramLike interface {
14381442
GetSyntacticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic
14391443
GetBindDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic
14401444
GetProgramDiagnostics() []*ast.Diagnostic
1441-
GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic
14421445
GetSemanticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic
14431446
GetDeclarationDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic
14441447
GetSuggestionDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic
@@ -1489,15 +1492,11 @@ func GetDiagnosticsOfAnyProgram(
14891492
getBindDiagnostics(ctx, file)
14901493

14911494
if program.Options().ListFilesOnly.IsFalseOrUnknown() {
1492-
allDiagnostics = append(allDiagnostics, program.GetGlobalDiagnostics(ctx)...)
1493-
14941495
if len(allDiagnostics) == configFileParsingDiagnosticsLength {
14951496
allDiagnostics = append(allDiagnostics, getSemanticDiagnostics(ctx, file)...)
1496-
// Ask for the global diagnostics again (they were empty above); we may have found new during checking, e.g. missing globals.
1497-
allDiagnostics = append(allDiagnostics, program.GetGlobalDiagnostics(ctx)...)
14981497
}
14991498

1500-
if (skipNoEmitCheckForDtsDiagnostics || program.Options().NoEmit.IsTrue()) && program.Options().GetEmitDeclarations() && len(allDiagnostics) == configFileParsingDiagnosticsLength {
1499+
if len(allDiagnostics) == configFileParsingDiagnosticsLength && (skipNoEmitCheckForDtsDiagnostics || program.Options().NoEmit.IsTrue()) && program.Options().GetEmitDeclarations() {
15011500
allDiagnostics = append(allDiagnostics, program.GetDeclarationDiagnostics(ctx, file)...)
15021501
}
15031502
}

internal/execute/incremental/program.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ func (p *Program) GetProgramDiagnostics() []*ast.Diagnostic {
137137
return p.program.GetProgramDiagnostics()
138138
}
139139

140-
func (p *Program) GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic {
141-
p.panicIfNoProgram("GetGlobalDiagnostics")
142-
return p.program.GetGlobalDiagnostics(ctx)
143-
}
144-
145140
// GetSemanticDiagnostics implements compiler.AnyProgram interface.
146141
func (p *Program) GetSemanticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic {
147142
p.panicIfNoProgram("GetSemanticDiagnostics")
@@ -358,8 +353,7 @@ func (p *Program) ensureHasErrorsForState(ctx context.Context, program *compiler
358353
if hasIncludeProcessingDiagnostics() ||
359354
len(program.GetConfigFileParsingDiagnostics()) > 0 ||
360355
len(program.GetSyntacticDiagnostics(ctx, nil)) > 0 ||
361-
len(program.GetProgramDiagnostics()) > 0 ||
362-
len(program.GetGlobalDiagnostics(ctx)) > 0 {
356+
len(program.GetProgramDiagnostics()) > 0 {
363357
p.snapshot.hasErrors = core.TSTrue
364358
// Dont need to encode semantic errors state since the syntax and program diagnostics are encoded as present
365359
p.snapshot.hasSemanticErrors = false

internal/testutil/harnessutil/harnessutil.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ func compileFilesWithHost(
681681
diagnostics = append(diagnostics, program.GetProgramDiagnostics()...)
682682
diagnostics = append(diagnostics, program.GetSyntacticDiagnostics(ctx, nil)...)
683683
diagnostics = append(diagnostics, program.GetSemanticDiagnostics(ctx, nil)...)
684-
diagnostics = append(diagnostics, program.GetGlobalDiagnostics(ctx)...)
685684
if config.CompilerOptions().GetEmitDeclarations() {
686685
diagnostics = append(diagnostics, program.GetDeclarationDiagnostics(ctx, nil)...)
687686
}

0 commit comments

Comments
 (0)