Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// If the text after the insertion point is the closing quote,
// replace it.
let rangeEndCol = this._position.column;
if (postText !== undefined) {
if (postText.startsWith(quoteCharacter)) {
rangeEndCol++;
}
}
const range: Range = {
start: { line: this._position.line, character: rangeStartCol },
end: { line: this._position.line, character: rangeEndCol }
};
completionItem.textEdit = TextEdit.replace(range, valueWithQuotes);
completionList.items.push(completionItem);
}
}
if (!completionItem) {
return;
}
if (!isNameTokenImmediatelyBeforeCursor) {
allCompletions.push(completionItem);
} else if (completionItem.label.startsWith(tokenBeforeCursor.image)) {
// If a Name token is immediately before the cursor, we only add
// candidates that start with the text of that name (since the user may
// still be typing the rest of the name). If the user accepts one of
// those candidates, it should replace the full Name token before the
// cursor.
allCompletions.push({
...completionItem,
textEdit: TextEdit.replace(
{
start: document.positionAt(tokenBeforeCursor.startOffset),
end: document.positionAt(tokenBeforeCursor.endOffset),
},
completionItem.label
),
});
}
});
function addEdit(text: string, startOffset: number, endOffset: number) {
if (documentText.substring(startOffset, endOffset) !== text) {
let replaceRange = Range.create(document.positionAt(startOffset), document.positionAt(endOffset));
editOperations.push(TextEdit.replace(replaceRange, text));
}
}
private createTextEdit(prefixLength: number, offset: number, content: string): TextEdit {
if (prefixLength === 0) {
return TextEdit.insert(this.document.positionAt(offset), content);
}
return TextEdit.replace(Range.create(this.document.positionAt(offset - prefixLength), this.document.positionAt(offset)), content);
}
}
function createTextEdit(editInfo: AutoFix): TextEdit {
return TextEdit.replace(Range.create(textDocument.positionAt(editInfo.edit.range[0]), textDocument.positionAt(editInfo.edit.range[1])), editInfo.edit.text || '')
}
[
uri
]:
[
TextEdit.replace(range, '\\')
]
}
};
case CommandIds.DIRECTIVE_TO_BACKTICK:
return {
changes: {
[
uri
]:
[
TextEdit.replace(range, '`')
]
}
};
case CommandIds.CONVERT_TO_AS:
return {
changes: {
[
uri
]:
[
TextEdit.replace(range, "AS")
]
}
};
case CommandIds.FLAG_TO_CHOWN:
return {
[uri]: [action.range, ...action.references].map(range => {
const { start, end } = range;
return TextEdit.replace(
Range.create(start.line, start.character + 1, end.line, end.character - 1),
params.newName,
);
}),
},