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

feat(server): provide folding ranges for inline templates #1779

Merged
merged 6 commits into from
Oct 27, 2022

Conversation

atscott
Copy link
Collaborator

@atscott atscott commented Oct 19, 2022

Following the embedded language support documentation, this commit provides folding ranges for inline templates in typescript files. This feature is provided in the language server so other editors that use the @angular/language-server package can make use of the feature as well.

https://code.visualstudio.com/api/language-extensions/embedded-languages

fixes #852

@atscott atscott added feature target: minor This PR is targeted for the next minor release labels Oct 19, 2022
@atscott atscott force-pushed the foldingRanges branch 3 times, most recently from 6c311b8 to b2ec117 Compare October 19, 2022 18:25
To support legacy view engine, we install an old version of the language
server into the vsix.
The esbuild configuration is now managed in the BUILD.bazel rules.
Following the embedded language support documentation, this commit provides
folding ranges for inline templates in typescript files.
This feature is provided in the language server so other editors that
use the @angular/language-server package can make use of the feature as
well.

https://code.visualstudio.com/api/language-extensions/embedded-languages

fixes angular#852
@atscott
Copy link
Collaborator Author

atscott commented Oct 20, 2022

@ivanwonder Would you mind reviewing this change?

@ivanwonder
Copy link
Contributor

Ok, I will review this soon.

server/src/session.ts Outdated Show resolved Hide resolved
server/src/session.ts Outdated Show resolved Hide resolved
server/src/embedded_support.ts Outdated Show resolved Hide resolved
return classDeclNode;
}

export function findAllMatchingNodes(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think this can be moved into NgLanguageService(for example, getAllComponentLocationsInFile), and reused for styles.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added some tests. Good thought.

As for moving it to the NgLanguageService, I do like the idea in general. Let's do it as a follow-up refactor? We do pretty much have these exact functions: https://github.com/angular/angular/blob/54e32dad3e130a64e0c312746b67229d8aeb785c/packages/language-service/src/language_service.ts#L594-L598
I don't know what exactly we'd want to expose as public API though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, Let's do it in the follow-up PR.

server/src/embedded_support.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@ivanwonder ivanwonder left a comment

Choose a reason for hiding this comment

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

LGTM

@atscott atscott added the action: merge Ready to merge label Oct 27, 2022
@dylhunn dylhunn self-requested a review October 27, 2022 17:33
Copy link
Collaborator

@dylhunn dylhunn left a comment

Choose a reason for hiding this comment

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

Looks good, this should be a really useful feature!

@atscott atscott merged commit b2fd11e into angular:main Oct 27, 2022
@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 Nov 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge Ready to merge feature target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow the collapse/expand of tags in inline templates
3 participants