Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
jakebailey wants to merge5 commits intomain
base:main
Choose a base branch
Loading
fromjabaile/remove-options-diags

Conversation

@jakebailey
Copy link
Member

"Options diagnostics" were just config file diagnostics + global diagnostics.

This was odd, because we then took that in places and combined it with... config file diags and global diags. And then not deduping it, sometimes.

This PR just removesGetOptionsDiagnostics altogether, instead leaving behind justGetConfigFileParsingDiagnostics andGetGlobalDiagnostics.

The language server still does not ever callGetGlobalDiagnostics. I am not sure where such a thing would go, since global diagnostics are generated as a side effect of doing checking (e.g., when we figure out thatAsyncIterable was never declared or something).

There's a baseline change, but I think it's correct and positive.

Copy link
Contributor

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull request overview

This PR removes theGetOptionsDiagnostics method, which redundantly combined config file diagnostics and global diagnostics. The code now directly usesGetConfigFileParsingDiagnostics andGetGlobalDiagnostics instead, eliminating unnecessary duplication and improving diagnostic handling clarity.

Key changes:

  • RemovedGetOptionsDiagnostics method and its helper from theProgram struct
  • Updated diagnostic collection logic to callGetConfigFileParsingDiagnostics andGetGlobalDiagnostics directly
  • Added a safety check inGetGlobalDiagnostics to handle editor scenarios

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

FileDescription
testdata/baselines/reference/tsbuildWatch/configFileErrors/reports-syntax-errors-in-config-file.jsUpdated test baseline to reflect removal ofsemanticDiagnosticsPerFile field and changes to diagnostic caching behavior
testdata/baselines/reference/tsbuild/configFileErrors/reports-syntax-errors-in-config-file.jsUpdated test baseline with same changes as watch variant
internal/execute/incremental/program.goRemovedGetOptionsDiagnostics method wrapper and its usage in error state checking
internal/compiler/program.goRemovedGetOptionsDiagnostics and helper methods, added type assertion safety check, updatedGetDiagnosticsOfAnyProgram to call diagnostics methods directly

pool:=p.checkerPool.(*checkerPool)
pool,ok:=p.checkerPool.(*checkerPool)
if!ok {
returnnil// !!! Global diagnostics in the editor?
Copy link
MemberAuthor

Choose a reason for hiding this comment

The 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.

}

func (p*Program)getOptionsDiagnosticsOfConfigFile() []*ast.Diagnostic {
ifp.Options()==nil||p.Options().ConfigFilePath=="" {
Copy link
MemberAuthor

Choose a reason for hiding this comment

The 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 madeParsedCommandLine mandatory, so this call always succeeds, so there's no reason to special case anything.

// Do binding early so we can track the time.
getBindDiagnostics(ctx,file)

allDiagnostics=append(allDiagnostics,program.GetOptionsDiagnostics(ctx)...)
Copy link
MemberAuthor

@jakebaileyjakebaileyDec 10, 2025
edited
Loading

Choose a reason for hiding this comment

The 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)

len(program.GetConfigFileParsingDiagnostics())>0||
len(program.GetSyntacticDiagnostics(ctx,nil))>0||
len(program.GetProgramDiagnostics())>0||
len(program.GetOptionsDiagnostics(ctx))>0||
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This list already containsGetConfigFileParsingDiagnostics andGetGlobalDiagnostics, so this is a noop.

iflen(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)...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Strada use to add them to semantic Diagnostics - this ensured that all callers of this API didnt have to worry about it?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We can do that, if and only if the caller passes in anil file, theoretically.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pushed a change which I think works to deleteGetGlobalDiagnostics too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

well - strada did the exact opposite. It added to "per file semanticDiagnostics" because thats how editor gets diagnostics and it shouldnt miss them?

functiongetDiagnosticsWorker(sourceFile:SourceFile,nodesToCheck:Node[]|undefined):Diagnostic[]{if(sourceFile){ensurePendingDiagnosticWorkComplete();// Some global diagnostics are deferred until they are needed and// may not be reported in the first call to getGlobalDiagnostics.// We should catch these changes and report them.constpreviousGlobalDiagnostics=diagnostics.getGlobalDiagnostics();constpreviousGlobalDiagnosticsSize=previousGlobalDiagnostics.length;checkSourceFileWithEagerDiagnostics(sourceFile,nodesToCheck);constsemanticDiagnostics=diagnostics.getDiagnostics(sourceFile.fileName);if(nodesToCheck){// No need to get global diagnostics.returnsemanticDiagnostics;}constcurrentGlobalDiagnostics=diagnostics.getGlobalDiagnostics();if(currentGlobalDiagnostics!==previousGlobalDiagnostics){// If the arrays are not the same reference, new diagnostics were added.constdeferredGlobalDiagnostics=relativeComplement(previousGlobalDiagnostics,currentGlobalDiagnostics,compareDiagnostics);returnconcatenate(deferredGlobalDiagnostics,semanticDiagnostics);}elseif(previousGlobalDiagnosticsSize===0&&currentGlobalDiagnostics.length>0){// If the arrays are the same reference, but the length has changed, a single// new diagnostic was added as DiagnosticCollection attempts to reuse the// same array.returnconcatenate(currentGlobalDiagnostics,semanticDiagnostics);}returnsemanticDiagnostics;}// Global diagnostics are always added when a file is not provided to// getDiagnosticsforEach(host.getSourceFiles(),file=>checkSourceFileWithEagerDiagnostics(file));returndiagnostics.getDiagnostics();}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not suire if we have enough coverage for diagnostics in fourslash but all this logic was for editor to not miss reporting errors as for command line you can always get all semantic diagnostics and then global diagnsotics?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not suire if we have enough coverage for diagnostics in fourslash but all this logic was for editor to not miss reporting errors as for command line you can always get all semantic diagnostics and then global diagnsotics?

The current LS can miss these global diagnostics, yes. Though, that isn't new...

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The last commit I did was bad, though, because it locks off ever asking for global diags in the LS where we never ask for all files, so I'll undo that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not suire if we have enough coverage for diagnostics in fourslash but all this logic was for editor to not miss reporting errors as for command line you can always get all semantic diagnostics and then global diagnsotics?

The current LS can miss these global diagnostics, yes. Though, that isn't new...

It is new right, given we use to add the new diagnostics to semantic diagnostics and send it back to client ?

getBindAndCheckDiagnosticsForFile

It shouldnt be part of this as these are the ones that are cached in buildInfo and need to be consistent

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm confused enough with how to make this work that I wish we just didn't have global diags at all, they just really do depend on whether or not a file was checked and in which order, which does not feel reasonable to manage?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Havent checked how diagnostics are handled in corsa but with push diagnostics we can control the order but not sure how to handle that as part of pull diagnostics esp since global diagnostics are checker diagnostics without any file info. (may be we just need to make sure that checker cannot generate global diagnostics) ?

@jakebaileyjakebailey changed the titleRemove GetOptionsDiagnosticsRemove GetOptionsDiagnostics, GetGlobalDiagnosticsDec 10, 2025
@jakebaileyjakebailey marked this pull request as draftDecember 10, 2025 19:35
@jakebaileyjakebailey changed the titleRemove GetOptionsDiagnostics, GetGlobalDiagnosticsRemove GetOptionsDiagnosticsDec 10, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@sheetalkamatsheetalkamatsheetalkamat left review comments

Copilot code reviewCopilotCopilot left review comments

@DanielRosenwasserDanielRosenwasserAwaiting requested review from DanielRosenwasser

@andrewbranchandrewbranchAwaiting requested review from andrewbranch

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@jakebailey@sheetalkamat

[8]ページ先頭

©2009-2025 Movatter.jp