stevedlawrence commented on issue #165:
URL:
https://github.com/apache/daffodil-vscode/issues/165#issuecomment-1240872286
To clarify what I think the correct algorithm is determine the right context
for auto-completion:
1. From the current position, scan backwards until until you find either a
`<` or `>`
1. If we find a `<`, it means we are inside an open tag (i.e.
adding/modifying an attribute)
1. From the `<` character, read characters forward until we find a
space (or the current position), this is the context tag
1. If we read read no characters, it means we just have a `<`, and
should jump to `ii`.
2. Otherwise, continue to scan forward keeping track if we are in
an attribute name, or value, or neither. Once we reach the current position, we
will know if we are inside an attribute value or not
1. If we are in an attribute value, we can autocomplete the
possible values for the attribute we found
2. If we are not in an attribute value, we can autocomplete the
possible attributes for the tag we found
2. If we find a `>`, it means we should autocomplete a new tag
1. Scan backwards to find the parent element. This is slightly tricky,
since we need to ignore previous sibling elements, which could be deeply
nested. I think the algorithm is increment a count when we see a closing tag,
decrement a count when we see an opening tag. If we find an opening tag and
that count is zero, then we've found the parent tag.
2. Once we've determined the parent tag, we can autocomplete which
tags are allowed as a child of that tag (e.g.. xs:element cannot have an
xs:sequence as a child)
Note that none of this looks at entire lines. It looks character by
character, either forwards or backwards, to determine the correct context of
the current position.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]