Skip to content

Commit

Permalink
debug debt: adop ITextModelResolverService
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Dec 14, 2016
1 parent 38df929 commit 6d9aa5a
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 215 deletions.
15 changes: 13 additions & 2 deletions src/vs/workbench/parts/debug/browser/debugActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { IDebugService, State, IProcess, SessionRequestType, IThread, IEnablemen
import { Variable, Expression, Thread, Breakpoint } from 'vs/workbench/parts/debug/common/debugModel';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { TogglePanelAction } from 'vs/workbench/browser/panel';

export class AbstractDebugAction extends Action {
Expand Down Expand Up @@ -697,7 +698,11 @@ export class FocusProcessAction extends AbstractDebugAction {
static ID = 'workbench.action.debug.focusProcess';
static LABEL = nls.localize('focusProcess', "Focus Process");

constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
constructor(id: string, label: string,
@IDebugService debugService: IDebugService,
@IKeybindingService keybindingService: IKeybindingService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService
) {
super(id, label, null, debugService, keybindingService, 100);
}

Expand All @@ -706,7 +711,13 @@ export class FocusProcessAction extends AbstractDebugAction {
return this.debugService.focusStackFrameAndEvaluate(null, process).then(() => {
const stackFrame = this.debugService.getViewModel().focusedStackFrame;
if (stackFrame) {
return this.debugService.openOrRevealSource(stackFrame.source, stackFrame.lineNumber, true, false);
return this.editorService.openEditor({
resource: stackFrame.source.uri,
options: {
preserveFocus: true,
selection: { startLineNumber: stackFrame.lineNumber, startColumn: 1 }
}
});
}
});
}
Expand Down
49 changes: 49 additions & 0 deletions src/vs/workbench/parts/debug/browser/debugContentProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import uri from 'vs/base/common/uri';
import { TPromise } from 'vs/base/common/winjs.base';
import { guessMimeTypes } from 'vs/base/common/mime';
import { IModel } from 'vs/editor/common/editorCommon';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IModeService } from 'vs/editor/common/services/modeService';
import { ITextModelResolverService, ITextModelContentProvider } from 'vs/editor/common/services/resolverService';
import { DEBUG_SCHEME, IDebugService } from 'vs/workbench/parts/debug/common/debug';
import { Model } from 'vs/workbench/parts/debug/common/debugModel';
import { Source } from 'vs/workbench/parts/debug/common/debugSource';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';

export class DebugContentProvider implements IWorkbenchContribution, ITextModelContentProvider {

constructor(
@ITextModelResolverService textModelResolverService: ITextModelResolverService,
@IDebugService private debugService: IDebugService,
@IModelService private modelService: IModelService,
@IModeService private modeService: IModeService
) {
textModelResolverService.registerTextModelContentProvider(DEBUG_SCHEME, this);
}

public getId(): string {
return 'debug.contentprovider';
}

public provideTextContent(resource: uri): TPromise<IModel> {
const process = this.debugService.getViewModel().focusedProcess;
if (!process) {
return TPromise.as(null);
}

return process.session.source({ sourceReference: Source.getSourceReference(resource) }).then(response => {
const mime = response.body.mimeType || guessMimeTypes(resource.toString())[0];
const modePromise = this.modeService.getOrCreateMode(mime);

return this.modelService.createModel(response.body.content, modePromise, resource);
}, err => {
(<Model>this.debugService.getModel()).sourceIsUnavailable(resource);
return err;
});
}
}
51 changes: 0 additions & 51 deletions src/vs/workbench/parts/debug/browser/debugEditorInputs.ts

This file was deleted.

36 changes: 0 additions & 36 deletions src/vs/workbench/parts/debug/browser/debugErrorEditor.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/vs/workbench/parts/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,6 @@ export interface IDebugService {
* Gets the current view model.
*/
getViewModel(): IViewModel;

/**
* Opens a new or reveals an already visible editor showing the source.
*/
openOrRevealSource(sourceOrUri: Source | uri, lineNumber: number, preserveFocus: boolean, sideBySide: boolean): TPromise<any>;
}

// Editor interfaces
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/parts/debug/common/debugModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,11 @@ export class Process implements debug.IProcess {
}
}

public sourceIsUnavailable(source: Source): void {
public sourceIsUnavailable(uri: uri): void {
Object.keys(this.threads).forEach(key => {
if (this.threads[key].getCachedCallStack()) {
this.threads[key].getCachedCallStack().forEach(stackFrame => {
if (stackFrame.source.uri.toString() === source.uri.toString()) {
if (stackFrame.source.uri.toString() === uri.toString()) {
stackFrame.source.available = false;
}
});
Expand Down Expand Up @@ -909,8 +909,8 @@ export class Model implements debug.IModel {
this._onDidChangeWatchExpressions.fire();
}

public sourceIsUnavailable(source: Source): void {
this.processes.forEach(p => p.sourceIsUnavailable(source));
public sourceIsUnavailable(uri: uri): void {
this.processes.forEach(p => p.sourceIsUnavailable(uri));
this._onDidChangeCallStack.fire();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IKeybindings } from 'vs/platform/keybinding/common/keybinding';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { IWorkbenchActionRegistry, Extensions as WorkbenchActionRegistryExtensions } from 'vs/workbench/common/actionRegistry';
import { ToggleViewletAction, Extensions as ViewletExtensions, ViewletRegistry, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
import { TogglePanelAction, Extensions as PanelExtensions, PanelRegistry, PanelDescriptor } from 'vs/workbench/browser/panel';
import { DebugViewRegistry } from 'vs/workbench/parts/debug/browser/debugViewRegistry';
import { VariablesView, WatchExpressionsView, CallStackView, BreakpointsView } from 'vs/workbench/parts/debug/electron-browser/debugViews';
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import { EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { IDebugService, VIEWLET_ID, REPL_ID, CONTEXT_NOT_IN_DEBUG_MODE, CONTEXT_IN_DEBUG_MODE } from 'vs/workbench/parts/debug/common/debug';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
Expand All @@ -32,11 +30,9 @@ import {
} from 'vs/workbench/parts/debug/browser/debugActions';
import { DebugActionsWidget } from 'vs/workbench/parts/debug/browser/debugActionsWidget';
import * as service from 'vs/workbench/parts/debug/electron-browser/debugService';
import { DebugErrorEditorInput } from 'vs/workbench/parts/debug/browser/debugEditorInputs';
import { DebugErrorEditor } from 'vs/workbench/parts/debug/browser/debugErrorEditor';
import { DebugContentProvider } from 'vs/workbench/parts/debug/browser/debugContentProvider';
import 'vs/workbench/parts/debug/electron-browser/debugEditorContribution';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/common/editor';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';


Expand Down Expand Up @@ -109,6 +105,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(OpenDebugViewletAction

(<IWorkbenchContributionsRegistry>Registry.as(WorkbenchExtensions.Workbench)).registerWorkbenchContribution(DebugEditorModelManager);
(<IWorkbenchContributionsRegistry>Registry.as(WorkbenchExtensions.Workbench)).registerWorkbenchContribution(DebugActionsWidget);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(DebugContentProvider);

const debugCategory = nls.localize('debugCategory', "Debug");
registry.registerWorkbenchAction(new SyncActionDescriptor(
Expand Down Expand Up @@ -145,14 +142,6 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
// register service
registerSingleton(IDebugService, service.DebugService);

// Register Debug Error Editor #9062
(<IEditorRegistry>Registry.as(EditorExtensions.Editors)).registerEditor(new EditorDescriptor(DebugErrorEditor.ID,
nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'debugErrorEditor' }, "Debug Error"),
'vs/workbench/parts/debug/browser/debugErrorEditor',
'DebugErrorEditor'),
[new SyncDescriptor(DebugErrorEditorInput)]
);

// Register configuration
const configurationRegistry = <IConfigurationRegistry>Registry.as(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
Expand Down
Loading

0 comments on commit 6d9aa5a

Please sign in to comment.