This is an automated email from the ASF dual-hosted git repository.
shanedell 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 5e182fd Updated attributeValueCompletion.ts to use the snippet
suggestion values from attributeItems.ts rather than duplicate the items and
snippet suggestion values in a separate file. This change also ensures all
attributes listed in attributeItems.ts will have the same suggestion values
when invoking attributeValueCompletion. Incorporated attributes type and base
in attributeItems.ts eliminating the need for commonItems.ts Implemented a fix
for missing attribute suggestion wh [...]
5e182fd is described below
commit 5e182fd9c3978bef279aa9b0564794da5f295e96
Author: rthomas320 <[email protected]>
AuthorDate: Thu Oct 23 08:31:36 2025 -0400
Updated attributeValueCompletion.ts to use the snippet suggestion values
from attributeItems.ts rather than duplicate the items and snippet
suggestion values in a separate file.
This change also ensures all attributes listed in attributeItems.ts will
have the same suggestion values when invoking attributeValueCompletion.
Incorporated attributes type and base in attributeItems.ts eliminating
the need for commonItems.ts
Implemented a fix for missing attribute suggestion when an XML tag does not
have a closing tag (yet).
Closes #1470
Closes #1473
---
src/language/providers/attributeCompletion.ts | 12 +-
src/language/providers/attributeValueCompletion.ts | 71 ++++-
src/language/providers/elementCompletion.ts | 8 +-
.../providers/intellisense/attributeItems.ts | 18 +-
.../providers/intellisense/attributeValueItems.ts | 341 ---------------------
src/language/providers/intellisense/commonItems.ts | 36 ---
src/language/providers/utils.ts | 52 ++--
src/tests/suite/language/items.test.ts | 9 +-
8 files changed, 105 insertions(+), 442 deletions(-)
diff --git a/src/language/providers/attributeCompletion.ts
b/src/language/providers/attributeCompletion.ts
index 0ef4cb0..6cc1b1f 100644
--- a/src/language/providers/attributeCompletion.ts
+++ b/src/language/providers/attributeCompletion.ts
@@ -25,7 +25,6 @@ import {
isInXPath,
lineCount,
createCompletionItem,
- getCommonItems,
getItemsOnLineCount,
cursorWithinQuotes,
cursorWithinBraces,
@@ -44,12 +43,7 @@ function getCompletionItems(
spacingChar: string,
afterChar: string
) {
- let compItems: vscode.CompletionItem[] = getCommonItems(
- itemsToUse,
- preVal,
- additionalItems,
- nsPrefix
- )
+ let compItems: vscode.CompletionItem[] = []
attributeCompletion(
additionalItems,
@@ -781,9 +775,5 @@ function getDefineVariableCompletionItems(
compItems.push(completionItem)
})
- getCommonItems(['type'], '', additionalItems, nsPrefix).forEach((ci) => {
- compItems.push(ci)
- })
-
return compItems
}
diff --git a/src/language/providers/attributeValueCompletion.ts
b/src/language/providers/attributeValueCompletion.ts
index 4250b00..35d902b 100644
--- a/src/language/providers/attributeValueCompletion.ts
+++ b/src/language/providers/attributeValueCompletion.ts
@@ -22,12 +22,11 @@ import {
cursorWithinBraces,
cursorWithinQuotes,
getNsPrefix,
+ insertSnippet,
} from './utils'
import { getDefinedTypes } from './attributeCompletion'
-import {
- attributeValues,
- noChoiceAttributes,
-} from './intellisense/attributeValueItems'
+import { attributeCompletion } from './intellisense/attributeItems'
+import { noChoiceAttributes } from './intellisense/attributeValueItems'
export function getAttributeValueCompletionProvider() {
return vscode.languages.registerCompletionItemProvider(
@@ -77,7 +76,37 @@ export function getAttributeValueCompletionProvider() {
editBuilder.replace(range, replaceValue)
})
- attributeValues(attributeName, startPosition, additionalItems)
+ function getAttributeValues(attributeName: string) {
+ type AttributeItem = {
+ item: string
+ snippetString: string
+ markdownString: string
+ }
+ const attributeItems: AttributeItem[] = []
+
+ attributeCompletion(
+ additionalItems,
+ '',
+ 'dfdl',
+ '',
+ ''
+ ).items.forEach((r) => attributeItems.push(r))
+
+ const foundItem = attributeItems.find((attributeItem) =>
+ attributeItem.item.includes(attributeName)
+ )
+
+ if (foundItem?.item.includes(attributeName)) {
+ let parts = foundItem.snippetString.split('=')
+ let snippet = parts.slice(1).toString()
+ if (snippet != null) {
+ return insertSnippet(snippet, startPosition)
+ } else {
+ return undefined
+ }
+ }
+ }
+ getAttributeValues(attributeName)
}
return undefined
},
@@ -132,7 +161,37 @@ export function getTDMLAttributeValueCompletionProvider() {
editBuilder.replace(range, replaceValue)
})
- attributeValues(attributeName, startPosition, additionalItems)
+ function getAttributeValues(attributeName: string) {
+ type AttributeItem = {
+ item: string
+ snippetString: string
+ markdownString: string
+ }
+ const attributeItems: AttributeItem[] = []
+
+ attributeCompletion(
+ additionalItems,
+ '',
+ 'dfdl',
+ '',
+ ''
+ ).items.forEach((r) => attributeItems.push(r))
+
+ const foundItem = attributeItems.find((attributeItem) =>
+ attributeItem.item.includes(attributeName)
+ )
+
+ if (foundItem?.item.includes(attributeName)) {
+ let parts = foundItem.snippetString.split('=')
+ let snippet = parts.slice(1).toString()
+ if (snippet != null) {
+ return insertSnippet(snippet, startPosition)
+ } else {
+ return undefined
+ }
+ }
+ }
+ getAttributeValues(attributeName)
}
return undefined
},
diff --git a/src/language/providers/elementCompletion.ts
b/src/language/providers/elementCompletion.ts
index 46538ae..33f2d2b 100644
--- a/src/language/providers/elementCompletion.ts
+++ b/src/language/providers/elementCompletion.ts
@@ -25,7 +25,6 @@ import {
isTagEndTrigger,
nearestOpen,
createCompletionItem,
- getCommonItems,
nearestTag,
getAttributeNames,
getItemsOnLineCount,
@@ -186,12 +185,7 @@ function getElementCompletionItems(
definedVariables: string = '',
nsPrefix: string
) {
- let compItems: vscode.CompletionItem[] = getCommonItems(
- itemsToUse,
- preVal,
- definedVariables,
- nsPrefix
- )
+ let compItems: vscode.CompletionItem[] = []
elementCompletion(definedVariables, nsPrefix).items.forEach((e) => {
for (let i = 0; i < itemsToUse.length; ++i) {
diff --git a/src/language/providers/intellisense/attributeItems.ts
b/src/language/providers/intellisense/attributeItems.ts
index 4df0604..64275fd 100644
--- a/src/language/providers/intellisense/attributeItems.ts
+++ b/src/language/providers/intellisense/attributeItems.ts
@@ -28,12 +28,12 @@ export const attributeCompletion = (
{
item: 'name',
snippetString: spacingChar + 'name="$1"$0' + afterChar,
- markdownString: 'specify name',
+ markdownString: 'specifies the name of this item',
},
{
item: 'ref',
snippetString: spacingChar + 'ref="$1"$0' + afterChar,
- markdownString: 'Specifies the name of an element in this schema'
+ markdownString: 'Refers to the name of a defined item'
},
{
item: 'default',
@@ -60,6 +60,20 @@ export const attributeCompletion = (
snippetString: spacingChar + 'nillable="${true|false|}"$0' + afterChar,
markdownString: 'Allows for the concept of an element having no value',
},
+ {
+ 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'
+
+ additionalItems +
+ '|}"$0' + afterChar,
+ markdownString: 'The name of a built in data type, or the name of a
simpleType or complexType element defined in this schema',
+ },
+ {
+ item: 'base',
+ 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'
+
+ additionalItems +
+ '|}"$0' + afterChar,
+ markdownString: 'The name of a built in data type, or the name of a
simpleType or complexType element defined in this schema',
+ },
{
item: 'dfdl:occursCount',
snippetString: spacingChar + dfdlPrefix + 'occursCount="$1"$0' +
afterChar,
diff --git a/src/language/providers/intellisense/attributeValueItems.ts
b/src/language/providers/intellisense/attributeValueItems.ts
index 4774146..b96cb75 100644
--- a/src/language/providers/intellisense/attributeValueItems.ts
+++ b/src/language/providers/intellisense/attributeValueItems.ts
@@ -15,9 +15,6 @@
* limitations under the License.
*/
-import * as vscode from 'vscode'
-import { insertSnippet } from '../utils'
-
export const noChoiceAttributes = [
'name',
'ref',
@@ -67,341 +64,3 @@ export const noChoiceAttributes = [
'targetNamespace',
'namespace',
]
-
-export function attributeValues(
- attributeName: string,
- startPos: vscode.Position,
- additionalTypes: string
-) {
- switch (attributeName) {
- case 'minOccurs':
- insertSnippet('"${1|0,1|}"$0', startPos)
- break
- case 'maxOccurs':
- insertSnippet('"${1|0,1,unbounded|}"$0', startPos)
- break
- case 'nillable':
- insertSnippet('"${true|false|}"$0', startPos)
- break
- case 'occursCount':
- insertSnippet('"$1"$0', startPos)
- break
- case 'byteOrder':
- insertSnippet('"${1|bigEndian,littleEndian|}"$0', startPos)
- break
- case 'bitOrder':
- insertSnippet(
- '"${1|mostSignificantBitFirst,leastSignificantBitFirst|}"$0',
- startPos
- )
- break
- case 'occursCountKind':
- insertSnippet(
- '"${1|expression,fixed,implicit,parsed,stopValue|}"$0',
- startPos
- )
- break
- case 'length':
- insertSnippet('"$1"$0', startPos)
- break
- case 'lengthKind':
- insertSnippet(
-
'"${1|delimited,fixed,explicit,implicit,prefixed,patternendOfParent|}"$0',
- startPos
- )
- break
- case 'prefixIncludesPrefixLength':
- insertSnippet('"${1|yes,no|}"$0', startPos)
- break
- case 'prefixLengthType':
- insertSnippet('"$1"$0', startPos)
- break
- case 'utf16Width':
- insertSnippet('"${1|fixed,variable|}"$0', startPos)
- break
- case 'encoding':
- insertSnippet(
- '"${1|US-ASCII,ASCII,UTF-8,UTF-16,UTF-16BE,UTF-16LE,ISO-8859-1|}"$0',
- startPos
- )
- break
- case 'encodingErrorPolicy':
- insertSnippet('"${1|error,replace|}"$0', startPos)
- break
- case 'nilKind':
- insertSnippet(
- '"${1|literalCharacter,literalValue,logicalValue|}"$0',
- startPos
- )
- break
- case 'nilValue':
- insertSnippet('nilValue="$1"$0', startPos)
- break
- case 'nilValueDelimiterPolicy':
- insertSnippet('"${1|initiator,terminator,both,none|}"$0', startPos)
- break
- case 'useNilForDefault':
- insertSnippet('"${1|yes,no|}"$0', startPos)
- break
- case 'alignment':
- insertSnippet('"${1|1,2,implicit|}"$0', startPos)
- break
- case 'lengthUnits':
- insertSnippet('"${1|bits,bytes,characters|}"$0', startPos)
- break
- case 'lengthPattern':
- insertSnippet('"$1"$0', startPos)
- break
- case 'inputValueCalc':
- insertSnippet('"{$1}"$0', startPos)
- break
- case 'outputValueCalc':
- insertSnippet('"{$1}"$0', startPos)
- break
- case 'alignmentUnits':
- insertSnippet('"${1|bits,bytes|}"$0', startPos)
- break
- case 'outputNewLine':
- insertSnippet('"${1|%CR;,%LF;,%CR;%LF;,%NEL;,%LS;|}"$0', startPos)
- break
- case 'choiceBranchKey':
- insertSnippet('"$1"$0', startPos)
- break
- case 'representation':
- insertSnippet('"${1|binary,text|}"$0', startPos)
- break
- case 'textStringJustification':
- insertSnippet('"${1|left,right,center|}"$0', startPos)
- break
- case 'textStandardZeroRep':
- insertSnippet('"0$1"$0', startPos)
- break
- case 'textStandardInfinityRep':
- insertSnippet('"Inf$1"$0', startPos)
- break
- case 'textStandardExponentRep':
- insertSnippet('"E$1"$0', startPos)
- break
- case 'textStandardNaNRep':
- insertSnippet('"NaN$1"$0', startPos)
- break
- case 'textNumberPattern':
- insertSnippet('"#,##0.###;-#,##0.###$1"$0', startPos)
- break
- case 'textNumberRep':
- insertSnippet('"${1|standard,zoned|}"$0', startPos)
- break
- case 'textNumberRoundingMode':
- insertSnippet(
-
'"${1|roundCeiling,roundFloor,roundDown,roundUp,roundHalfEven,roundHalfDown,roundHalfUp,roundUnnecessary|}"$0',
- startPos
- )
- break
- case 'textNumberRoundingIncrement':
- insertSnippet('"0"$0', startPos)
- break
- case 'textNumberRounding':
- insertSnippet('"${1|explicit,pattern|}"$0', startPos)
- break
- case 'textNumberCheckPolicy':
- insertSnippet('"${1|lax,strict|}"$0', startPos)
- break
- case 'textOutputMinLength':
- insertSnippet('"0"$0', startPos)
- break
- case 'textStandardDecimalSeparator':
- insertSnippet('"$1"$0', startPos)
- break
- case 'textStandardGroupingSeparator':
- insertSnippet('",$1"$0', startPos)
- break
- case 'textPadKind':
- insertSnippet('"${1|none,padChar|}"$0', startPos)
- break
- case 'textStandardBase':
- insertSnippet('"${1|2,8,10,16|}"$0', startPos)
- break
- case 'textZonedSignStyle':
- insertSnippet('"$1"$0', startPos)
- break
- case 'textTrimKind':
- insertSnippet('"${1|none,padChar|}"$0', startPos)
- break
- case 'textBooleanTrueRep':
- insertSnippet('"$1"$0', startPos)
- break
- case 'textBooleanFalseRep':
- insertSnippet('"$1"$0', startPos)
- break
- case 'textBooleanJustification':
- insertSnippet('"${1|left,right,center|}"$0', startPos)
- break
- case 'textBooleanPadCharacter':
- insertSnippet('"$1"$0', startPos)
- break
- case 'leadingSkip':
- insertSnippet('"0$1"$0', startPos)
- break
- case 'trailingSkip':
- insertSnippet('"0$1"$0', startPos)
- break
- case 'truncateSpecifiedLengthString':
- insertSnippet('"${1|no,yes|}"$0', startPos)
- break
- case 'sequenceKind':
- insertSnippet('"${1|ordered,unordered|}"$0', startPos)
- break
- case 'separator':
- insertSnippet('"$1"$0', startPos)
- break
- case 'separatorPosition':
- insertSnippet('"${1|infix,postfix,prefix|}"$0', startPos)
- break
- case 'separatorSuppressionPolicy':
- insertSnippet(
- '"${1|anyEmpty,never,trailingEmpty,trailingEmptyStrict|}"$0',
- startPos
- )
- break
- case 'terminator':
- insertSnippet('"$1"$0', startPos)
- break
- case 'textBidi':
- insertSnippet('"${1|no,yes|}"$0', startPos)
- break
- case 'hiddenGroupRef':
- insertSnippet('"$1"\n$0', startPos)
- break
- case 'choiceLengthKind':
- insertSnippet('"${1|explicit,implicit|}"$0', startPos)
- break
- case 'choiceLength':
- insertSnippet('"$1"$0', startPos)
- break
- case 'fillByte':
- insertSnippet('"$1"$0', startPos)
- break
- case 'ignoreCase':
- insertSnippet('"${1|no,yes|}"$0', startPos)
- break
- case 'initiatedContent':
- insertSnippet('"${1|yes,no|}"$0', startPos)
- break
- case 'initiator':
- insertSnippet('"$1"$0', startPos)
- break
- case 'choiceDispatchKey':
- insertSnippet('"$1"$0', startPos)
- break
- case 'binaryNumberRep':
- insertSnippet('"${1|binary,packed,bcd,ibm4690Packed|}"$0', startPos)
- break
- case 'floating':
- insertSnippet('"${1|no,yes|}"$0', startPos)
- break
- case 'binaryFloatRep':
- insertSnippet('"${1|ieee,ibm390Hex|}"$0', startPos)
- break
- case 'binaryDecimalVirtualPoint':
- insertSnippet('"$1"$0', startPos)
- break
- case 'binaryPackedSignCodes':
- insertSnippet('"$1"$0', startPos)
- break
- case 'binaryNumberCheckPolicy':
- insertSnippet('"${1|strict,lax|}"$0', startPos)
- break
- case 'dfdl:binaryBooleanTrueRep':
- insertSnippet('"$1"$0', startPos)
- break
- case 'dfdl:binaryBooleanFalseRep':
- insertSnippet('"$1"$0', startPos)
- break
- case 'calendarPattern':
- insertSnippet('"$1"$0', startPos)
- break
- case 'calendarPatternKind':
- insertSnippet('"${1|explicit,implicit|}"$0', startPos)
- break
- case 'dfdl:calendarCheckPolicy':
- insertSnippet('"${1|strict,lax|}"$0', startPos)
- break
- case 'dfdl:calendarTimeZone':
- insertSnippet('"$1"$0', startPos)
- break
- case 'dfdl:calendarObserveDST':
- insertSnippet('"${1|yes,no|}"$0', startPos)
- break
- case 'dfdl:calendarFirstDayOfWeek':
- insertSnippet('"${1|Monday,Sunday|}"$0', startPos)
- break
- case 'dfdl:calendarDaysInFirstWeek':
- insertSnippet('"${1|1,2,3,4,5,6,7|}"$0', startPos)
- break
- case 'dfdl:calendarCenturyStart':
- insertSnippet('"$1"$0', startPos)
- break
- case 'dfdl:calendarLanguage':
- insertSnippet('"$1"$0', startPos)
- break
- case 'documentFinalTerminatorCanBeMissing':
- insertSnippet('"${1|yes,no|}"$0', startPos)
- break
- case 'emptyValueDelimiterPolicy':
- insertSnippet('"${1|initiator,terminator,both,none|}"$0', startPos)
- break
- case 'emptyElementParsePolicy':
- insertSnippet('"${1|treatAsAbsent,treatAsEmpty|}"$0', startPos)
- break
- case 'escapeSchemeRef':
- insertSnippet('"$1"$0', startPos)
- break
- case 'escapeKind':
- insertSnippet('"${1|escapeCharacter,escapeBlock|}"$0', startPos)
- break
- case ':escapeCharacter':
- insertSnippet('"$1"$0', startPos)
- break
- case 'escapeBlockStart':
- insertSnippet('"$1"$0', startPos)
- break
- case 'escapeBlockEnd':
- insertSnippet('"$1"$0', startPos)
- break
- case 'escapeEscapeCharacter':
- insertSnippet('"$1"$0', startPos)
- break
- case 'extraEscapedCharacters':
- insertSnippet('"$1"$0', startPos)
- break
- case 'generateEscapeBlock':
- insertSnippet('"${1|always,whenNeeded|}"$0', startPos)
- break
- case 'escapeCharacterPolicy':
- insertSnippet('"${1|all,delimiters|}"$0', startPos)
- break
- case 'testKind':
- insertSnippet('"${1|expression,pattern|}"$0', startPos)
- break
- case 'test':
- insertSnippet('"{$1}"$0', startPos)
- break
- case 'testPattern':
- insertSnippet('"$1"$0', startPos)
- break
- case 'message':
- insertSnippet('"$1"$0', startPos)
- break
- case 'failureType':
- insertSnippet('"${1|processingError,recoverableError|}"$0', startPos)
- break
- case 'type':
- insertSnippet(
-
'"${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'
+
- additionalTypes +
- '|}"$0',
- startPos
- )
- break
- }
-}
diff --git a/src/language/providers/intellisense/commonItems.ts
b/src/language/providers/intellisense/commonItems.ts
deleted file mode 100644
index 64ab0c3..0000000
--- a/src/language/providers/intellisense/commonItems.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-
-// prettier-ignore
-export const commonCompletion = (additionalItems) => {
- return {
- items: [
- {
- item: 'type',
- // use the "xs:" prefix for primitive types to differentiate them from
custom simple types
- snippetString:
'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'
+ additionalItems + '|}"$0',
- markdownString: 'The name of a built in data type, or the name of a
simpleType or complexType element defined in this schema',
- },
- {
- item: 'base',
- // use the "xs:" prefix for primitive types to differentiate them from
custom simple types
- snippetString:
'base="${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'
+ additionalItems + '|}"$0',
- markdownString: 'The name of a built in data type, or the name of a
simpleType or complexType element defined in this schema',
- },
- ],
- }
-}
diff --git a/src/language/providers/utils.ts b/src/language/providers/utils.ts
index 7c99123..2d27105 100644
--- a/src/language/providers/utils.ts
+++ b/src/language/providers/utils.ts
@@ -16,7 +16,6 @@
*/
import * as vscode from 'vscode'
-import { commonCompletion } from './intellisense/commonItems'
import { isXPath } from '../semantics/dfdlExt'
import { xml2js } from 'xml-js'
@@ -278,6 +277,10 @@ export function checkTagOpen(
// start tag assume it is a multi-line tag
if (
itemsOnLine < 2 &&
+ !document
+ .lineAt(triggerLine + 1)
+ .text.trim()
+ .startsWith('<') &&
triggerText.trim().startsWith('<' + nsPrefix + tag) &&
triggerText.indexOf('>', tagPos) < 0 //if tag ending character is missing
will return -1
) {
@@ -288,7 +291,7 @@ export function checkTagOpen(
const nextTagPos = triggerText.indexOf('<', tagPos + 1)
let tagEndPos = triggerText.indexOf('>', tagPos)
- if (tagPos > -1 && itemsOnLine > 1) {
+ if (tagPos > -1 && itemsOnLine >= 1) {
if (
triggerPos > tagPos &&
((triggerPos <= tagEndPos &&
@@ -489,12 +492,14 @@ export function getAttributeNames(
let currentText = document.lineAt(currentLine).text
let closeText = currentText
- //if mulit-line tag
+ //if multi-line tag
if (
- !(
- currentText.trim().startsWith('<' + nsPrefix + tag) &&
- currentText.endsWith('>')
- )
+ currentText.trim().startsWith('<' + nsPrefix + tag) &&
+ !currentText.endsWith('>') &&
+ !document
+ .lineAt(currentLine + 1)
+ .text.trim()
+ .startsWith('<')
) {
//Get the opening tag
while (
@@ -524,14 +529,15 @@ export function getAttributeNames(
}
let attributeNames: string[] = []
- const xmljs = xml2js(currentText, {})
- const attributes = xmljs.elements?.[0].attributes
- if (attributes) {
- const attributeSet: Set<string> = new Set(Object.keys(attributes))
- attributeNames = [...attributeSet]
- return attributeNames
+ if (currentText.includes('>')) {
+ const xmljs = xml2js(currentText, {})
+ const attributes = xmljs.elements?.[0].attributes
+ if (attributes) {
+ const attributeSet: Set<string> = new Set(Object.keys(attributes))
+ attributeNames = [...attributeSet]
+ return attributeNames
+ }
}
-
return attributeNames
}
@@ -820,21 +826,3 @@ export function createCompletionItem(
return completionItem
}
-
-export function getCommonItems(
- itemsToUse: string[],
- preVal: string = '',
- additionalItems: string = '',
- nsPrefix: string
-) {
- let compItems: vscode.CompletionItem[] = []
-
- commonCompletion(additionalItems).items.forEach((e) => {
- if (itemsToUse.includes(e.item)) {
- const completionItem = createCompletionItem(e, preVal, nsPrefix)
- compItems.push(completionItem)
- }
- })
-
- return compItems
-}
diff --git a/src/tests/suite/language/items.test.ts
b/src/tests/suite/language/items.test.ts
index f36d103..92ed539 100644
--- a/src/tests/suite/language/items.test.ts
+++ b/src/tests/suite/language/items.test.ts
@@ -17,7 +17,6 @@
import * as assert from 'assert'
import { attributeCompletion } from
'../../../language/providers/intellisense/attributeItems'
-import { commonCompletion } from
'../../../language/providers/intellisense/commonItems'
import { elementCompletion } from
'../../../language/providers/intellisense/elementItems'
suite('Items Test Suite', () => {
@@ -78,6 +77,8 @@ suite('Items Test Suite', () => {
'minOccurs',
'maxOccurs',
'nillable',
+ 'type',
+ 'base',
'dfdl:occursCount',
'dfdl:byteOrder',
'dfdl:bitOrder',
@@ -188,12 +189,6 @@ suite('Items Test Suite', () => {
'namespace',
]
- test('all commonItems available', async () => {
- let itemNames: string[] = []
- commonCompletion('').items.forEach((r) => itemNames.push(r.item))
- assert.strictEqual(itemNames.includes('type'), true)
- })
-
test('all elementItems available', async () => {
elementCompletion('', '').items.forEach((item) => {
assert.strictEqual(expectedElementItems.includes(item.item), true)