Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
let attributeAtCursor = itemAtCursor.attribute;
if (attributeAtCursor.referencedBlock) {
block = block.getExportedBlock(attributeAtCursor.referencedBlock);
}
if (!block) {
return [];
}
if (attributeAtCursor.attributeType === AttributeType.ambiguous) {
let completions: CompletionItem[] = [
{
label: "block:",
kind: CompletionItemKind.Property,
},
];
block.eachBlockExport((name) => {
completions.push({
label: `${name}:`,
kind: CompletionItemKind.Property,
});
});
return completions;
}
if (attributeAtCursor.attributeType === AttributeType.class) {
return block.classes
// TODO: we should look at scope attributes if the user is on the
// root element.
.filter(blockClass => !blockClass.isRoot)
case ReferenceType.DEPENDS_ON: {
const options = addReferenceablesOptions(
customTag,
referenceables
)
const value = `\${1${options}\}`
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
})
}
}
} else {
collector.add({
kind: CompletionItemKind.Value,
label: customTag.tag,
insertText: customTag.tag + " ",
insertTextFormat: InsertTextFormat.Snippet,
documentation: customTag.description
})
collector.add({
function collectCloseTagSuggestions(afterOpenBracket: number, matchingOnly: boolean): CompletionList {
let range = getReplaceRange(afterOpenBracket);
let contentAfter = document.getText().substr(offset);
let closeTag = contentAfter.match(/^\s*>/) ? '' : '>';
let curr = node;
while (curr) {
let tag = curr.tag;
if (tag && !curr.closed) {
result.items.push({
label: '/' + tag,
kind: CompletionItemKind.Property,
filterText: '/' + tag + closeTag,
textEdit: { newText: '/' + tag + closeTag, range: range }
});
return result;
}
curr = curr.parent;
}
if (matchingOnly) {
return result;
}
tagProviders.forEach((provider) => {
provider.collectTags((tag, label) => {
result.items.push({
label: '/' + tag,
kind: CompletionItemKind.Property,
export const getSuggestionKind = (type: any): CompletionItemKind => {
if (Array.isArray(type)) {
const array = type as any[]
type = array.length > 0 ? array[0] : null
}
if (!type) {
return CompletionItemKind.Value
}
switch (type) {
case "string":
return CompletionItemKind.Value
case "object":
return CompletionItemKind.Module
case "property":
return CompletionItemKind.Property
default:
return CompletionItemKind.Value
}
}
case 'call':
case 'index':
return CompletionItemKind.Function;
case 'enum':
return CompletionItemKind.Enum;
case 'module':
return CompletionItemKind.Module;
case 'class':
return CompletionItemKind.Class;
case 'interface':
return CompletionItemKind.Interface;
case 'warning':
return CompletionItemKind.File;
}
return CompletionItemKind.Property;
}
case CompletionItemKind.Method:
return ts.ScriptElementKind.memberFunctionElement;
case CompletionItemKind.Function:
return ts.ScriptElementKind.functionElement;
case CompletionItemKind.Constructor:
return ts.ScriptElementKind.constructorImplementationElement;
case CompletionItemKind.Field:
case CompletionItemKind.Variable:
return ts.ScriptElementKind.variableElement;
case CompletionItemKind.Class:
return ts.ScriptElementKind.classElement;
case CompletionItemKind.Interface:
return ts.ScriptElementKind.interfaceElement;
case CompletionItemKind.Module:
return ts.ScriptElementKind.moduleElement;
case CompletionItemKind.Property:
return ts.ScriptElementKind.memberVariableElement;
case CompletionItemKind.Unit:
case CompletionItemKind.Value:
return ts.ScriptElementKind.constElement;
case CompletionItemKind.Enum:
return ts.ScriptElementKind.enumElement;
case CompletionItemKind.Keyword:
return ts.ScriptElementKind.keyword;
case CompletionItemKind.Color:
return ts.ScriptElementKind.constElement;
case CompletionItemKind.Reference:
return ts.ScriptElementKind.alias;
case CompletionItemKind.File:
return ts.ScriptElementKind.moduleElement;
case CompletionItemKind.Snippet:
case CompletionItemKind.Text:
insertText = entry.name;
if (!isDefined(declaration.colonPosition)) {
insertText += ': ';
retrigger = true;
}
}
else {
range = _this.getCompletionRange(null);
insertText = entry.name + ': ';
retrigger = true;
}
var item = {
label: entry.name,
documentation: languageFacts.getEntryDescription(entry),
textEdit: TextEdit.replace(range, insertText),
kind: CompletionItemKind.Property
};
if (!entry.restrictions) {
retrigger = false;
}
if (retrigger) {
item.command = {
title: 'Suggest',
command: 'editor.action.triggerSuggest'
};
}
if (strings.startsWith(entry.name, '-')) {
item.sortText = 'x';
}
result.items.push(item);
});
this.completionParticipants.forEach(function (participant) {
tagProvider.collectTags((tag, label) => {
result.items.push({
documentation: label,
kind: CompletionItemKind.Property,
label: tag,
});
});
return result;
function collectAutoCloseTagSuggestion(
tagCloseEnd: number,
tag: string,
): CompletionList {
if (!isEmptyElement(tag)) {
let pos = document.positionAt(tagCloseEnd)
result.items.push({
label: '',
kind: CompletionItemKind.Property,
filterText: '',
textEdit: TextEdit.insert(pos, '$0'),
insertTextFormat: InsertTextFormat.Snippet,
})
}
return result
}
provider.collectTags((tag, label) => {
result.items.push({
label: tag,
kind: CompletionItemKind.Property,
documentation: label,
textEdit: TextEdit.replace(range, tag),
sortText: priority + tag,
insertTextFormat: InsertTextFormat.PlainText
});
});
});