This is an automated email from the ASF dual-hosted git repository.
rstrickland pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/daffodil-vscode.git
The following commit(s) were added to refs/heads/main by this push:
new 0b15bc7 Document IntelliSense AttributeCompletionProvider +
AttributeValueCompletionProvider + relevant files
0b15bc7 is described below
commit 0b15bc77fddc42efa991f57c62c6cd8bc2c7eab4
Author: Jeremy Yao <[email protected]>
AuthorDate: Sat Nov 1 19:20:07 2025 -0400
Document IntelliSense AttributeCompletionProvider +
AttributeValueCompletionProvider + relevant files
Closes #1490
Closes #1489
---
src/language/intellisense-development.md | 245 ++++++++++++++++++
src/language/providers/attributeCompletion.ts | 141 ++++++++++-
src/language/providers/attributeValueCompletion.ts | 85 +++++++
.../providers/intellisense/attributeItems.ts | 280 ++++++++++++++++-----
.../providers/intellisense/attributeValueItems.ts | 11 +
5 files changed, 685 insertions(+), 77 deletions(-)
diff --git a/src/language/intellisense-development.md
b/src/language/intellisense-development.md
new file mode 100644
index 0000000..bd27782
--- /dev/null
+++ b/src/language/intellisense-development.md
@@ -0,0 +1,245 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+# Intellisense
+
+This document contains an overview of how intellisense works as well as a
general view of the architecture of the code.
+
+## Table of Contents
+
+- [Intellisense](#intellisense)
+ - [Table of Contents](#table-of-contents)
+ - [General Intellisense Concepts](#general-intellisense-concepts)
+ - [Providers](#providers)
+ - [Registration](#registration)
+ - [DFDL](#dfdl)
+ - [High-level dfdl Intellisense
Overview](#high-level-dfdl-intellisense-overview)
+ - [Provider Registration (Start
Here)](#provider-registration-start-here)
+ - [Provider Implementation
Locations](#provider-implementation-locations)
+ - [Helpers + Vocabulary](#helpers-vocabulary)
+ - [Context Parsing](#context-parsing)
+ - [Namespace / Prefix Handling](#namespace-prefix-handling)
+ - [Completions Construction](#completions-construction)
+ - [Hover / Documentation](#hover-documentation)
+ - [Testing](#testing)
+ - [Individual File Deep-Dives](#individual-file-deep-dives)
+ - [Core Provider Files](#core-provider-files)
+ - [attributeCompletion.ts](#attributecompletionts)
+ - [attributeValueCompletion.ts](#attributevaluecompletionts)
+ - [Intellisense Data Files (intellisense
subdirectory)](#intellisense-data-files-intellisense-subdirectory)
+ - [attributeItems.ts](#attributeitemsts)
+ - [attributeValueItems.ts](#attributevalueitemsts)
+ - [TDML](#tdml)
+
+### General Intellisense Concepts
+
+#### Providers
+
+Providers in the VS Code API are extension points that let you plug specific
language or editor features into the editor’s pipeline (e.g., completions,
hovers, formatting). Proviers are implemented and then registered in the code
which gets then gets called depending on the situation the provider activates.
+
+Many providers exist. Relevant ones that are used extensively in the code
pertaining to IntelliSense functionality include `completionItemProvider` which
provide code suggestions and `hoverProvider` which provider hover information.
More information can be found at
<https://code.visualstudio.com/api/references/vscode-api>.
+
+#### Registration
+
+After a provider has its functionality implemented, it can then be registered
into the extension so that its functionality can be utilized in the
IntelliSense functionality pipeline. Relevant registration calls include
`registerCompletionItemProvider` and `registerHoverProvider`.
+
+### DFDL
+
+This section focuses on the `dfdl` Intellisense implementation.
+
+#### High-level dfdl Intellisense Overview
+
+This section providers a high-level view of the architecture of all relevant
code items pertaining to the `dfdl` IntelliSense functionality.
+
+##### Provider Registration (Start Here)
+
+`src/language/dfdl.ts` is the starting point. It wires up the extension’s
language features by calling VS Code registration APIs (e.g.,
`registerCompletionItemProvider`, `registerHoverProvider`, and similar) that
are then customized as functions that provide customized provider functinoality.
+
+In other words, `dfdl.ts` connects the provider implementations to VS Code for
the DFDL language.
+
+##### Provider Implementation Locations
+
+Autocompletion logic is split into multiple provider modules under
`src/language/providers/`, each handling different completion scenarios.
+
+- `elementCompletion.ts` -- suggests child elements / element tags.
+- `attributeCompletion.ts` -- suggests attribute names when inside an element.
+- `attributeValueCompletion.ts` -- provides completion suggestions for
attribute values (e.g., enumerated values).
+- `closeElement.ts`, `closeElementSlash.ts` -- completions for closing tags
and slash completions.
+- `attributeHover.ts` -- hover provider that shows attribute
documentation/available attributes.
+
+It should be noted that there are many `registerCompletionItemProvider` calls.
The implemented `completionItemProvider`s each contain logic to determine
whether or not it the provider is relevant to a given situation or not.
+
+##### Helpers + Vocabulary
+
+`src/language/providers/utils.ts` and
`src/language/providers/intellisense/commonItems.ts` contain shared helpers for
constructing CompletionItem objects, and context parsing utilities used by many
providers. For `src/language/providers/intellisense/commonItems.ts` and tracing
through usage, it's used by `attributeCompletion.ts` and `elementCompletion.ts`.
+
+`src/rootCompletion/utils.ts` contains utilities used for root-level
completion logic (common completion primitives).
+
+The code relies on project classes like schemaData (found under
src/classes/schemaData.ts) and other "model" classes to know DFDL vocabulary
(elements, attributes, properties). Those model classes hold the authoritative
lists that the providers consult when building suggestions.
+
+##### Context Parsing
+
+Providers do lightweight parsing of the current document and cursor context
(often using a small tokenizer / utility functions) to determine whether the
cursor is:
+
+- inside an element start tag
+- inside attribute name or value
+- within namespace/prefix context
+- in text content (no suggestions)
+
+This context detection guides which provider runs and how it filters
suggestions.
+
+##### Namespace / Prefix Handling
+
+The code is able to determine the current element's namespace and the
suggestions are able to insert the correct namespace or omit the namespace
accordinly for attribute and element suggestions
+
+##### Completions Construction
+
+Providers build `vscode.CompletionItem` objects populated with:
+
+- label, kind (element/attribute/snippet)
+- insertText (text inserted when the user accepts the suggestion)
+- sometimes additionalTextEdits or textEdit ranges to precisely replace text
+- optional documentation or detail shown in the completion UI
+
+Some items use resolveCompletionItem logic if additional data must be computed
after selection.
+
+##### Hover / Documentation
+
+`attributeHover.ts` forms hover messages (Markdown strings) describing
attributes available on a tag, DFDL property documentation, etc. Hover resolves
current element context then gathers attribute docs and returns a
`vscode.Hover` object.
+
+Hover tooltips can be found under `attributeHoverValues()` in
`attributeHoverItems.ts`.
+
+##### Testing
+
+`src/tests/suite/language/items.test.ts` contains unit-style checks that
assert which items should be available in certain contexts -- useful to confirm
the expected behavior of completion providers.
+
+#### Individual File Deep-Dives
+
+##### Core Provider Files
+
+###### attributeCompletion.ts
+
+**Purpose:** Attribute name completion provider for XML elements in DFDL
schemas and TDML test files.
+
+**Key Functionality:**
+
+- Provides context-aware attribute suggestions based on current XML element
type
+- Suggests valid DFDL attributes for DFDL-specific elements
+- Suggests XSD attributes for XML Schema elements
+- Filters out already-present attributes to avoid duplicates
+- Handles both space-triggered and newline-triggered completion
+- Scans document for user-defined types for type attribute completion
+
+**Key Functions:**
+
+- `getAttributeCompletionProvider()`: DFDL document provider
+- `getTDMLAttributeCompletionProvider()`: TDML document provider
+- `getDefinedTypes()`: Scans for xs:simpleType and xs:complexType declarations
+- `prunedDuplicateAttributes()`: Removes attributes already present on element
+
+**Trigger:** Space (` `) or newline (`\n`)
+
+###### attributeValueCompletion.ts
+
+**Purpose:** Attribute value completion provider for DFDL schemas and TDML
test files.
+
+**Key Functionality:**
+
+- Intelligent value suggestions based on attribute name
+- Enumerated value completion for DFDL properties with fixed value sets
+- Type name completion (references to xs:simpleType or xs:complexType)
+- Variable name completion (references to dfdl:defineVariable)
+- Boolean values (true/false, yes/no) for boolean attributes
+- Standard values (encoding names, byte orders, etc.)
+
+**Key Functions:**
+
+- `getAttributeValueCompletionProvider()`: DFDL document provider
+- `getTDMLAttributeValueCompletionProvider()`: TDML document provider
+- `getAttributeDetails()`: Extracts attribute name and value range for
completion context
+
+**Trigger:** Space (` `)
+
+##### Intellisense Data Files (intellisense subdirectory)
+
+###### attributeItems.ts
+
+**Purpose:** Static completion data for XML schema attributes used in DFDL/XSD
documents.
+
+**Data Structure:**
+
+- Array of completion items, each containing:
+ - `item`: Attribute name
+ - `snippetString`: VS Code snippet with placeholders and default values
+ - `markdownString`: Documentation shown in completion tooltip
+
+**Snippet Features:**
+
+- Tab stops ($1, $2, etc.)
+- Choice placeholders (${1|option1,option2|})
+- Final cursor position ($0)
+- Namespace prefix handling
+
+**Attribute Categories:**
+
+- XSD Core Attributes (name, ref, type, minOccurs, maxOccurs)
+- DFDL Length Properties (dfdl:length, dfdl:lengthKind, dfdl:lengthUnits)
+- DFDL Encoding Properties (dfdl:encoding, dfdl:encodingErrorPolicy)
+- DFDL Text/Binary Representation
+- DFDL Separators/Delimiters
+- DFDL Calendar/Date
+- DFDL Escape Schemes
+- DFDL Assertions
+
+**Key Export:**
+
+- `attributeCompletion(additionalItems, nsPrefix, dfdlPrefix, spacingChar,
afterChar)`: Returns object with completion items
+
+###### attributeValueItems.ts
+
+**Purpose:** Completion logic for attribute values (as opposed to attribute
names).
+
+**Data Structures:**
+
+- `noChoiceAttributes`: Array of free-text attributes that should not show
completion choices
+- `attributeValues()`: Function that generates value snippets based on
attribute name
+
+**Snippet Patterns:**
+
+- `${1|option1,option2|}`: Dropdown with predefined choices
+- `"$1"`: Simple placeholder for user input
+- `"{$1}"`: Placeholder for DFDL expressions with curly braces
+- `$0`: Final cursor position
+
+**Attribute Categories Handled:**
+
+- Occurrence attributes (minOccurs, maxOccurs, occursCountKind)
+- Length attributes (lengthKind, lengthUnits)
+- Encoding attributes (encoding, encodingErrorPolicy)
+- Binary/Text format attributes
+- Calendar/date attributes
+- Sequence/Choice properties
+- Yes/No boolean properties
+
+**Key Exports:**
+
+- `noChoiceAttributes`: List of attributes without predefined choices
+- `attributeValues(attributeName, startPos, additionalTypes)`: Inserts
appropriate snippet at cursor
+
+### TDML
+
+This section focuses on the `tdml` Intellisense implementation. It should be
noted that the functionality is currently unused.
diff --git a/src/language/providers/attributeCompletion.ts
b/src/language/providers/attributeCompletion.ts
index 6cc1b1f..b94d68f 100644
--- a/src/language/providers/attributeCompletion.ts
+++ b/src/language/providers/attributeCompletion.ts
@@ -15,6 +15,27 @@
* limitations under the License.
*/
+/**
+ * Attribute Completion Provider for DFDL and TDML Documents
+ *
+ * This module provides intelligent attribute name completion for XML elements
in DFDL schemas
+ * and TDML test files. It offers context-aware suggestions based on:
+ * - The current XML element type (xs:element, xs:sequence, dfdl:format, etc.)
+ * - The namespace being used (XSD, DFDL, TDML)
+ * - Previously entered attributes (to avoid suggesting duplicates)
+ * - The cursor position within the element tag
+ *
+ * Features:
+ * - Suggests valid DFDL attributes for DFDL-specific elements
+ * - Suggests XSD attributes for XML Schema elements
+ * - Suggests TDML attributes for TDML test elements
+ * - Filters out already-present attributes to avoid duplicates
+ * - Handles both space-triggered and equals-triggered completion
+ * - Provides appropriate snippets with placeholders for attribute values
+ *
+ * The provider is triggered when the user types ' ' (space) or '=' within an
XML element tag.
+ */
+
import * as vscode from 'vscode'
import { xml2js } from 'xml-js'
import {
@@ -34,6 +55,19 @@ import {
import { attributeCompletion } from './intellisense/attributeItems'
+/**
+ * Builds a list of completion items for attributes based on the element
context.
+ * Combines common items with element-specific attribute suggestions from the
intellisense data.
+ *
+ * @param itemsToUse - Array of attribute names that are valid for the current
element
+ * @param preVal - Prefix value to prepend to completion text
+ * @param additionalItems - The element name for which to get attribute
suggestions
+ * @param nsPrefix - The XML Schema namespace prefix (e.g., 'xs:', 'xsd:')
+ * @param dfdlPrefix - The DFDL namespace prefix (typically 'dfdl:')
+ * @param spacingChar - Character for spacing in the completion snippet
+ * @param afterChar - Character to insert after the attribute value
+ * @returns Array of VS Code completion items for attributes
+ */
function getCompletionItems(
itemsToUse: string[],
preVal: string = '',
@@ -43,8 +77,10 @@ function getCompletionItems(
spacingChar: string,
afterChar: string
) {
+ // array for completion item that will be returned
let compItems: vscode.CompletionItem[] = []
+ // Add element-specific attribute completion items from intellisense data
attributeCompletion(
additionalItems,
nsPrefix,
@@ -61,36 +97,45 @@ function getCompletionItems(
return compItems
}
-/** Retrieves relevant lines of the document for use in
prunedDuplicateAttributes
- * Format of return is as follows [relevant parts of the string, index
representing the location of the cursor in the string]
+/**
+ * Retrieves the relevant text of the current XML element for attribute
parsing.
+ * Extracts the portion of the document that contains the element tag being
edited,
+ * which may span multiple lines. This text is used to identify existing
attributes
+ * and determine what new attributes can be suggested.
*
- * @param position
- * @param document
- * @returns
+ * The function searches backwards to find the opening '<' of the element and
forwards
+ * to find where the element ends (either '>' or '/>').
+ *
+ * @param position - The current cursor position
+ * @param document - The VS Code text document
+ * @returns A tuple of [element text, cursor index within that text]
*/
-
function getPotentialAttributeText(
position: vscode.Position,
document: vscode.TextDocument
): [string, number] {
- // Overall strategy: Find the lines that are relevant to the XML element
we're looking at. The element can be incomplete and not closed.
+ // Overall strategy: Find the lines that are relevant to the XML element
we're looking at.
+ // The element can be incomplete and not yet closed.
let lowerLineBound: number = position.line
let upperLineBound: number = position.line
- // Determining the lowerbound strategy: Traverse backwards line-by-line
until we encounter an opening character (<)
+ // Determining the lower bound strategy: Traverse backwards line-by-line
until we encounter
+ // an opening character (<), which marks the start of the current element.
- //handle edge case if there's an element closing on the same line or if
there is a closing tag after the cursor on the same line
+ // Handle edge case if there's an element closing on the same line or if
there is a
+ // closing tag after the cursor on the same line
if (lowerLineBound > 0) {
lowerLineBound--
}
while (
lowerLineBound > 0 && // Make sure we aren't going to negative line indexes
- document.lineAt(lowerLineBound).text.indexOf('<') == -1 // continue going
up the document if there is no <
+ document.lineAt(lowerLineBound).text.indexOf('<') == -1 // Continue going
up if no '<' found
) {
- lowerLineBound-- // traverse backwards via decrementing line index
+ lowerLineBound-- // Traverse backwards via decrementing line index
}
- // Upperbound strategy: Increment the upperLineBound 1 line downward to
avoid the edge case it's equal to the lowerLineBound and there's more content
beyond lowerLineBound
+ // Upper bound strategy: Increment the upperLineBound 1 line downward to
avoid the edge case
+ // where it's equal to the lowerLineBound and there's more content beyond
lowerLineBound
if (upperLineBound != document.lineCount - 1) {
upperLineBound++
}
@@ -205,6 +250,20 @@ function prunedDuplicateAttributes(
return originalAttributeSuggestions
}
+/**
+ * Registers the attribute completion provider for DFDL documents.
+ * This provider suggests valid attribute names when the user types within an
XML element tag.
+ *
+ * The provider:
+ * 1. Determines the current element context (which element the cursor is
inside)
+ * 2. Gets the list of valid attributes for that element
+ * 3. Filters out attributes that are already present
+ * 4. Returns context-appropriate attribute suggestions
+ *
+ * Triggered by: space (' ') and newline ('\n') characters
+ *
+ * @returns A VS Code Disposable for the registered completion provider
+ */
export function getAttributeCompletionProvider() {
return vscode.languages.registerCompletionItemProvider(
{ language: 'dfdl' },
@@ -271,6 +330,15 @@ export function getAttributeCompletionProvider() {
)
}
+/**
+ * Registers the attribute completion provider for TDML test documents.
+ * Similar to the DFDL provider but tailored for TDML-specific attributes
+ * like test types, validation modes, and TDML configuration options.
+ *
+ * Triggered by: space (' ') and newline ('\n') characters
+ *
+ * @returns A VS Code Disposable for the registered completion provider
+ */
export function getTDMLAttributeCompletionProvider() {
return vscode.languages.registerCompletionItemProvider(
{ language: 'tdml' },
@@ -327,6 +395,18 @@ export function getTDMLAttributeCompletionProvider() {
)
}
+/**
+ * Scans the entire document to find all user-defined type names.
+ * Searches for xs:simpleType and xs:complexType declarations and extracts
+ * their names, which can then be used for type attribute completion.
+ *
+ * This allows users to get completion suggestions for their custom-defined
+ * types when specifying the 'type' attribute on elements.
+ *
+ * @param document - The VS Code text document to scan
+ * @param nsPrefix - The namespace prefix for schema elements (e.g., 'xs:')
+ * @returns Comma-separated string of defined type names
+ */
export function getDefinedTypes(
document: vscode.TextDocument,
nsPrefix: string
@@ -357,6 +437,29 @@ export function getDefinedTypes(
return additionalTypes
}
+/**
+ * Determines which completion items to show based on the nearest open element.
+ * Matches the element name against known DFDL elements and returns appropriate
+ * attribute suggestions for that element type.
+ *
+ * The function handles special cases for different element types:
+ * - Schema root elements
+ * - Element declarations
+ * - Sequence/choice/group definitions
+ * - Format definitions
+ * - Variables and assertions
+ * - TDML test case elements
+ *
+ * @param nearestOpenItem - The name of the current enclosing element
+ * @param attributeNames - Array of attributes already present on the element
+ * @param triggerText - The text of the current line up to the cursor
+ * @param nsPrefix - The namespace prefix being used
+ * @param preVal - Prefix value to add before attribute (for formatting)
+ * @param additionalItems - String of additional items (types/variables) to
include
+ * @param charBeforeTrigger - Character immediately before the cursor
+ * @param charAfterTrigger - Character immediately after the cursor
+ * @returns Array of completion items appropriate for the element, or undefined
+ */
function checkNearestOpenItem(
nearestOpenItem: string,
attributeNames: string[],
@@ -748,6 +851,20 @@ function checkNearestOpenItem(
}
}
+/**
+ * Creates completion items specifically for dfdl:defineVariable elements.
+ * Provides attribute suggestions for variable declarations including:
+ * - external: Whether the variable is externally provided
+ * - defaultValue: Default value for the variable
+ * - type: Data type of the variable (with custom type suggestions)
+ *
+ * @param preVal - Prefix value for formatting
+ * @param additionalItems - Comma-separated list of user-defined types
+ * @param nsPrefix - The namespace prefix
+ * @param spacingChar - Character for spacing before the attribute
+ * @param afterChar - Character to insert after the attribute value
+ * @returns Array of completion items for defineVariable attributes
+ */
function getDefineVariableCompletionItems(
preVal: string,
additionalItems: string,
diff --git a/src/language/providers/attributeValueCompletion.ts
b/src/language/providers/attributeValueCompletion.ts
index 35d902b..9ed3bfa 100644
--- a/src/language/providers/attributeValueCompletion.ts
+++ b/src/language/providers/attributeValueCompletion.ts
@@ -15,6 +15,29 @@
* limitations under the License.
*/
+/**
+ * Attribute Value Completion Provider for DFDL and TDML Documents
+ *
+ * This module provides intelligent completion suggestions for attribute
values in DFDL schemas
+ * and TDML test files. It offers context-aware value suggestions based on:
+ * - The attribute name (e.g., different values for dfdl:representation,
dfdl:length, etc.)
+ * - Valid enumerated values from the DFDL specification
+ * - Previously defined types (for type references)
+ * - Previously defined variables (for variable references)
+ * - Boolean values (true/false, yes/no) for boolean attributes
+ * - Standard values like encoding names, byte orders, etc.
+ *
+ * Features:
+ * - Enumerated value completion for DFDL properties with fixed value sets
+ * - Type name completion (references to xs:simpleType or xs:complexType
definitions)
+ * - Variable name completion (references to dfdl:defineVariable declarations)
+ * - Custom completion items for attributes requiring user input
+ * - Filtering based on attribute context (element type, namespace, etc.)
+ * - Integration with DFDL and TDML specification data
+ *
+ * The provider is triggered when the user types opening quotes (\" or ') for
an attribute value.
+ */
+
import * as vscode from 'vscode'
import {
@@ -28,6 +51,19 @@ import { getDefinedTypes } from './attributeCompletion'
import { attributeCompletion } from './intellisense/attributeItems'
import { noChoiceAttributes } from './intellisense/attributeValueItems'
+/**
+ * Registers the attribute value completion provider for DFDL documents.
+ * This provider suggests valid values for DFDL attributes based on the
attribute name
+ * and context.
+ *
+ * The provider:
+ * 1. Identifies the attribute being edited
+ * 2. Looks up valid values for that attribute from the intellisense data
+ * 3. Includes user-defined types and variables as applicable
+ * 4. Provides completion items with appropriate snippets
+ *
+ * @returns A VS Code Disposable for the registered completion provider
+ */
export function getAttributeValueCompletionProvider() {
return vscode.languages.registerCompletionItemProvider(
'dfdl',
@@ -36,6 +72,9 @@ export function getAttributeValueCompletionProvider() {
document: vscode.TextDocument,
position: vscode.Position
) {
+ // Don't provide completion in these contexts:
+ // - Inside curly braces (DFDL expression language)
+ // - Outside of quoted strings (not in an attribute value)
if (
checkBraceOpen(document, position) ||
cursorWithinBraces(document, position) ||
@@ -76,6 +115,23 @@ export function getAttributeValueCompletionProvider() {
editBuilder.replace(range, replaceValue)
})
+ /**
+ * Generates appropriate completion snippets for attribute values
based on the attribute name.
+ *
+ * This function is called by the completion provider when the
cursor is positioned in an
+ * attribute value context. It uses a switch statement to map
attribute names to their
+ * corresponding value snippets and inserts them at the specified
position.
+ *
+ * @param attributeName - The name of the attribute being completed
(without namespace prefix for most cases)
+ *
+ * Implementation Notes:
+ * ---------------------
+ * - Uses insertSnippet() utility to insert snippets at the cursor
position
+ * - Snippet syntax: ${1|choice1,choice2|} for dropdowns, "$1" for
free text
+ * - Expression attributes use "{$1}" to include required curly
braces
+ * - Some attributes have default values (e.g., "0" for numeric
properties)
+ * - Type attribute merges XSD primitive types with custom types
from the schema
+ */
function getAttributeValues(attributeName: string) {
type AttributeItem = {
item: string
@@ -115,6 +171,16 @@ export function getAttributeValueCompletionProvider() {
)
}
+/**
+ * Registers the attribute value completion provider for TDML test documents.
+ * This provider suggests valid values for TDML-specific attributes such as:
+ * - Test types (parser, unparser, negative)
+ * - Validation modes (on, limited, off)
+ * - Encoding names (UTF-8, ASCII, ISO-8859-1, etc.)
+ * - Boolean values (true, false)
+ *
+ * @returns A VS Code Disposable for the registered completion provider
+ */
export function getTDMLAttributeValueCompletionProvider() {
return vscode.languages.registerCompletionItemProvider(
'dfdl',
@@ -123,6 +189,7 @@ export function getTDMLAttributeValueCompletionProvider() {
document: vscode.TextDocument,
position: vscode.Position
) {
+ // Don't provide completion inside curly braces (expressions)
if (
checkBraceOpen(document, position) ||
cursorWithinBraces(document, position)
@@ -200,6 +267,24 @@ export function getTDMLAttributeValueCompletionProvider() {
)
}
+/**
+ * Extracts details about the attribute being edited at the cursor position.
+ * Identifies the attribute name and the position range of its value (between
quotes).
+ *
+ * The function:
+ * 1. Searches backwards to find the '=' sign and attribute name
+ * 2. Searches for the opening quote (' or ") after the '=' sign
+ * 3. Searches for the closing quote
+ * 4. Returns the attribute name and value range
+ *
+ * This information is used to provide context-appropriate attribute value
completions
+ * and to replace the existing value when a completion is selected.
+ *
+ * @param document - The VS Code text document
+ * @param position - Current cursor position
+ * @returns Tuple of [attribute name, start position of value, end position of
value]
+ * Returns ['none', 0, 0] if not in an attribute value context
+ */
function getAttributeDetails(
document: vscode.TextDocument,
position: vscode.Position
diff --git a/src/language/providers/intellisense/attributeItems.ts
b/src/language/providers/intellisense/attributeItems.ts
index 64275fd..3985dcc 100644
--- a/src/language/providers/intellisense/attributeItems.ts
+++ b/src/language/providers/intellisense/attributeItems.ts
@@ -15,6 +15,65 @@
* limitations under the License.
*/
+/**
+ * Attribute Completion Items for DFDL/XSD Schema Intellisense
+ *
+ * This module provides static completion data for XML schema attributes used
in DFDL (Data Format Description Language)
+ * and XSD (XML Schema Definition) documents. It is consumed by the completion
provider to offer context-aware
+ * attribute suggestions as users type in DFDL schema files.
+ *
+ * Data Structure:
+ * ---------------
+ * The attributeCompletion function returns an object containing an array of
completion items. Each item contains:
+ * - item: The attribute name to display in the completion list
+ * - snippetString: A VSCode snippet with placeholders ($1, $2, etc.) and
default values
+ * - markdownString: Human-readable documentation shown in the completion
tooltip
+ *
+ * Usage by Completion Provider:
+ * ------------------------------
+ * This data is used by src/language/providers/dfdl.ts to provide intelligent
attribute completion when:
+ * - User types inside an XML element tag (e.g., <xs:element |)
+ * - User triggers completion manually with Ctrl+Space
+ * - Completion provider filters these items based on current context and
element type
+ *
+ * Snippet Format:
+ * ---------------
+ * Snippets use VSCode snippet syntax:
+ * - $1, $2, etc.: Tab stop positions for user input
+ * - ${1|option1,option2|}: Choice placeholders with predefined options
+ * - $0: Final cursor position after all tab stops
+ * - spacingChar: Spacing before attribute (typically space)
+ * - afterChar: Character after attribute (typically space or >)
+ *
+ * DFDL Specification Reference:
+ * ------------------------------
+ * Attributes in this file are defined by:
+ * - DFDL v1.0 Specification: https://daffodil.apache.org/docs/dfdl/
+ * - XML Schema Part 1: Structures (for xs: attributes)
+ * - Attributes prefixed with dfdl: are DFDL-specific extensions to XSD
+ *
+ * Key Attribute Categories:
+ * -------------------------
+ * 1. XSD Core Attributes: name, ref, type, default, fixed, minOccurs,
maxOccurs, nillable
+ * 2. Length Properties: dfdl:length, dfdl:lengthKind, dfdl:lengthUnits,
dfdl:lengthPattern
+ * 3. Encoding Properties: dfdl:encoding, dfdl:encodingErrorPolicy,
dfdl:utf16Width
+ * 4. Occurrence Properties: dfdl:occursCount, dfdl:occursCountKind,
dfdl:occursStopValue
+ * 5. Byte/Bit Order: dfdl:byteOrder, dfdl:bitOrder
+ * 6. Text Representation: dfdl:textNumberPattern,
dfdl:textStringJustification, dfdl:textPadKind
+ * 7. Binary Representation: dfdl:binaryNumberRep, dfdl:binaryFloatRep,
dfdl:binaryBooleanTrueRep
+ * 8. Separators/Delimiters: dfdl:separator, dfdl:terminator, dfdl:initiator
+ * 9. Calendar/Date: dfdl:calendarPattern, dfdl:calendarTimeZone,
dfdl:calendarPatternKind
+ * 10. Escape Schemes: dfdl:escapeSchemeRef, dfdl:escapeCharacter,
dfdl:escapeBlockStart
+ * 11. Assertions: testKind, test, testPattern, message, failureType
+ * 12. Schema Organization: schemaLocation, namespace
+ *
+ * @param additionalItems - Additional completion items to merge with the
standard set
+ * @param nsPrefix - Namespace prefix for schema elements (typically "xs:" or
"xsd:")
+ * @param dfdlPrefix - DFDL namespace prefix (typically "dfdl:")
+ * @param spacingChar - Character to insert before attribute (typically " ")
+ * @param afterChar - Character to insert after attribute value (typically " "
or ">")
+ * @returns Object containing array of completion items with snippets and
documentation
+ */
// prettier-ignore
export const attributeCompletion = (
additionalItems,
@@ -24,7 +83,11 @@ export const attributeCompletion = (
afterChar: string
) => {
return {
+ // Array of completion item objects, each representing a DFDL/XSD
attribute with its snippet and documentation
items: [
+ // === XSD Core Attributes ===
+ // These are fundamental XML Schema attributes used for element
definition and reference
+
{
item: 'name',
snippetString: spacingChar + 'name="$1"$0' + afterChar,
@@ -60,6 +123,9 @@ export const attributeCompletion = (
snippetString: spacingChar + 'nillable="${true|false|}"$0' + afterChar,
markdownString: 'Allows for the concept of an element having no value',
},
+ // === DFDL Occurrence Control Properties ===
+ // These properties control how many times an element occurs in the data
stream
+
{
item: 'type',
snippetString: spacingChar +
'type="${1|xs:string,xs:decimal,xs:float,xs:double,xs:integer,xs:nonNegativeInteger,xs:int,xs:unsignedInt,xs:short,xs:unsignedShort,xs:long,xs:unsignedLong,xs:byte,xs:unsignedByte,xs:hexBinary,xs:boolean'
+
@@ -79,16 +145,6 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix + 'occursCount="$1"$0' +
afterChar,
markdownString: 'dfdl:occursCount property takes an expression which
commonly looks in the Infoset via an expression, to obtain the count from
another element.',
},
- {
- item: 'dfdl:byteOrder',
- snippetString: spacingChar + dfdlPrefix +
'byteOrder="${1|bigEndian,littleEndian|}"$0' + afterChar,
- markdownString: 'This property applies to all Number, Calendar (date
and time), and Boolean types with representation binary',
- },
- {
- item: 'dfdl:bitOrder',
- snippetString: spacingChar + dfdlPrefix +
'bitOrder="${1|mostSignificantBitFirst,leastSignificantBitFirst|}"$0' +
afterChar,
- markdownString: 'Determines the specific bits of any grammar region',
- },
{
item: 'dfdl:occursCountKind',
snippetString: spacingChar + dfdlPrefix +
'occursCountKind="${1|expression,fixed,implicit,parsed,stopValue|}"$0' +
afterChar,
@@ -99,6 +155,24 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix + 'occursStopValue="$1"$0' +
afterChar,
markdownString: 'A whitespace separated list of logical values that
specify the alternative logical stop values for the element',
},
+
+ // === DFDL Byte and Bit Order Properties ===
+ // Control the ordering of bytes and bits in binary data
+
+ {
+ item: 'dfdl:byteOrder',
+ snippetString: spacingChar + dfdlPrefix +
'byteOrder="${1|bigEndian,littleEndian|}"$0' + afterChar,
+ markdownString: 'This property applies to all Number, Calendar (date
and time), and Boolean types with representation binary',
+ },
+ {
+ item: 'dfdl:bitOrder',
+ snippetString: spacingChar + dfdlPrefix +
'bitOrder="${1|mostSignificantBitFirst,leastSignificantBitFirst|}"$0' +
afterChar,
+ markdownString: 'Determines the specific bits of any grammar region',
+ },
+
+ // === DFDL Length Properties ===
+ // Define how the length of an element is determined and represented
+
{
item: 'dfdl:length',
snippetString: spacingChar + dfdlPrefix + 'length="$1"$0',
@@ -119,6 +193,10 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix + 'prefixLengthType="$1"$0' +
afterChar,
markdownString: 'Name of a simple type derived from xs:integer or any
subtype of it.',
},
+
+ // === DFDL Encoding Properties ===
+ // Control character encoding and text handling
+
{
item: 'dfdl:utf16Width',
snippetString: spacingChar + dfdlPrefix +
'utf16Width="${1|fixed,variable|}"$0' + afterChar,
@@ -134,6 +212,10 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix +
'encodingErrorPolicy="${1|error,replace|}"$0' + afterChar,
markdownString: 'This property provides control of how decoding and
encoding errors are handled when converting the data to text, or text to data',
},
+
+ // === DFDL Nil/Null Value Properties ===
+ // Handle nil (null) values in data streams
+
{
item: 'dfdl:nilKind',
snippetString: spacingChar + dfdlPrefix +
'nilKind="${1|literalCharacter,literalValue,logicalValue|}"$0' + afterChar,
@@ -154,6 +236,10 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix +
'useNilForDefault="${1|yes,no|}"$0' + afterChar,
markdownString: 'Controls whether to set the Infoset item [nilled]
boolean member, or to use the XSD default or fixed properties to obtain a data
value'
},
+
+ // === DFDL Alignment and Positioning Properties ===
+ // Control byte/bit alignment and skip regions
+
{
item: 'dfdl:alignment',
snippetString: spacingChar + dfdlPrefix +
'alignment="${1|1,2,implicit|}"$0' + afterChar,
@@ -184,21 +270,62 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix +
'alignmentUnits="${1|bits,bytes|}"$0' + afterChar,
markdownString: "Scales the alignment.\nCan only be used when
alignment is bits or bytes.\nValid values are 'bits or 'bytes'.",
},
+ {
+ item: 'dfdl:leadingSkip',
+ snippetString: spacingChar + dfdlPrefix + 'leadingSkip="0$1"$0' +
afterChar,
+ markdownString: 'A non-negative number of bytes or bits to skip before
alignment is applied',
+ },
+ {
+ item: 'dfdl:trailingSkip',
+ snippetString: spacingChar + dfdlPrefix + 'trailingSkip="0$1"$0' +
afterChar,
+ markdownString: 'A non-negative number of bytes or bits to skip after
the element,',
+ },
+
+ // === DFDL Output Control Properties ===
+ // Control unparsing behavior and output formatting
+
{
item: 'dfdl:outputNewLine',
snippetString: spacingChar + dfdlPrefix +
'outputNewLine="${1|%CR;,%LF;,%CR;%LF;,%NEL;,%LS;|}"$0' + afterChar,
markdownString: 'Specifies the character or characters that are used
to replace the %NL; character class entity during unparse',
},
+
+ // === DFDL Choice and Branching Properties ===
+ // Control xs:choice element behavior and direct/dispatch choices
+
{
item: 'dfdl:choiceBranchKey',
snippetString: spacingChar + dfdlPrefix + 'choiceBranchKey="$1"$0' +
afterChar,
markdownString: 'List of DFDL String Literals',
},
+ {
+ item: 'dfdl:choiceDispatchKey',
+ snippetString: spacingChar + dfdlPrefix + 'choiceDispatchKey="$1"$0' +
afterChar,
+ markdownString: 'The expression must evaluate to a string, the string
must match one of the dfdl:choiceBranchKey property values of one of the
branches of the choice',
+ },
+ {
+ item: 'dfdl:choiceLengthKind',
+ snippetString: spacingChar + dfdlPrefix +
'choiceLengthKind="${1|explicit,implicit|}"$0' + afterChar,
+ markdownString: 'Determines whether the branches of the choice are
always filled (explicit) to the fixed-length specified by dfdl:choiceLength or
not filled (implicit)',
+ },
+ {
+ item: 'dfdl:choiceLength',
+ snippetString: spacingChar + dfdlPrefix + 'choiceLength="$1"$0' +
afterChar,
+ markdownString: 'Specifies the length of the choice in bytes, only
used when dfdl:choiceLengthKind is explicit',
+ },
+
+ // === DFDL Representation Properties ===
+ // Control whether data is represented as text or binary
+
{
item: 'dfdl:representation',
snippetString: spacingChar + dfdlPrefix +
'representation="${1|binary,text|}"$0' + afterChar,
markdownString: 'Identifies the physical representation of the element
as text or binary',
},
+
+ // === DFDL Text String Properties ===
+ // Properties specific to text representation of string data
+
{
item: 'dfdl:textStringJustification',
snippetString: spacingChar + dfdlPrefix +
'textStringJustification="${1|left,right,center|}"$0' + afterChar,
@@ -209,6 +336,15 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix +
'textStringPadCharacter="$1"$0' + afterChar,
markdownString: 'Specifies the string justification',
},
+ {
+ item: 'dfdl:truncateSpecifiedLengthString',
+ snippetString: spacingChar + dfdlPrefix +
'truncateSpecifiedLengthString="${1|no,yes|}"$0' + afterChar,
+ markdownString: 'This property provides the means to express an error,
or the strings can be truncated to fit when the strings in an Infoset being
unparsed do not fit within those specified lengths',
+ },
+
+ // === DFDL Text Number Properties ===
+ // Properties for parsing and unparsing numeric data in text
representation
+
{
item: 'dfdl:textStandardZeroRep',
snippetString: spacingChar + dfdlPrefix + 'textStandardZeroRep="0"$0'
+ afterChar,
@@ -309,6 +445,10 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix +
'textTrimKind="${1|none,padChar|}"$0' + afterChar,
markdownString: 'Indicates whether to trim data on parsing',
},
+
+ // === DFDL Text Boolean Properties ===
+ // Properties for text representation of boolean values
+
{
item: 'dfdl:textBooleanTrueRep',
snippetString: spacingChar + dfdlPrefix + 'textBooleanTrueRep="$1"$0'
+ afterChar,
@@ -329,21 +469,10 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix +
'textBooleanPadCharacter="$1"$0' + afterChar,
markdownString: 'The value that is used when padding or trimming
boolean elements',
},
- {
- item: 'dfdl:leadingSkip',
- snippetString: spacingChar + dfdlPrefix + 'leadingSkip="0$1"$0' +
afterChar,
- markdownString: 'A non-negative number of bytes or bits to skip before
alignment is applied',
- },
- {
- item: 'dfdl:trailingSkip',
- snippetString: spacingChar + dfdlPrefix + 'trailingSkip="0$1"$0' +
afterChar,
- markdownString: 'A non-negative number of bytes or bits to skip after
the element,',
- },
- {
- item: 'dfdl:truncateSpecifiedLengthString',
- snippetString: spacingChar + dfdlPrefix +
'truncateSpecifiedLengthString="${1|no,yes|}"$0' + afterChar,
- markdownString: 'This property provides the means to express an error,
or the strings can be truncated to fit when the strings in an Infoset being
unparsed do not fit within those specified lengths',
- },
+
+ // === DFDL Sequence Properties ===
+ // Properties for xs:sequence groups controlling ordering and separators
+
{
item: 'dfdl:sequenceKind',
snippetString: spacingChar + dfdlPrefix + 'SequenceKind
="${1|ordered,unordered|}"$0' + afterChar,
@@ -364,11 +493,48 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix +
'separatorSuppressionPolicy="${1|anyEmpty,never,trailingEmpty,trailingEmptyStrict|}"$0'
+ afterChar,
markdownString: 'Controls the circumstances when separators are
expected in the data when parsing, or generated when unparsing',
},
+
+ // === DFDL Delimiter Properties ===
+ // Properties for initiators and terminators marking element boundaries
+
{
item: 'dfdl:terminator',
snippetString: spacingChar + dfdlPrefix + 'terminator="$1"$0' +
afterChar,
markdownString: 'charater or bytes found in the input stream that
designate termination of an element',
},
+ {
+ item: 'dfdl:initiator',
+ snippetString: spacingChar + dfdlPrefix + 'initiator="$1"$0' +
afterChar,
+ markdownString: 'Specifies an ordered whitespace separated list of
alternative DFDL String Literals one of which marks the beginning of the
element or group of elements ',
+ },
+ {
+ item: 'dfdl:initiatedContent',
+ snippetString: spacingChar + dfdlPrefix +
'initiatedContent="${1|yes,no|}"$0' + afterChar,
+ markdownString: 'yes indicates all branches of a choice are
initiated\nno indicates the branch dfdl:initator property may be ste to empty
string',
+ },
+ {
+ item: "dfdl:documentFinalTerminatorCanBeMissing" + afterChar,
+ snippetString: spacingChar + dfdlPrefix +
'documentFinalTerminatorCanBeMissing="${1|yes,no|}"$0',
+ markdownString: 'Specifies whether the final line can be missing',
+ },
+
+ // === DFDL Empty Element Properties ===
+ // Control behavior when elements have no content
+
+ {
+ item:'dfdl:emptyValueDelimiterPolicy',
+ snippetString: spacingChar + dfdlPrefix +
'emptyValueDelimiterPolicy="${1|initiator,terminator,both,none|}"$0' +
afterChar,
+ markdownString: 'Indicates which of initiator, terminator, both, or
neither must be present when an element in the data stream is empty.',
+ },
+ {
+ item:'dfdl:emptyElementParsePolicy',
+ snippetString: spacingChar + dfdlPrefix +
'emptyElementParsePolicy="${1|treatAsAbsent,treatAsEmpty|}"$0' + afterChar,
+ markdownString: 'Indicates which of initiator, terminator, both, or
neither must be present when an element in the data stream is empty.',
+ },
+
+ // === DFDL Miscellaneous Properties ===
+ // Additional properties for special features
+
{
item: 'dfdl:textBidi',
snippetString: spacingChar + dfdlPrefix + 'textBidi="${1|no,yes|}"$0'
+ afterChar,
@@ -379,16 +545,6 @@ export const attributeCompletion = (
snippetString: spacingChar + 'dfdl:hiddenGroupRef="$1"$0' + afterChar,
markdownString: 'Reference to a global model group definition',
},
- {
- item: 'dfdl:choiceLengthKind',
- snippetString: spacingChar + dfdlPrefix +
'choiceLengthKind="${1|explicit,implicit|}"$0' + afterChar,
- markdownString: 'Determines whether the branches of the choice are
always filled (explicit) to the fixed-length specified by dfdl:choiceLength or
not filled (implicit)',
- },
- {
- item: 'dfdl:choiceLength',
- snippetString: spacingChar + dfdlPrefix + 'choiceLength="$1"$0' +
afterChar,
- markdownString: 'Specifies the length of the choice in bytes, only
used when dfdl:choiceLengthKind is explicit',
- },
{
item: 'dfdl:fillByte',
snippetString: spacingChar + dfdlPrefix + 'fillByte="$1"$0' +
afterChar,
@@ -399,21 +555,10 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix +
'ignoreCase="${1|no,yes|}"$0' + afterChar,
markdownString: 'Whether mixed case data is accepted when matching
delimiters and data values on input',
},
- {
- item: 'dfdl:initiatedContent',
- snippetString: spacingChar + dfdlPrefix +
'initiatedContent="${1|yes,no|}"$0' + afterChar,
- markdownString: 'yes indicates all branches of a choice are
initiated\nno indicates the branch dfdl:initator property may be ste to empty
string',
- },
- {
- item: 'dfdl:initiator',
- snippetString: spacingChar + dfdlPrefix + 'initiator="$1"$0' +
afterChar,
- markdownString: 'Specifies an ordered whitespace separated list of
alternative DFDL String Literals one of which marks the beginning of the
element or group of elements ',
- },
- {
- item: 'dfdl:choiceDispatchKey',
- snippetString: spacingChar + dfdlPrefix + 'choiceDispatchKey="$1"$0' +
afterChar,
- markdownString: 'The expression must evaluate to a string, the string
must match one of the dfdl:choiceBranchKey property values of one of the
branches of the choice',
- },
+
+ // === DFDL Binary Number Properties ===
+ // Properties for binary representation of numeric values
+
{
item: 'dfdl:binaryNumberRep',
snippetString: spacingChar + dfdlPrefix +
'binaryNumberRep="${1|binary,packed,bcd,ibm4690Packed|}"$0' + afterChar,
@@ -444,6 +589,10 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix +
'binaryNumberCheckPolicy="${1|strict,lax|}"$0' + afterChar,
markdownString: 'Indicates how lenient to be when parsing binary
numbers',
},
+
+ // === DFDL Binary Boolean Properties ===
+ // Properties for binary representation of boolean values
+
{
item: 'dfdl:binaryBooleanTrueRep',
snippetString: spacingChar + dfdlPrefix +
'binaryBooleanTrueRep="$1"$0' + afterChar,
@@ -454,6 +603,10 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix +
'binaryBooleanFalseRep="$1"$0' + afterChar,
markdownString: 'A binary xs:unsignedInt gives the representation for
false',
},
+
+ // === DFDL Calendar/Date-Time Properties ===
+ // Properties for parsing and unparsing date/time data
+
{
item: 'dfdl:calendarPattern',
snippetString: spacingChar + dfdlPrefix + 'calendarPattern="$1"$0' +
afterChar,
@@ -519,21 +672,10 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix + 'binaryCalendarEpoch="$1"$0'
+ afterChar,
markdownString: 'The epoch from which to calculate dates and times.
Used when dfdl:binaryCalendarRep is binarySeconds or binaryMilliseconds',
},
- {
- item: "dfdl:documentFinalTerminatorCanBeMissing" + afterChar,
- snippetString: spacingChar + dfdlPrefix +
'documentFinalTerminatorCanBeMissing="${1|yes,no|}"$0',
- markdownString: 'Specifies whether the final line can be missing',
- },
- {
- item:'dfdl:emptyValueDelimiterPolicy',
- snippetString: spacingChar + dfdlPrefix +
'emptyValueDelimiterPolicy="${1|initiator,terminator,both,none|}"$0' +
afterChar,
- markdownString: 'Indicates which of initiator, terminator, both, or
neither must be present when an element in the data stream is empty.',
- },
- {
- item:'dfdl:emptyElementParsePolicy',
- snippetString: spacingChar + dfdlPrefix +
'emptyElementParsePolicy="${1|treatAsAbsent,treatAsEmpty|}"$0' + afterChar,
- markdownString: 'Indicates which of initiator, terminator, both, or
neither must be present when an element in the data stream is empty.',
- },
+
+ // === DFDL Escape Scheme Properties ===
+ // Properties for defining and using escape mechanisms
+
{
item: 'dfdl:escapeSchemeRef',
snippetString: spacingChar + dfdlPrefix + 'escapeSchemeRef="$1"$0' +
afterChar,
@@ -579,6 +721,10 @@ export const attributeCompletion = (
snippetString: spacingChar + dfdlPrefix +
'escapeCharacterPolicy="${1|all,delimiters|}"$0' + afterChar,
markdownString: "The type of escape mechanism defined in the escape
scheme",
},
+
+ // === DFDL Assert and Discriminator Properties ===
+ // Properties for assertions and discriminators used in validation and
disambiguation
+
{
item: 'testKind',
snippetString: spacingChar + 'testKind="${1|expression,pattern|}"$0' +
afterChar,
@@ -604,6 +750,10 @@ export const attributeCompletion = (
snippetString: spacingChar +
'failureType="${1|processingError,recoverableError|}"$0' + afterChar,
markdownString: 'Specifies the type of failure that occurs when the
dfdl:assert is unsuccessful',
},
+
+ // === XSD Schema Organization Attributes ===
+ // Attributes for schema imports and includes
+
{
item: 'schemaLocation',
snippetString: spacingChar + 'schemaLocation="$1"$0' + afterChar,
diff --git a/src/language/providers/intellisense/attributeValueItems.ts
b/src/language/providers/intellisense/attributeValueItems.ts
index b96cb75..93c3eff 100644
--- a/src/language/providers/intellisense/attributeValueItems.ts
+++ b/src/language/providers/intellisense/attributeValueItems.ts
@@ -15,6 +15,17 @@
* limitations under the License.
*/
+/**
+ * List of attribute names that should NOT show completion choices.
+ * These are typically free-form text attributes where showing predefined
+ * options would not be helpful, such as:
+ * - Names and references (name, ref, namespace)
+ * - Expressions and patterns (inputValueCalc, outputValueCalc, test,
testPattern)
+ * - Numeric values (length, occursCount, textOutputMinLength)
+ * - Custom strings (separator, terminator, initiator, nilValue)
+ * - Type names (prefixLengthType)
+ * - Escape characters and patterns
+ */
export const noChoiceAttributes = [
'name',
'ref',