mbeckerle opened a new issue, #366:
URL: https://github.com/apache/daffodil-vscode/issues/366
This is a long ticket description. Perhaps can be broken out into separate
issues over time if that helps, but until someone with more experience of the
intellisense code looks at this, I don't want to do that preemptively.
- I was unable to figure out how to enable intellisense from the
documentation here:
https://github.com/apache/daffodil-vscode/wiki/Apache-Daffodil%E2%84%A2-Extension-for-Visual-Studio-Code
The animation showing how to do that goes too quickly, and I cannot see
how
the features it is using are being activated.
Intellisense does seem to work however, after I set a file association of
"*.dfdl.xsd" to "dfdl". Actually it may have just worked anyway, as I'm
not sure this setting was needed.
I created a new foo.dfdl.xsd schema file with it.
- The completion for a schema chooses elementFormDefault="qualified"
which is
incorrect. (a bug) The preferred style for DFDL schemas (or any XSD)
should
be elementFormDefault="unqualified".
Alas, I wish I had known this when we created the TDML language. It would
be so much nicer without the "tdml:" prefixes required everywhere.
- The intellisense completion for a schema provides this namespace prefix:
xmlns:math="[www.w3.org/2005/xpath-functions/math](http://www.w3.org/2005/xpath-functions/math)"
which contains functions not supported by the DFDL schema language.
So I am not sure why this namespace prefix is provided. Perhaps these
functions can be used in schematron annotations or other annotations than
DFDL?
- I wanted to insert a dfdl:format annotation. I typed "for" and was
prompted
with dfdl:format. Clicking on that embeds a giant pile of code as if this
was the start of an empty dfdl schema file. This is not helpful. I was
hoping it would insert this:
```
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
<dfdl:format />
</xs:appinfo>
</xs:annotation>
```
and leave me positioned after the dfdl:format to add properties or a ref.
If I type "ann" I am offered xs:annotation, and clicking that inserts most
of what I wanted.
```
<xs:annotation>
<xs:appinfo source="http://www.ogf.org/dfdl/">
</xs:appinfo>
</xs:annotation>
```
- In this context, if I type dfdl:format in the middle and click on the
offered "dfdl:format" choice it still inserts the entirely wrong "whole
file" contents, in the middle of my appinfo, so clearly the context is not
being taken into account.
- If I type my own <dfdl:format /> element then try to complete properties
inside it, I get no selection support for possible properties. I am offered
top-level annotations and XSD elements.
In fact, I found that the intellisense seems keyed to writing new schemas
from the start. E.g., if you type this:
` <xs:element name="foo"
`
And then ctrl-space will give you DFDL property choices. But if you type:
` <xs:element name="foo" />
`
Then position the cursor just before the "/>" and ctrl-space, the offerings
are for top-level annotations, not properties.
- After some time intellisense stopped working. I could easily get it into
a
mode where any Ctrl-Space to see completions just puts up a box saying
"Loading..." which never goes away unless you select some other window or
hit escape. Other modes it got stuck in were where I selected an option
from the intellisense choices offered, but nothing was inserted, just a
blank line added. I had to restart VSCode in these cases.
BTW: My preferred style for writing DFDL schemas now is using no "xs:"
prefixes on elements at all. E.g., like this example:
```
<?xml version='1.0' encoding='utf-8' ?>
<schema
xmlns:xs="http://www.w3.org/2001/xmlSchema"
xmlns="http://www.w3.org/2001/xmlSchema"
xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
xmlns:daf="urn:ogf:dfdl:2013:imp:[daffodil.apache.org:2018](http://daffodil.apache.org:2018/):ext"
xmlns:fn="http:/[www.w3.org/2005/xpath-functions](http://www.w3.org/2005/xpath-functions)"
elementFormDefault="unqualified"
xmlns:foo="urn:foo"
xmlns:tns="urn:foo"
targetNamespace="urn:foo">
<include
schemaLocation="org/apache/daffodil/xsd/DFDLGeneralFormat.dfdl.xsd"
/>
<element name="bar" type="xs:string" byteOrder="bigEndian" />
</schema>
```
- In the above, notice the element declaration for the element named
"bar".
Note the byteOrder property lacks the "dfdl:" prefix, which is required.
This was inserted by intellisense. I'm not sure what caused this, but I'm
not able to get back to the behavior where it inserts properties with the
dfdl: prefix on them any longer. Even if remove the default xmlns="..."
binding, put all the xs: back on everything, save, restart VSCode, it
still
inserts properties like byteOrder without the required dfdl: prefix.
## Summary
Clearly the intellisense is working sufficiently that a lengthy discussion
of exactly the contexts and things it should do for a user in those
contexts is warranted now.
I'd actually like to learn how to add context sensitive intellsense
completions to this so that I can try-out ones I think would be helpful.
--
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]