-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Initial language service support for selectorless #61240
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
Conversation
if (meta !== null && meta.selector !== null) { | ||
const ref = new Reference<ClassDeclaration>(symbol.tsSymbol.valueDeclaration as any); | ||
// Host directives will be added as identifiers with the same offset as the host | ||
// which means that they'll get added twice. De-duplicate them to avoid confusion. |
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.
out of curiosity, is this new or why is this surfacing now?
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.
It was always like that, we just didn't have any tests with host directives so we never noticed it. I think that also the language service integration was de-duping the information produced as a result at some point so it didn't affect users either.
/** | ||
* A `TmplAstComponent` element node that's targeted, where the given position is within the body. | ||
*/ | ||
export interface ComponentInBodyContext { |
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 know this is not new, but "body" was confusing me for a bit.
The template symbol builder works by finding the variables referring to template AST nodes with specific offsets and resolving them to directives. Afterwards it goes through the directives and resolves their host directives. The problem is that host directives are added with the exact same offsets as their host which means they get added once initially and again when resolving host directives. These changes resolve the issue by de-duplicating them.
Updates the template type checker to produce symbols for selectorless nodes. This is necessary for integration into the language service.
Adds the logic to resolve the template targets for the selectorless component and directive nodes. This is a prerequisite for other functionality.
Updates the language service to handle producing definition information for selectorless components and directives.
Updates the language service to produce quick info for selectorless components and directives.
…on for selectorless Adds an initial implementation for finding references and renaming to selectorless components/directives. Finding references should work everywhere, whereas renaming only currently works when initiated from the template.
f6858dc
to
2580eda
Compare
This PR was merged into the repository by commit fa27b76. The changes were merged into the following branches: main |
) Updates the language service to handle producing definition information for selectorless components and directives. PR Close #61240
Follow-up from angular#61240 (comment). Adds a `isSelfClosing` property on element-like AST nodes so consumers can easily determine if it's self-closing, rather than having to look at the spans. This is useful for migrations and in the language service.
…ectives Follow-up to angular#61240 that adds renaming support for selectorless components/directives both from the template and from the TypeScript source.
Follow-up from #61240 (comment). Adds a `isSelfClosing` property on element-like AST nodes so consumers can easily determine if it's self-closing, rather than having to look at the spans. This is useful for migrations and in the language service. PR Close #61307
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. |
Sets up some initial support for selectorless in the language service which handles things like resolving definitions and hover tooltips. We're still missing at least the following:
Includes the following changes:
fix(compiler-cli): symbol builder duplicating host directives
The template symbol builder works by finding the variables referring to template AST nodes with specific offsets and resolving them to directives. Afterwards it goes through the directives and resolves their host directives.
The problem is that host directives are added with the exact same offsets as their host which means they get added once initially and again when resolving host directives.
These changes resolve the issue by de-duplicating them.
refactor(compiler-cli): produce template symbols for selectorless nodes
Updates the template type checker to produce symbols for selectorless nodes. This is necessary for integration into the language service.
refactor(language-service): set up template targets for selectorless
Adds the logic to resolve the template targets for the selectorless component and directive nodes. This is a prerequisite for other functionality.
refactor(language-service): support definitions for selectorless
Updates the language service to handle producing definition information for selectorless components and directives.
refactor(language-service): support quick info selectorless symbols
Updates the language service to produce quick info for selectorless components and directives.
refactor(language-service): initial reference and rename implementation for selectorless
Adds an initial implementation for finding references and renaming to selectorless components/directives.
Finding references should work everywhere, whereas renaming only currently works when initiated from the template.