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
Structural directive autocompletion #40032
Conversation
40f6b6f
to
b459787
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.
Looks good.
A few variable names could be more meaningful .For example isDomProperty
gives much more context to the reader than isProperty
.
b459787
to
ad92362
Compare
This commit extends the template targeting system, which determines the node being referenced given a template position, to return additional context if needed about the particular aspect of the node to which the position refers. For example, a position pointing to an element node may be pointing either to its tag name or to somewhere in the node body. This is the difference between `<div|>` and `<div foo | bar>`.
This commit expands the autocompletion capabilities of the language service to include element tag names. It presents both DOM elements from the Angular DOM schema as well as any components (or directives with element selectors) that are in scope within the template as options for completion.
…ility The `annotations` package in the compiler previously contained a registry which tracks NgModule scopes for template type-checking, including unifying all type-checking metadata across class inheritance lines. This commit generalizes this utility and prepares it for use in the `TemplateTypeChecker` as well, to back APIs used by the language service.
…etion This commit adds two new APIs to the `TemplateTypeChecker`: `getPotentialDomBindings` and `getDirectiveMetadata`. Together, these will support the Language Service in performing autocompletion of directive inputs/outputs.
This commit adds attribute completion to the Language Service. It completes from 3 sources: 1. inputs/outputs of directives currently present on the element 2. inputs/outputs/attributes of directives in scope for the element, that would become present if the input/output/attribute was added 3. DOM properties and attributes We distinguish between completion of a property binding (`[foo|]`) and a completion in an attribute context (`foo|`). For the latter, bindings to the attribute are offered, as well as a property binding which adds the square bracket notation. To determine hypothetical matches (directives which would become present if a binding is added), directives in scope are scanned and matched against a hypothetical version of the element which has the attribute.
This commit adds autocompletion for pipe expressions, built on existing APIs for checking which pipes are in scope.
This commit introduces an `isStructural` flag on directive metadata, which is `true` if the directive injects `TemplateRef` (and thus is at least theoretically usable as a structural directive). The flag is not used for anything currently, but will be utilized by the Language Service to offer better autocompletion results for structural directives.
This comit adds support for autocompletion of attributes that create structural directives. Such completions differ from those of normal attributes, as the structural directive syntax creates a synthetic <ng-template> node which has different attributes from the main element.
ad92362
to
4243377
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 on the schema file
Reviewed-for: fw-security
@@ -240,6 +240,13 @@ const _ATTR_TO_PROP: {[name: string]: string} = { | |||
'tabindex': 'tabIndex', | |||
}; | |||
|
|||
// Invert _ATTR_TO_PROP. | |||
const _PROP_TO_ATTR: {[name: string]: string} = |
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.
optional: could this be Record<string, string>
?
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 could. I actually prefer the primitive syntax as it gives the opportunity to name what kind of strings the keys are, which Record<string, string>
does not.
(Note to caretaker/myself: does not require dev-infra approval as only BUILD.bazel files are changed. The compiler-cli has an exception for this, but the language-service is in a separate directory and thus not covered, even though it's still compiler code) |
This commit expands the autocompletion capabilities of the language service to include element tag names. It presents both DOM elements from the Angular DOM schema as well as any components (or directives with element selectors) that are in scope within the template as options for completion. PR Close #40032
…ility (#40032) The `annotations` package in the compiler previously contained a registry which tracks NgModule scopes for template type-checking, including unifying all type-checking metadata across class inheritance lines. This commit generalizes this utility and prepares it for use in the `TemplateTypeChecker` as well, to back APIs used by the language service. PR Close #40032
This commit adds attribute completion to the Language Service. It completes from 3 sources: 1. inputs/outputs of directives currently present on the element 2. inputs/outputs/attributes of directives in scope for the element, that would become present if the input/output/attribute was added 3. DOM properties and attributes We distinguish between completion of a property binding (`[foo|]`) and a completion in an attribute context (`foo|`). For the latter, bindings to the attribute are offered, as well as a property binding which adds the square bracket notation. To determine hypothetical matches (directives which would become present if a binding is added), directives in scope are scanned and matched against a hypothetical version of the element which has the attribute. PR Close #40032
This commit adds autocompletion for pipe expressions, built on existing APIs for checking which pipes are in scope. PR Close #40032
This commit introduces an `isStructural` flag on directive metadata, which is `true` if the directive injects `TemplateRef` (and thus is at least theoretically usable as a structural directive). The flag is not used for anything currently, but will be utilized by the Language Service to offer better autocompletion results for structural directives. PR Close #40032
This comit adds support for autocompletion of attributes that create structural directives. Such completions differ from those of normal attributes, as the structural directive syntax creates a synthetic <ng-template> node which has different attributes from the main element. PR Close #40032
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. |
No description provided.