-
Notifications
You must be signed in to change notification settings - Fork 763
Remove GetOptionsDiagnostics #2322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1031,7 +1031,10 @@ func (p *Program) GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic { | |
| return nil | ||
| } | ||
|
|
||
| pool := p.checkerPool.(*checkerPool) | ||
| pool, ok := p.checkerPool.(*checkerPool) | ||
| if !ok { | ||
| return nil // !!! Global diagnostics in the editor? | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whenever we get around to revamping how the checkers are allocated, I think the fix is going to be to (in the editor) collect global diags from diagnostic-producing checkers, and then re-collect them whenever we check a new file, then expose those diags there. |
||
| } | ||
|
|
||
| globalDiagnostics := make([][]*ast.Diagnostic, len(pool.checkers)) | ||
| pool.forEachCheckerParallel(func(idx int, checker *checker.Checker) { | ||
|
|
@@ -1045,17 +1048,6 @@ func (p *Program) GetDeclarationDiagnostics(ctx context.Context, sourceFile *ast | |
| return p.collectDiagnostics(ctx, sourceFile, true /*concurrent*/, p.getDeclarationDiagnosticsForFile) | ||
| } | ||
|
|
||
| func (p *Program) GetOptionsDiagnostics(ctx context.Context) []*ast.Diagnostic { | ||
| return SortAndDeduplicateDiagnostics(core.Concatenate(p.GetGlobalDiagnostics(ctx), p.getOptionsDiagnosticsOfConfigFile())) | ||
| } | ||
|
|
||
| func (p *Program) getOptionsDiagnosticsOfConfigFile() []*ast.Diagnostic { | ||
| if p.Options() == nil || p.Options().ConfigFilePath == "" { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This used to be here because we could fail to get file parsing diags. But then we made |
||
| return nil | ||
| } | ||
| return p.GetConfigFileParsingDiagnostics() | ||
| } | ||
|
|
||
| func FilterNoEmitSemanticDiagnostics(diagnostics []*ast.Diagnostic, options *core.CompilerOptions) []*ast.Diagnostic { | ||
| if !options.NoEmit.IsTrue() { | ||
| return diagnostics | ||
|
|
@@ -1445,7 +1437,6 @@ type ProgramLike interface { | |
| GetConfigFileParsingDiagnostics() []*ast.Diagnostic | ||
| GetSyntacticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic | ||
| GetBindDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic | ||
| GetOptionsDiagnostics(ctx context.Context) []*ast.Diagnostic | ||
| GetProgramDiagnostics() []*ast.Diagnostic | ||
| GetGlobalDiagnostics(ctx context.Context) []*ast.Diagnostic | ||
| GetSemanticDiagnostics(ctx context.Context, file *ast.SourceFile) []*ast.Diagnostic | ||
|
|
@@ -1494,18 +1485,16 @@ func GetDiagnosticsOfAnyProgram( | |
| allDiagnostics = append(allDiagnostics, program.GetProgramDiagnostics()...) | ||
|
|
||
| if len(allDiagnostics) == configFileParsingDiagnosticsLength { | ||
| // Options diagnostics include global diagnostics (even though we collect them separately), | ||
| // and global diagnostics create checkers, which then bind all of the files. Do this binding | ||
| // early so we can track the time. | ||
| // Do binding early so we can track the time. | ||
| getBindDiagnostics(ctx, file) | ||
|
|
||
| allDiagnostics = append(allDiagnostics, program.GetOptionsDiagnostics(ctx)...) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note above how we get config file diags, then get options diags, and then get global diags. This means we could have the same diags repeated twice! (This func does not sort and dedupe, for some reason) |
||
|
|
||
| if program.Options().ListFilesOnly.IsFalseOrUnknown() { | ||
| allDiagnostics = append(allDiagnostics, program.GetGlobalDiagnostics(ctx)...) | ||
|
|
||
| if len(allDiagnostics) == configFileParsingDiagnosticsLength { | ||
| allDiagnostics = append(allDiagnostics, getSemanticDiagnostics(ctx, file)...) | ||
| // Ask for the global diagnostics again (they were empty above); we may have found new during checking, e.g. missing globals. | ||
| allDiagnostics = append(allDiagnostics, program.GetGlobalDiagnostics(ctx)...) | ||
| } | ||
|
|
||
| if (skipNoEmitCheckForDtsDiagnostics || program.Options().NoEmit.IsTrue()) && program.Options().GetEmitDeclarations() && len(allDiagnostics) == configFileParsingDiagnosticsLength { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,12 +132,6 @@ func (p *Program) GetBindDiagnostics(ctx context.Context, file *ast.SourceFile) | |
| return p.program.GetBindDiagnostics(ctx, file) | ||
| } | ||
|
|
||
| // GetOptionsDiagnostics implements compiler.AnyProgram interface. | ||
| func (p *Program) GetOptionsDiagnostics(ctx context.Context) []*ast.Diagnostic { | ||
| p.panicIfNoProgram("GetOptionsDiagnostics") | ||
| return p.program.GetOptionsDiagnostics(ctx) | ||
| } | ||
|
|
||
| func (p *Program) GetProgramDiagnostics() []*ast.Diagnostic { | ||
| p.panicIfNoProgram("GetProgramDiagnostics") | ||
| return p.program.GetProgramDiagnostics() | ||
|
|
@@ -365,7 +359,6 @@ func (p *Program) ensureHasErrorsForState(ctx context.Context, program *compiler | |
| len(program.GetConfigFileParsingDiagnostics()) > 0 || | ||
| len(program.GetSyntacticDiagnostics(ctx, nil)) > 0 || | ||
| len(program.GetProgramDiagnostics()) > 0 || | ||
| len(program.GetOptionsDiagnostics(ctx)) > 0 || | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This list already contains |
||
| len(program.GetGlobalDiagnostics(ctx)) > 0 { | ||
| p.snapshot.hasErrors = core.TSTrue | ||
| // Dont need to encode semantic errors state since the syntax and program diagnostics are encoded as present | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.