rt320 commented on issue #165:
URL: 
https://github.com/apache/daffodil-vscode/issues/165#issuecomment-1192798296

   VS Code has a built in interface for handling auto-complete. Whenever an 
autocomplete trigger is activated, the built in interface supplies a position 
in the document where the autocomplete was triggered.  With the position there 
is a method to get the "lineAt()" string.  The wholeLine variable contains the 
string returned by lineAt(). A more accurate variable name instead of 
"wholeLine" might have been "triggerLine".  Based on VS Code examples for 
autocompletion, the string method "contains()" was used to return true or false 
to a string comparison of possible XML components that were in the line where 
the autocomplete was triggered.  In the current autocomplete code no attempt is 
made to parse out individual XML components, string comparisons are the basis 
for determining what autocompletion items should be suggested.  An "openItem" 
is determined by parsing lines backwards to find the last end tag. Any XML 
components after that last end tag are considered to be "open". One relat
 ively easy way to provide an alternative to the hardcoded namespace "xs" could 
be to use the JavaScript/TypeScript object "regExp" to define a regex that 
compares '<' + any characters + "element", and uses the regExp test() method to 
compare the regex to wholeLine and return true of false, similar to how the 
process currently works.  Another suggestion was to use regex to parse the 
namespace from wholeLine and then use the namespace value to build an end tag 
value to look for, I'm not sure how the search for the end tag would work.  The 
entire document could also be parsed into XML components and associated with 
positions and some method developed to query if a tag is open by position, 
although thought would have to be given to how to handle inserting attributes 
into already closed tags of existing schemas. There are probably any number of 
solutions. Each solution will have benefits and drawbacks, including length of 
development time. I'm not sure the best way to address this issue.


-- 
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]

Reply via email to