Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
|| (!/^[a-z,A-Z,\d]*$/.test(abbreviation) && !abbreviation.endsWith('.'))
|| markupSnippetKeys.indexOf(abbreviation) > -1
|| commonlyUsedTags.indexOf(abbreviation) > -1) {
try {
expandedText = expand(abbreviation, expandOptions);
// Skip cases when abc -> abc: ; as this is noise
if (isStyleSheet(syntax) && expandedText === `${abbreviation}: \${1};`) {
expandedText = '';
}
} catch (e) {
}
}
if (expandedText) {
expandedAbbr = CompletionItem.create(abbreviation);
expandedAbbr.textEdit = TextEdit.replace(abbreviationRange, expandedText);
expandedAbbr.documentation = removeTabStops(expandedText);
expandedAbbr.insertTextFormat = InsertTextFormat.Snippet;
expandedAbbr.detail = 'Emmet Abbreviation';
if (filters.indexOf('bem') > -1) {
expandedAbbr.label = abbreviation + filterDelimitor + bemFilterSuffix;
}
if (isStyleSheet(syntax)) {
// See https://github.com/Microsoft/vscode/issues/28933#issuecomment-309236902
// Due to this we set filterText, sortText and label to expanded abbreviation
// - Label makes it clear to the user what their choice is
// - FilterText fixes the issue when user types in propertyname and emmet uses it to match with abbreviations
// - SortText will sort the choice in a way that is intutive to the user
expandedAbbr.filterText = expandedAbbr.documentation;
expandedAbbr.sortText = expandedAbbr.documentation;
expandedAbbr.label = expandedAbbr.documentation;
function _functionSymbol(node: StylusNode, text: string[]): CompletionItem {
const name = node.name;
const completionItem = CompletionItem.create(name);
completionItem.kind = CompletionItemKind.Function;
return completionItem;
}
function _selectorSymbol(node: StylusNode, text: string[], currentWord: string): CompletionItem {
const firstSegment = node.segments[0];
const name = firstSegment.string
? node.segments!.map(s => s.string).join('')
: firstSegment.nodes!.map(s => s.name).join('');
const completionItem = CompletionItem.create(name);
completionItem.kind = CompletionItemKind.Class;
return completionItem;
}
return data.atDirectives.map(property => {
const completionItem = CompletionItem.create(property.name);
completionItem.detail = property.description;
completionItem.kind = CompletionItemKind.Keyword;
return completionItem;
});
}
return data.properties.map(property => {
const completionItem = CompletionItem.create(property.name);
completionItem.insertText = property.name + (useSeparator ? ': ' : ' ');
completionItem.detail = property.description;
completionItem.kind = CompletionItemKind.Property;
return completionItem;
});
}
const createExpandedAbbr = (abbr) => {
try {
expandedText = expand(abbr, expandOptions);
} catch (e) {
}
if (expandedText && isExpandedTextNoise(syntax, abbr, expandedText)) {
expandedText = '';
}
if (expandedText) {
expandedAbbr = CompletionItem.create(abbr);
expandedAbbr.textEdit = TextEdit.replace(abbreviationRange, escapeNonTabStopDollar(addFinalTabStop(expandedText)));
expandedAbbr.documentation = replaceTabStopsWithCursors(expandedText);
expandedAbbr.insertTextFormat = InsertTextFormat.Snippet;
expandedAbbr.detail = 'Emmet Abbreviation';
expandedAbbr.label = abbreviation;
expandedAbbr.label += filter ? '|' + filter.replace(',', '|') : "";
completionItems = [expandedAbbr];
}
}
if (!snippetKey.startsWith(prefix.toLowerCase()) || (skipFullMatch && snippetKey === prefix.toLowerCase())) {
return;
}
let currentAbbr = abbreviation + snippetKey.substr(prefix.length);
let expandedAbbr;
try {
expandedAbbr = expand(currentAbbr, expandOptions);
} catch (e) {
}
if (!expandedAbbr) {
return;
}
let item = CompletionItem.create(prefix + snippetKey.substr(prefix.length));
item.documentation = replaceTabStopsWithCursors(expandedAbbr);
item.detail = snippetDetail;
item.textEdit = TextEdit.replace(abbreviationRange, escapeNonTabStopDollar(addFinalTabStop(expandedAbbr)));
item.insertTextFormat = InsertTextFormat.Snippet;
snippetCompletions.push(item);
});
return snippetCompletions;
function _variableSymbol(node: StylusNode, text: string[], currentWord: string): CompletionItem {
const name = node.name;
const lineno = Number(node.val!.lineno!) - 1;
const completionItem = CompletionItem.create(name);
completionItem.detail = text[lineno].trim();
completionItem.kind = CompletionItemKind.Variable;
return completionItem;
}
export default builtIn.map((item) => {
const completionItem = CompletionItem.create(item.insertText);
completionItem.detail = item.name;
completionItem.insertText = item.insertText;
completionItem.documentation = item.desc;
completionItem.kind = CompletionItemKind.Function;
return completionItem;
});