Title: perf(language-service): lighter analysis trigger for project initialization by kbrilla · Pull Request #66964 · angular/angular · GitHub
Open Graph Title: perf(language-service): lighter analysis trigger for project initialization by kbrilla · Pull Request #66964 · angular/angular
X Title: perf(language-service): lighter analysis trigger for project initialization by kbrilla · Pull Request #66964 · angular/angular
Description: PR: perf(language-service): lighter analysis trigger for project initialization Description Replaces getSemanticDiagnostics() with a lighter ensureProjectAnalyzed() call during project initialization. When a project loads, the language service previously called getSemanticDiagnostics(firstRootFile) to trigger Angular compilation — but this also performed unnecessary per-file TypeScript type checking that was never consumed. The new ensureProjectAnalyzed() method triggers only the Angular analysis pipeline (analyzeSync + resolveCompilation) without running per-file diagnostics, saving 50–500ms per project load depending on file complexity. Problem When a project loads, runGlobalAnalysisForNewlyLoadedProject() calls: project.getLanguageService().getSemanticDiagnostics(fileName) Through the plugin wrapper in ts_plugin.ts, this triggers: tsLS.getSemanticDiagnostics(fileName) — full TypeScript semantic analysis on the first root file (wasted) ngLS.getSemanticDiagnostics(fileName) → compiler.getDiagnosticsForFile() — Angular analysis + per-file template type checking + additional checks (only analysis is needed) The results from both calls are discarded — the only purpose was to initialize the Angular compiler. Solution Added a new ensureProjectAnalyzed() method to the NgLanguageService API that triggers only the Angular compiler's analysis pipeline: ensureProjectAnalyzed(): void { const compiler = this.compilerFactory.getOrCreate(); compiler['ensureAnalyzed'](); // private API, established pattern in LS refactoring code } This uses compiler['ensureAnalyzed']() which directly invokes the private ensureAnalyzed() method on NgCompiler. We are aware this accesses a private API, but it is an established pattern already used in 4 other places in the language service codebase: src/refactorings/convert_to_signal_input/full_class_input_refactoring.ts src/refactorings/convert_to_signal_input/individual_input_refactoring.ts src/refactorings/convert_to_signal_queries/individual_query_refactoring.ts src/refactorings/convert_to_signal_queries/full_class_query_refactoring.ts Given that ensureAnalyzed() is used in 5 places across the language service (including this PR), it may be worth considering making it part of the NgCompiler public API to formalize this usage pattern. Alternative considered A public API alternative is compiler.getTemplateTypeChecker(), which calls ensureAnalyzed() internally and returns the TemplateTypeChecker instance (unused). Both approaches are functionally equivalent and pass all tests. The private API approach was chosen for clarity of intent — we're explicitly triggering analysis, not requesting a type checker. Changes File Change packages/language-service/api.ts Added ensureProjectAnalyzed() to NgLanguageService interface packages/language-service/src/language_service.ts Implemented ensureProjectAnalyzed() packages/language-service/src/ts_plugin.ts Exposed ensureProjectAnalyzed in the plugin object vscode-ng-language-service/server/src/session.ts Replaced getSemanticDiagnostics(fileName) with ensureProjectAnalyzed() in runGlobalAnalysisForNewlyLoadedProject() packages/language-service/test/legacy/ts_plugin_spec.ts Added test verifying ensureProjectAnalyzed() initializes the compiler Impact Saves 50–500ms per project load (varies by first root file complexity) No change to observable behavior — diagnostics are still computed on first pull/push request Independent — can be merged independently of other performance PRs Testing All existing language service tests pass (modern + legacy) New test added in ts_plugin_spec.ts verifying that ensureProjectAnalyzed() properly initializes the Angular compiler state Verified both getTemplateTypeChecker() and compiler['ensureAnalyzed']() approaches pass all tests Breaking Changes None Related Complements #66700 (Pull-Based Diagnostics) and #66668 (Client-Side File Watching) AI Disclosure This PR was developed using Claude Opus 4 AI assistant under human orchestration and review by @kbrilla. Integration See #66967 for integration with Progressive Project Initialization and Pull-Based Diagnostics, which improves how these features work together.
Open Graph Description: PR: perf(language-service): lighter analysis trigger for project initialization Description Replaces getSemanticDiagnostics() with a lighter ensureProjectAnalyzed() call during project initializati...
X Description: PR: perf(language-service): lighter analysis trigger for project initialization Description Replaces getSemanticDiagnostics() with a lighter ensureProjectAnalyzed() call during project initializati...
Opengraph URL: https://github.com/angular/angular/pull/66964
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:7ce5dd0d-e6e8-844d-4da0-fd644137c784 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E00E:7A60E:3619B66:456A2AE:6B01E628 |
| html-safe-nonce | 0c39d553da020723e51d751049c164afe0f7179334c82b3d19b19cd4f839481f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDBFOjdBNjBFOjM2MTlCNjY6NDU2QTJBRTo2QjAxRTYyOCIsInZpc2l0b3JfaWQiOiI0NjE0NjY0MDU2MDU2NDQwMzYwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 395d0d0e829ec5e78f78c859fe04594270b9b0b7c7e6c1b717d640f64c13561a |
| hovercard-subject-tag | pull_request:3260283454 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/angular/angular/pull/66964/files |
| twitter:image | https://avatars.githubusercontent.com/u/22288449?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/22288449?s=400&v=4 |
| og:image:alt | PR: perf(language-service): lighter analysis trigger for project initialization Description Replaces getSemanticDiagnostics() with a lighter ensureProjectAnalyzed() call during project initializati... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width