-
Notifications
You must be signed in to change notification settings - Fork 25.9k
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
parser and language service fixes for unclosed element tags #42554
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This commit updates the parser logic to continue to try to match an end tag to an unclosed open tag on the stack. Previously, it would only push an error to the list and stop looking at unclosed elements. For example, the invalid HTML of `<li><div></li>`, has an unclosed element stack of [`li`, `div`] when it encounters the close `li` tag. We compare against the previously unclosed tag `div` and see that this is unexpected. Instead of simply giving up here, we continue to move up the unclosed tags until we find a match (if there is one).
alxhub
approved these changes
Jun 11, 2021
…se tag Unclosed element tags are not assigned an `endSourceSpan` by the parser. As a result, the visitor which determines the target node at a position for the language service was unable to determine that a given position was inside an unclosed parent. This happens because we update the `endSourceSpan` of template/element nodes to be the end tag (and there is not one for unclosed tags). Consequently, the visitor then cannot match a position to any child node location. This change updates the visitor logic to check if there are any `children` of a template/element node and updates the end span to be the end span of the last child. This allows our `isWithin` logic to identify that a child position is within the unclosed parent. Addresses one of the issues found during investigation of angular/vscode-ng-language-service#1399
alxhub
pushed a commit
that referenced
this pull request
Jun 14, 2021
…se tag (#42554) Unclosed element tags are not assigned an `endSourceSpan` by the parser. As a result, the visitor which determines the target node at a position for the language service was unable to determine that a given position was inside an unclosed parent. This happens because we update the `endSourceSpan` of template/element nodes to be the end tag (and there is not one for unclosed tags). Consequently, the visitor then cannot match a position to any child node location. This change updates the visitor logic to check if there are any `children` of a template/element node and updates the end span to be the end span of the last child. This allows our `isWithin` logic to identify that a child position is within the unclosed parent. Addresses one of the issues found during investigation of angular/vscode-ng-language-service#1399 PR Close #42554
alxhub
pushed a commit
that referenced
this pull request
Jun 14, 2021
…2554) This commit updates the parser logic to continue to try to match an end tag to an unclosed open tag on the stack. Previously, it would only push an error to the list and stop looking at unclosed elements. For example, the invalid HTML of `<li><div></li>`, has an unclosed element stack of [`li`, `div`] when it encounters the close `li` tag. We compare against the previously unclosed tag `div` and see that this is unexpected. Instead of simply giving up here, we continue to move up the unclosed tags until we find a match (if there is one). PR Close #42554
alxhub
pushed a commit
that referenced
this pull request
Jun 14, 2021
…se tag (#42554) Unclosed element tags are not assigned an `endSourceSpan` by the parser. As a result, the visitor which determines the target node at a position for the language service was unable to determine that a given position was inside an unclosed parent. This happens because we update the `endSourceSpan` of template/element nodes to be the end tag (and there is not one for unclosed tags). Consequently, the visitor then cannot match a position to any child node location. This change updates the visitor logic to check if there are any `children` of a template/element node and updates the end span to be the end span of the last child. This allows our `isWithin` logic to identify that a child position is within the unclosed parent. Addresses one of the issues found during investigation of angular/vscode-ng-language-service#1399 PR Close #42554
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
action: merge
The PR is ready for merge by the caretaker
area: compiler
Issues related to `ngc`, Angular's template compiler
area: language-service
Issues related to Angular's VS Code language service
cla: yes
target: patch
This PR is targeted for the next patch release
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix(compiler): always match close tag to the nearest open element
This commit updates the parser logic to continue to try to match an end
tag to an unclosed open tag on the stack. Previously, it would only
push an error to the list and stop looking at unclosed elements.
For example, the invalid HTML of
<li><div></li>
, has an unclosedelement stack of [
li
,div
] when it encounters the closeli
tag.We compare against the previously unclosed tag
div
and see that this isunexpected. Instead of simply giving up here, we continue to move up the
unclosed tags until we find a match (if there is one).
fix(language-service): Use last child end span for parent without close tag
Unclosed element tags are not assigned an
endSourceSpan
by the parser.As a result, the visitor which determines the target node at a position
for the language service was unable to determine that a given position
was inside an unclosed parent. This happens because we update the
endSourceSpan
of template/element nodes to be the end tag (and thereis not one for unclosed tags). Consequently, the visitor then cannot
match a position to any child node location.
This change updates the visitor logic to check if there are any
children
of a template/element node and updates the end span to be theend span of the last child. This allows our
isWithin
logic to identifythat a child position is within the unclosed parent.