Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function collectCharacterEntityProposals(): CompletionList {
// character entities
let k = offset - 1
let characterStart = position.character
while (k >= 0 && isLetterOrDigit(text, k)) {
k--
characterStart--
}
if (k >= 0 && text[k] === '&') {
let range = Range.create(
Position.create(position.line, characterStart - 1),
position,
)
for (let entity in entities) {
if (endsWith(entity, ';')) {
const label = '&' + entity
result.items.push({
label,
kind: CompletionItemKind.Keyword,
documentation: `Character entity representing '${entities[entity]}'`,
textEdit: TextEdit.replace(range, label),
insertTextFormat: InsertTextFormat.PlainText,
})
}
}
}
...change.textChanges.map(tc => {
// currently, only import codeAction is available
// change start of doc to start of script region
if (tc.span.start === 0 && tc.span.length === 0) {
const region = regionStart.get(doc);
if (region) {
const line = region.start.line;
return {
range: Range.create(line + 1, 0, line + 1, 0),
newText: tc.newText
};
}
}
return {
range: convertRange(doc, tc.span),
newText: tc.newText
};
})
);
function shiftRange(range: Range, startOffset: number, endOffset: number): Range {
const start = shiftPosition(range.start, startOffset);
const end = shiftPosition(range.end, endOffset);
return Range.create(start, end);
}
): DocumentLink | null {
const documentUri = Uri.parse(document.uri);
const tokenContent = stripQuotes(attributeValue);
if (tokenContent.length === 0) {
return null;
}
if (tokenContent.length < attributeValue.length) {
startOffset++;
endOffset--;
}
const workspaceUrl = getWorkspaceUrl(documentUri, tokenContent, documentContext, base);
if (!workspaceUrl || !isValidURI(workspaceUrl)) {
return null;
}
return {
range: Range.create(document.positionAt(startOffset), document.positionAt(endOffset)),
target: workspaceUrl
};
}
locs.forEach(loc => {
if (!loc.uri) {
let fullpath = path.isAbsolute(loc.filename) ? loc.filename : path.join(context.cwd, loc.filename)
loc.uri = URI.file(fullpath).toString()
}
if (!loc.bufnr && workspace.getDocument(loc.uri) != null) {
loc.bufnr = workspace.getDocument(loc.uri).bufnr
}
if (!loc.range) {
let { lnum, col } = loc
loc.range = Range.create(lnum - 1, col - 1, lnum - 1, col - 1)
} else {
loc.lnum = loc.lnum || loc.range.start.line + 1
loc.col = loc.col || loc.range.start.character + 1
}
})
let bufnr = await this.nvim.call('bufnr', '%')
end = idx;
break;
} else {
lastIdx = idx;
}
}
if (idx === lineText.length - 1) {
start = lineText.lastIndexOf(' ') + 1;
end = idx + 1;
}
}
if (start < 0 || end < 0) {
return;
} else {
range = Range.create(line, start, line, end);
}
return range;
}
this.openerService.getOpener(uri).then(opener => opener.open(uri, {
selection: Range.create(sym.location.range.start, sym.location.range.start),
}));
});
function _variableSymbol(node: StylusNode, text: string[]): SymbolInformation {
const name = node.name;
const lineno = Number(node.val!.lineno) - 1;
const column = Math.max(text[lineno].indexOf(name), 0);
const range = Range.create(lineno, column, lineno, column + name.length);
return SymbolInformation.create(name, SymbolKind.Variable, range);
}
function adjustRange(range: Range, offset: number): Range {
let { start, end } = range
return Range.create(start.line - offset, start.character, end.line - offset, end.character)
}
private createRange(lines: string[], lineAt: number): Range {
const line: string = lines[lineAt];
const firstNonWhitespaceCharacterIndex: number = line.search(/\S|$/);
return Range.create(
{
line: lineAt,
character: firstNonWhitespaceCharacterIndex,
},
{
line: lineAt,
character: firstNonWhitespaceCharacterIndex + line.trim().length,
}
);
}