-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
fix(compiler-cli): report non-template diagnostics #40331
Conversation
8531795
to
03e2894
Compare
0fc956b
to
697504c
Compare
9999842
to
0d22a3c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if (file === undefined) { | ||
return this.compiler.getDiagnostics(); | ||
} | ||
return this.compiler.getDiagnosticsForFile(file, OptimizeFor.WholeProgram); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alxhub , I made this use WholeProgram optimization for two reasons.
- the previous behavior used WholeProgram, so it's better not to change it unless we have a good reason to
- I not sure how this will be used. If someone calls this in a loop one file at a time, we definitely want to use WholeProgram mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is absolutely correct :)
@@ -51,7 +51,7 @@ export class LanguageService { | |||
const program = compiler.getNextProgram(); | |||
const sourceFile = program.getSourceFile(fileName); | |||
if (sourceFile) { | |||
diagnostics.push(...ttc.getDiagnosticsForFile(sourceFile, OptimizeFor.SingleFile)); | |||
diagnostics.push(...compiler.getDiagnosticsForFile(sourceFile, OptimizeFor.SingleFile)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alxhub , I made this use SingleFile optimization because that's what the previous behavior was, and I don't want to give up single file optimization and cause a performance regression.
If we wanted to call this with WholeProgram optimization, we have two options.
- manually ensure all shims are built before calling this, that way we use the memoized shims
- expose an optimizeFor parameter on this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is correct here too :)
d6afab8
to
f986617
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed-for: language-service
Report non-template diagnotics when calling `getDiagnotics` function of the language service we only returned template diagnotics. This change causes it to return all diagnotics, not just diagnostics from the template type checker.
f986617
to
94361c5
Compare
presubmit is running... |
…gnostics` With this change we replace `getDiagnostics` with `getDiagnosticsForFile`. `getDiagnostics` no longer accept a parameter and is intended to be used instead of `getDiagnostics`. I used `OptimizeFor.WholeProgram` based on the comments in angular/angular#40331 (comment) which suggests that if you iterate through files one at a time the `WholeProgram` flag should be used. For more context see: angular/angular#40331 (cherry picked from commit 5fdc0a6)
…gnostics` With this change we replace `getDiagnostics` with `getDiagnosticsForFile`. `getDiagnostics` no longer accept a parameter and is intended to be used instead of `getDiagnostics`. I used `OptimizeFor.WholeProgram` based on the comments in angular/angular#40331 (comment) which suggests that if you iterate through files one at a time the `WholeProgram` flag should be used. For more context see: angular/angular#40331
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Report non-template diagnostics when calling
getDiagnostics
function ofthe language service we only returned template diagnostics. This change
causes it to return all diagnostics, not just diagnostics from the
template type checker.
Why does this split getDiagnostics into two functions?
A. I split getDiagnostics into two functions. getDiagnostics for getting all diagnostics in the program, and getDiagnosticsForFile, which only gets diagnostics for the argument file. this is because it makes the implementation less complicated, and it aligns with our style guide – better to have two functions that do different things than one function that can do both things.