本文整理汇总了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));
}
示例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);
}
示例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;
}
示例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]);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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();
});
}