redhat-developer / redhat-developer/vscode-xml

Code completion - insert required subelements

Open
#521 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

completion enhancement
Dominant language
TypeScript
Stars
328
Forks
101
Avg merge
1d 17h
Merged PRs (30d)
7

Description

If my schema contains required attributes on an element, executing autocompletion for that element will also autocomplete the required attributes. Example:

<xs:complexType name="enumerationType">
  <xs:sequence>
      <xs:element type="enumType" name="enum" maxOccurs="unbounded" minOccurs="1" />
  </xs:sequence>
  <xs:attribute type="xs:string" name="name" use="required" />
  <xs:attribute type="enumerationDataType" name="data_type" use="required" />
</xs:complexType>

Executing code completion for this element will type
image

<enumeration name="" data_type="text"></enumeration>

(it also inferred an attribute value for the data type because enumerationDataType is an xs:enumeration)

However, the element contains a mandatory subelement at least once, which means the generated xml is instantly invalid.

My suggestion is that the autocompletion for an element should generate all required subelements

<enumeration name="" data_type="text">
<enum></enum>
</enumeration>

ideally this rule would be applied recursively, so if enum had a mandatory attribute value, it would generate

<enumeration name="" data_type="text">
<enum value=""></enum>
</enumeration>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named in the issue. Start by locating the XML schema-aware completion entry point and its existing required-attribute tests, then add coverage for required subelements, including recursive required children; done means completion produces valid XML for the examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
devtools, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.