本文整理匯總了TypeScript中vscode.Position.translate方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Position.translate方法的具體用法?TypeScript Position.translate怎麽用?TypeScript Position.translate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vscode.Position
的用法示例。
在下文中一共展示了Position.translate方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: provideCompletionItems
async provideCompletionItems(document: TextDocument, position: Position):
Promise<CompletionItem[]> {
// TODO(gabriel): use LeanInputAbbreviator.active() instead
if (!isInputCompletion(document, position)) {
const message = await this.server.complete(document.fileName, position.line + 1, position.character);
const completions: CompletionItem[] = [];
if (message.completions) {
for (const completion of message.completions) {
const item = new CompletionItem(completion.text, CompletionItemKind.Function);
item.range = new Range(position.translate(0, -message.prefix.length), position);
if (completion.tactic_params) {
item.detail = completion.tactic_params.join(' ');
} else {
item.detail = completion.type;
}
item.documentation = new MarkdownString(completion.doc);
completions.push(item);
}
}
for (const kw of keywords) {
completions.push(new CompletionItem(kw, CompletionItemKind.Keyword));
}
return completions;
} else {
return null;
}
}
示例2: previousTokenPosition
private previousTokenPosition(document: TextDocument, position: Position): Position {
while (position.character > 0) {
let word = document.getWordRangeAtPosition(position);
if (word) {
return word.start;
}
position = position.translate(0, -1);
}
return null;
}
示例3: prepForDocCompletion
/**
* Prepare the area around the position for insertion of the jsdoc.
*
* Removes any the prefix and suffix of a possible jsdoc
*/
private prepForDocCompletion(editor: TextEditor, position: Position): Thenable<Position> {
const line = editor.document.lineAt(position.line).text;
const prefix = line.slice(0, position.character).match(/\/\**\s*$/);
const suffix = line.slice(position.character).match(/^\s*\**\//);
if (!prefix && !suffix) {
// Nothing to remove
return Promise.resolve(position);
}
const start = position.translate(0, prefix ? -prefix[0].length : 0);
return editor.edit(
edits => {
edits.delete(new Range(start, position.translate(0, suffix ? suffix[0].length : 0)));
}, {
undoStopBefore: true,
undoStopAfter: false
}).then(() => start);
}
示例4: next
/**
* Returns the next character in the stream and advances it.
* Also returns NaN when no more characters are available.
* @returns {Number}
*/
next() {
if (this.eof()) {
return NaN;
}
const line = this.document.lineAt(this.pos.line).text;
let code: number;
if (this.pos.character < line.length) {
code = line.charCodeAt(this.pos.character);
this.pos = this.pos.translate(0, 1);
} else {
code = this._eol.charCodeAt(this.pos.character - line.length);
this.pos = new Position(this.pos.line + 1, 0);
}
if (this.eof()) {
// restrict pos to eof, if in case it got moved beyond eof
this.pos = new Position(this._eof.line, this._eof.character);
}
return code;
}
示例5: syncWindows
public syncWindows() {
let editor = window.activeTextEditor;
if (!editor) {
return;
}
let doc = editor.document;
let editors: TextEditor[] = window.visibleTextEditors;
var i = 0;
var previousEditorPos = 0;
let previousPos: Position;
for (var theEditor of editors) {
console.log(theEditor.document.positionAt);
if (theEditor.viewColumn != ViewColumn.One) {
theEditor.revealRange(new Range(previousPos, previousPos.translate(theEditor.document.lineCount)));
} else {
previousPos = theEditor.selection.active;
}
}
}
示例6: Range
edits => {
edits.delete(new Range(start, position.translate(0, suffix ? suffix[0].length : 0)));
}, {