当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Position.translate方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:bryangingechen,项目名称:vscode-lean,代码行数:27,代码来源:completion.ts

示例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;
	}
开发者ID:YanLinAung,项目名称:vscode-go,代码行数:10,代码来源:goSignature.ts

示例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);
	}
开发者ID:yuit,项目名称:vscode,代码行数:23,代码来源:jsDocCompletionProvider.ts

示例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;
	}
开发者ID:FabianLauer,项目名称:vscode,代码行数:27,代码来源:bufferStream.ts

示例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;
            }
        }
    }
开发者ID:Xography,项目名称:vscode-scrollsync,代码行数:23,代码来源:extension.ts

示例6: Range

			edits => {
				edits.delete(new Range(start, position.translate(0, suffix ? suffix[0].length : 0)));
			}, {
开发者ID:yuit,项目名称:vscode,代码行数:3,代码来源:jsDocCompletionProvider.ts


注:本文中的vscode.Position.translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。