Skip to content
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: match external templates to project on startup #988

Merged
merged 1 commit into from
Dec 1, 2020

Conversation

kyliau
Copy link
Contributor

@kyliau kyliau commented Nov 20, 2020

Currently, Ivy LS is not able to match external projects to their external
templates if no TS files are open. This is because Ivy LS does not implement
getExternalFiles().

To fix this, we take a different route:
After ngcc has run, we send diagnostics for all the open files. But in the
case where all open files are external templates, we first get diagnostics
for a root TS file, then process the rest. Processing a root TS file triggers
a global analysis, during which we match the external templates to their
project.

For a more detailed explanation, see
https://github.com/angular/vscode-ng-language-service/wiki/Project-Matching-for-External-Templates

@kyliau kyliau changed the title fix: match external templates to respective projects on startup fix: match external templates to project on startup Nov 20, 2020
server/src/session.ts Outdated Show resolved Hide resolved
server/src/session.ts Outdated Show resolved Hide resolved
server/src/session.ts Outdated Show resolved Hide resolved
server/src/session.ts Outdated Show resolved Hide resolved
server/src/session.ts Outdated Show resolved Hide resolved
@kyliau kyliau force-pushed the external-template-project-matching branch 6 times, most recently from 072534c to 96ee0e8 Compare November 20, 2020 18:55
integration/lsp/ivy_spec.ts Outdated Show resolved Hide resolved
server/src/session.ts Outdated Show resolved Hide resolved
server/src/session.ts Show resolved Hide resolved
server/src/session.ts Outdated Show resolved Hide resolved
@kyliau kyliau force-pushed the external-template-project-matching branch 2 times, most recently from 1ca74ed to cc2ef8c Compare November 24, 2020 19:44
return;
}
const fileName = project.getRootScriptInfos()[0].fileName;
// Getting semantic diagnostics will trigger a global analysis.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it that getting semantic diagnostics always triggers global analysis or is this just because we're triggering diagnostics on a root file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Getting semantic diagnostics always triggers global analysis, because a new compiler is created every time. Technically any file will do, not just root files, but the file must be part of the project, so root file is a convenient candidate.

@kyliau kyliau requested a review from ayazhafiz December 1, 2020 00:27
@kyliau kyliau force-pushed the external-template-project-matching branch from cc2ef8c to fede6e6 Compare December 1, 2020 00:29
Currently, Ivy LS is not able to match external projects to their external
templates if no TS files are open. This is because Ivy LS does not implement
`getExternalFiles()`.

To fix this, we take a different route:
After ngcc has run, we send diagnostics for all the open files. But in the
case where all open files are external templates, we first get diagnostics
for a root TS file, then process the rest. Processing a root TS file triggers
a global analysis, during which we match the external templates to their
project.

For a more detailed explanation, see
https://github.com/angular/vscode-ng-language-service/wiki/Project-Matching-for-External-Templates

Close angular#976
@kyliau kyliau force-pushed the external-template-project-matching branch from fede6e6 to 1cffa6a Compare December 1, 2020 00:43
@kyliau kyliau added this to PRs In Review in Ivy Language Service Dec 1, 2020
server/src/session.ts Show resolved Hide resolved
@kyliau kyliau merged commit a4fbc33 into angular:master Dec 1, 2020
Ivy Language Service automation moved this from PRs In Review to Done Dec 1, 2020
@kyliau kyliau deleted the external-template-project-matching branch December 1, 2020 22:05
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants