Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tagProvider.collectAttributes(currentTag, (attribute, type) => {
let codeSnippet = attribute;
if (type !== 'v' && value.length) {
codeSnippet = codeSnippet + value;
}
result.items.push({
textEdit: TextEdit.replace(range, codeSnippet),
kind: type === 'handler' ? CompletionItemKind.Function : CompletionItemKind.Value,
label: attribute,
insertTextFormat : InsertTextFormat.Snippet
});
});
return result;
},
{
label: 'template with pug',
documentation: 'Scaffold <template> with pug',
kind: CompletionItemKind.Snippet,
insertTextFormat: InsertTextFormat.Snippet,
insertText: `<template lang="pug">
\t\${0}
</template>
`
},
{
label: 'script with JavaScript',
documentation: 'Scaffold
`
},
{
label: 'script with TypeScript',
documentation: 'Scaffold </template>
)
const value = `[ \${1${options}\}, $2, $3 ]`
collector.add({
kind: CompletionItemKind.Value,
label: customTag.tag,
insertText: `${customTag.tag} ${value}`,
insertTextFormat: InsertTextFormat.Snippet
})
collector.add({
kind: CompletionItemKind.Property,
label: customTag.propertyName,
insertText: `${customTag.propertyName}: ${value}`,
insertTextFormat: InsertTextFormat.Snippet
})
}
case ReferenceType.SUB: {
collector.add({
kind: CompletionItemKind.Value,
label: customTag.tag,
insertText: `${customTag.tag} $1`,
insertTextFormat: InsertTextFormat.Snippet
})
collector.add({
kind: CompletionItemKind.Property,
label: customTag.propertyName,
insertText: `${customTag.propertyName}: $1`,
insertTextFormat: InsertTextFormat.Snippet
})
Object.keys(dataAttributes).forEach(attr =>
result.items.push({
label: attr,
kind: CompletionItemKind.Value,
textEdit: TextEdit.replace(range, dataAttributes[attr]),
insertTextFormat: InsertTextFormat.Snippet,
}),
);
provider.collectAttributes(tag, (attribute, type, documentation) => {
if ((type === 'event' && filterPrefix !== '@') || (type !== 'event' && filterPrefix === '@')) {
return;
}
let codeSnippet = attribute;
if (type !== 'v' && value.length) {
codeSnippet = codeSnippet + value;
}
result.items.push({
label: attribute,
kind: type === 'event' ? CompletionItemKind.Function : CompletionItemKind.Value,
textEdit: TextEdit.replace(range, codeSnippet),
insertTextFormat: InsertTextFormat.Snippet,
sortText: priority + attribute,
documentation
});
});
});
): void => {
if (customTag.type) {
switch (customTag.type) {
case ReferenceType.FIND_IN_MAP: {
const options = addReferenceablesOptions(
customTag,
referenceables
)
const value = `[ \${1${options}\}, $2, $3 ]`
collector.add({
kind: CompletionItemKind.Value,
label: customTag.tag,
insertText: `${customTag.tag} ${value}`,
insertTextFormat: InsertTextFormat.Snippet
})
collector.add({
kind: CompletionItemKind.Property,
label: customTag.propertyName,
insertText: `${customTag.propertyName}: ${value}`,
insertTextFormat: InsertTextFormat.Snippet
})
}
case ReferenceType.SUB: {
collector.add({
kind: CompletionItemKind.Value,
label: customTag.tag,
insertText: `${customTag.tag} $1`,
insertTextFormat: InsertTextFormat.Snippet
})
if (start.length && newText.startsWith(start)) {
newText = newText.slice(start.length)
}
}
character = characterIndex(line, colnr - 1)
if (range.end.character > character) {
let end = line.slice(character, range.end.character)
if (newText.endsWith(end)) {
newText = newText.slice(0, - end.length)
}
}
}
} else {
newText = insertText
}
if (insertTextFormat == InsertTextFormat.Snippet
&& newText
&& newText.indexOf('$') !== -1) {
let parser = new SnippetParser()
let snippet = parser.text(newText)
word = snippet ? getValidWord(snippet, invalidInsertCharacters) : label
} else {
word = getValidWord(newText, invalidInsertCharacters) || label
}
return word
}
provider.collectAttributes(tag, (attribute, info, type?: string) => {
let codeSnippet = attribute;
if (type !== 'v' && value.length) {
codeSnippet = codeSnippet + value;
}
result.items.push({
label: attribute,
detail: info.detail,
documentation: info.documentation,
kind: type === 'handler' ? CompletionItemKind.Function : CompletionItemKind.Value,
textEdit: TextEdit.replace(range, codeSnippet),
insertTextFormat: InsertTextFormat.Snippet
});
});
});
modifiers.items.forEach(modifier => {
result.items.push({
label: modifier.label,
kind: CompletionItemKind.Method,
textEdit: TextEdit.insert(document.positionAt(nameEnd), modifier.label),
insertTextFormat: InsertTextFormat.Snippet,
sortText: modifiers.priority + modifier.label,
documentation: modifier.documentation
});
});
}