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


TypeScript editorExtensions.ServicesAccessor类代码示例

本文整理汇总了TypeScript中vs/editor/browser/editorExtensions.ServicesAccessor的典型用法代码示例。如果您正苦于以下问题:TypeScript ServicesAccessor类的具体用法?TypeScript ServicesAccessor怎么用?TypeScript ServicesAccessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ServicesAccessor类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: run

	public run(accessor: ServicesAccessor, editor: ICodeEditor): TPromise<void> {
		const debugService = accessor.get(IDebugService);
		const viewletService = accessor.get(IViewletService);

		const text = editor.getModel().getValueInRange(editor.getSelection());
		return viewletService.openViewlet(VIEWLET_ID).then(() => debugService.addWatchExpression(text));
	}
开发者ID:sameer-coder,项目名称:vscode,代码行数:7,代码来源:debugEditorActions.ts

示例2: run

	public run(accessor: ServicesAccessor, editor: ICodeEditor, args: any): TPromise<any> {
		const debugService = accessor.get(IDebugService);
		const editorService = accessor.get(IEditorService);
		const currentUri = editor.getModel().uri;
		const currentLine = editor.getPosition().lineNumber;
		//Breakpoints returned from `getBreakpoints` are already sorted.
		const allEnabledBreakpoints = debugService.getModel().getBreakpoints({ enabledOnly: true });

		//Try to find breakpoint in current file
		let moveBreakpoint =
			this.isNext
				? allEnabledBreakpoints.filter(bp => bp.uri.toString() === currentUri.toString() && bp.lineNumber > currentLine)[0]
				: allEnabledBreakpoints.filter(bp => bp.uri.toString() === currentUri.toString() && bp.lineNumber < currentLine)[0];

		//Try to find breakpoints in following files
		if (!moveBreakpoint) {
			moveBreakpoint =
				this.isNext
					? allEnabledBreakpoints.filter(bp => bp.uri.toString() > currentUri.toString())[0]
					: allEnabledBreakpoints.filter(bp => bp.uri.toString() < currentUri.toString())[0];
		}

		//Move to first possible breakpoint
		if (!moveBreakpoint) {
			moveBreakpoint = allEnabledBreakpoints[0];
		}

		if (moveBreakpoint) {
			return openBreakpointSource(moveBreakpoint, false, true, debugService, editorService);
		}

		return TPromise.as(null);
	}
开发者ID:jinlongchen2018,项目名称:vscode,代码行数:33,代码来源:debugEditorActions.ts

示例3: formatDocumentRangeWithFirstProvider

export async function formatDocumentRangeWithFirstProvider(
	accessor: ServicesAccessor,
	editorOrModel: ITextModel | IActiveCodeEditor,
	range: Range,
	token: CancellationToken
): Promise<boolean> {

	const instaService = accessor.get(IInstantiationService);
	const statusBarService = accessor.get(IStatusbarService);
	const labelService = accessor.get(ILabelService);

	const model = isCodeEditor(editorOrModel) ? editorOrModel.getModel() : editorOrModel;
	const [best, ...rest] = DocumentRangeFormattingEditProviderRegistry.ordered(model);
	if (!best) {
		return false;
	}
	const ret = await instaService.invokeFunction(formatDocumentRangeWithProvider, best, editorOrModel, range, token);
	if (rest.length > 0) {
		statusBarService.setStatusMessage(
			nls.localize('random.pick', "$(tasklist) Formatted '{0}' with '{1}'", labelService.getUriLabel(model.uri, { relative: true }), best.displayName),
			5 * 1000
		);
	}
	return ret;
}
开发者ID:joelday,项目名称:vscode,代码行数:25,代码来源:format.ts

示例4: run

	async run(accessor: ServicesAccessor, editor: ICodeEditor, args: any): Promise<void> {
		if (!editor.hasModel()) {
			return;
		}

		const commandService = accessor.get(ICommandService);
		const viewletService = accessor.get(IViewletService);
		const notificationService = accessor.get(INotificationService);
		const model = editor.getModel();
		const formatterCount = DocumentFormattingEditProviderRegistry.all(model).length;

		if (formatterCount > 1) {
			return commandService.executeCommand('editor.action.formatDocument.multiple');
		} else if (formatterCount === 1) {
			return commandService.executeCommand('editor.action.formatDocument');
		} else {
			const langName = model.getLanguageIdentifier().language;
			const message = nls.localize('no.rovider', "There is no formatter for '{0}'-files installed.", langName);
			const choice = {
				label: nls.localize('install.formatter', "Install Formatter..."),
				run: () => showExtensionQuery(viewletService, `category:formatters ${langName}`)
			};
			notificationService.prompt(Severity.Info, message, [choice]);
		}
	}
开发者ID:eamodio,项目名称:vscode,代码行数:25,代码来源:formatActionsNone.ts

示例5: run

	public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
		const keybindingService = accessor.get(IKeybindingService);
		const editorService = accessor.get(IEditorService);

		if (keybindingService instanceof WorkbenchKeybindingService) {
			editorService.openEditor({ contents: keybindingService.dumpDebugInfo(), options: { pinned: true } } as IUntitledResourceInput);
		}
	}
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:8,代码来源:inspectKeybindings.ts

示例6: run

	public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
		const configurationService = accessor.get(IConfigurationService);

		let newRenderControlCharacters = !editor.getConfiguration().viewInfo.renderControlCharacters;

		configurationService.updateValue('editor.renderControlCharacters', newRenderControlCharacters, ConfigurationTarget.USER);
	}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:7,代码来源:toggleRenderControlCharacter.ts

示例7: run

	public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
		const configurationService = accessor.get(IConfigurationService);

		const newValue = !editor.getConfiguration().viewInfo.minimap.enabled;

		configurationService.updateValue('editor.minimap.enabled', newValue, ConfigurationTarget.USER);
	}
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:7,代码来源:toggleMinimap.ts

示例8: run

	public run(accessor: ServicesAccessor, editor: ICodeEditor): TPromise<void> {
		const debugService = accessor.get(IDebugService);
		if (debugService.state !== State.Stopped) {
			return TPromise.as(null);
		}

		let breakpointToRemove: IBreakpoint;
		const oneTimeListener = debugService.getViewModel().focusedSession.raw.onDidEvent(event => {
			if (event.event === 'stopped' || event.event === 'exit') {
				if (breakpointToRemove) {
					debugService.removeBreakpoints(breakpointToRemove.getId());
				}
				oneTimeListener.dispose();
			}
		});

		const position = editor.getPosition();
		const uri = editor.getModel().uri;
		const bpExists = !!(debugService.getModel().getBreakpoints({ column: position.column, lineNumber: position.lineNumber, uri }).length);
		return (bpExists ? TPromise.as(null) : debugService.addBreakpoints(uri, [{ lineNumber: position.lineNumber, column: position.column }])).then((breakpoints) => {
			if (breakpoints && breakpoints.length) {
				breakpointToRemove = breakpoints[0];
			}
			debugService.getViewModel().focusedThread.continue();
		});
	}
开发者ID:AllureFer,项目名称:vscode,代码行数:26,代码来源:debugEditorActions.ts


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