提交 fa3494b1 编写于 作者: I isidor

debug: move debugSource to its own file.

上级 d147ddd4
......@@ -7,12 +7,12 @@ import nls = require('vs/nls');
import uri from 'vs/base/common/uri';
import { TPromise, Promise } from 'vs/base/common/winjs.base';
import ee = require('vs/base/common/eventEmitter');
import paths = require('vs/base/common/paths');
import severity from 'vs/base/common/severity';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import pluginsRegistry = require('vs/platform/plugins/common/pluginsRegistry');
import editor = require('vs/editor/common/editorCommon');
import { Source } from 'vs/workbench/parts/debug/common/debugSource';
export var VIEWLET_ID = 'workbench.view.debug';
export var DEBUG_SERVICE_ID = 'debugService';
......@@ -79,36 +79,6 @@ export interface IExceptionBreakpoint extends IEnablement {
name: string;
}
export class Source {
public uri: uri;
public inMemory: boolean;
public available: boolean;
private static INTERNAL_URI_PREFIX = 'debug://internal/';
constructor(public name: string, uriStr: string, public reference = 0) {
this.uri = uri.parse(uriStr);
this.inMemory = uriStr.indexOf(Source.INTERNAL_URI_PREFIX) === 0;
this.available = true;
}
public toRawSource(): DebugProtocol.Source {
return this.inMemory ? { name: this.name } :
{ path: paths.normalize(this.uri.fsPath, true) };
}
public static fromRawSource(rawSource: DebugProtocol.Source): Source {
var uriStr = rawSource.path ? uri.file(rawSource.path).toString() : Source.INTERNAL_URI_PREFIX + rawSource.name;
return new Source(rawSource.name, uriStr, rawSource.sourceReference);
}
public static fromUri(uri: uri): Source {
var uriStr = uri.toString();
return new Source(uriStr.substr(uriStr.lastIndexOf('/') + 1), uriStr);
}
}
// Events
export var ModelEvents = {
......
......@@ -13,6 +13,7 @@ import severity from 'vs/base/common/severity';
import types = require('vs/base/common/types');
import arrays = require('vs/base/common/arrays');
import debug = require('vs/workbench/parts/debug/common/debug');
import { Source } from 'vs/workbench/parts/debug/common/debugSource';
function resolveChildren(debugService: debug.IDebugService, parent: debug.IExpressionContainer): TPromise<Variable[]> {
var session = debugService.getActiveSession();
......@@ -204,7 +205,7 @@ export class StackFrame implements debug.IStackFrame {
private internalId: string;
private scopes: TPromise<Scope[]>;
constructor(public threadId: number, public frameId: number, public source: debug.Source, public name: string, public lineNumber: number, public column: number) {
constructor(public threadId: number, public frameId: number, public source: Source, public name: string, public lineNumber: number, public column: number) {
this.internalId = uuid.generateUuid();
this.scopes = null;
}
......@@ -229,7 +230,7 @@ export class Breakpoint implements debug.IBreakpoint {
public lineNumber: number;
private id: string;
constructor(public source: debug.Source, public desiredLineNumber: number, public enabled: boolean) {
constructor(public source: Source, public desiredLineNumber: number, public enabled: boolean) {
this.lineNumber = this.desiredLineNumber;
this.id = uuid.generateUuid();
}
......@@ -326,7 +327,7 @@ export class Model extends ee.EventEmitter implements debug.IModel {
}
if (!found) {
this.breakpoints.push(new Breakpoint(debug.Source.fromUri(modelUri), lineNumber, true));
this.breakpoints.push(new Breakpoint(Source.fromUri(modelUri), lineNumber, true));
this.breakpointsActivated = true;
}
......@@ -370,7 +371,7 @@ export class Model extends ee.EventEmitter implements debug.IModel {
public setBreakpointsForModel(modelUri: uri, data: { lineNumber: number; enabled: boolean; }[]): void {
this.clearBreakpoints(modelUri);
for (var i = 0, len = data.length; i < len; i++) {
this.breakpoints.push(new Breakpoint(debug.Source.fromUri(modelUri), data[i].lineNumber, data[i].enabled));
this.breakpoints.push(new Breakpoint(Source.fromUri(modelUri), data[i].lineNumber, data[i].enabled));
}
this.emit(debug.ModelEvents.BREAKPOINTS_UPDATED);
}
......@@ -533,7 +534,7 @@ export class Model extends ee.EventEmitter implements debug.IModel {
this.emit(debug.ModelEvents.WATCH_EXPRESSIONS_UPDATED);
}
public sourceIsUnavailable(source: debug.Source): void {
public sourceIsUnavailable(source: Source): void {
Object.keys(this.threads).forEach(key => {
this.threads[key].callStack.forEach(stackFrame => {
if (stackFrame.source.uri.toString() === source.uri.toString()) {
......@@ -555,10 +556,10 @@ export class Model extends ee.EventEmitter implements debug.IModel {
this.threads[data.threadId].callStack = data.callStack.map(
(rsf, level) => {
if (!rsf) {
return new StackFrame(data.threadId, 0, debug.Source.fromUri(uri.parse('unknown')), nls.localize('unknownStack', "Unknown stack location"), undefined, undefined);
return new StackFrame(data.threadId, 0, Source.fromUri(uri.parse('unknown')), nls.localize('unknownStack', "Unknown stack location"), undefined, undefined);
}
return new StackFrame(data.threadId, rsf.id, rsf.source ? debug.Source.fromRawSource(rsf.source) : debug.Source.fromUri(uri.parse('unknown')), rsf.name, rsf.line, rsf.column);
return new StackFrame(data.threadId, rsf.id, rsf.source ? Source.fromRawSource(rsf.source) : Source.fromUri(uri.parse('unknown')), rsf.name, rsf.line, rsf.column);
});
this.threads[data.threadId].exception = data.exception;
......
/*---------------------------------------------------------------------------------------------
* 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 paths = require('vs/base/common/paths');
export class Source {
public uri: uri;
public inMemory: boolean;
public available: boolean;
private static INTERNAL_URI_PREFIX = 'debug://internal/';
constructor(public name: string, uriStr: string, public reference = 0) {
this.uri = uri.parse(uriStr);
this.inMemory = uriStr.indexOf(Source.INTERNAL_URI_PREFIX) === 0;
this.available = true;
}
public toRawSource(): DebugProtocol.Source {
return this.inMemory ? { name: this.name } :
{ path: paths.normalize(this.uri.fsPath, true) };
}
public static fromRawSource(rawSource: DebugProtocol.Source): Source {
var uriStr = rawSource.path ? uri.file(rawSource.path).toString() : Source.INTERNAL_URI_PREFIX + rawSource.name;
return new Source(rawSource.name, uriStr, rawSource.sourceReference);
}
public static fromUri(uri: uri): Source {
var uriStr = uri.toString();
return new Source(uriStr.substr(uriStr.lastIndexOf('/') + 1), uriStr);
}
}
......@@ -31,6 +31,7 @@ import viewmodel = require('vs/workbench/parts/debug/common/debugViewModel');
import debugactions = require('vs/workbench/parts/debug/browser/debugActions');
import { Adapter } from 'vs/workbench/parts/debug/node/debugAdapter';
import { Repl } from 'vs/workbench/parts/debug/browser/replEditor';
import { Source } from 'vs/workbench/parts/debug/common/debugSource';
import { Position } from 'vs/platform/editor/common/editor';
import { ITaskService , TaskEvent, TaskType, TaskServiceEvents} from 'vs/workbench/parts/tasks/common/taskService';
import { IViewletService } from 'vs/workbench/services/viewlet/common/viewletService';
......@@ -366,7 +367,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
private loadBreakpoints(): debug.IBreakpoint[] {
try {
return JSON.parse(this.storageService.get(DEBUG_BREAKPOINTS_KEY, StorageScope.WORKSPACE, '[]')).map((breakpoint: any) => {
return new model.Breakpoint(new debug.Source(breakpoint.source.name, breakpoint.source.uri, breakpoint.source.reference), breakpoint.desiredLineNumber || breakpoint.lineNumber, breakpoint.enabled);
return new model.Breakpoint(new Source(breakpoint.source.name, breakpoint.source.uri, breakpoint.source.reference), breakpoint.desiredLineNumber || breakpoint.lineNumber, breakpoint.enabled);
});
} catch (e) {
return [];
......@@ -746,7 +747,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
return this.viewModel;
}
public openOrRevealEditor(source: debug.Source, lineNumber: number, preserveFocus: boolean, sideBySide: boolean): Promise {
public openOrRevealEditor(source: Source, lineNumber: number, preserveFocus: boolean, sideBySide: boolean): Promise {
const visibleEditors = this.editorService.getVisibleEditors();
for (var i = 0; i < visibleEditors.length; i++) {
const fileInput = wbeditorcommon.asFileEditorInput(visibleEditors[i].input);
......@@ -798,7 +799,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
);
}
private sourceIsUnavailable(source: debug.Source, sideBySide: boolean): Promise {
private sourceIsUnavailable(source: Source, sideBySide: boolean): Promise {
this.model.sourceIsUnavailable(source);
const editorInput = this.getDebugStringEditorInput(source, 'Source is not available.', 'text/plain');
......@@ -844,7 +845,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
});
}
private getDebugStringEditorInput(source: debug.Source, value: string, mtype: string): debuginputs.DebugStringEditorInput {
private getDebugStringEditorInput(source: Source, value: string, mtype: string): debuginputs.DebugStringEditorInput {
var filtered = this.debugStringEditorInputs.filter(input => input.getResource().toString() === source.uri.toString());
if (filtered.length === 0) {
......@@ -880,7 +881,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
this.model.getBreakpoints().filter(bp => this.model.areBreakpointsActivated() && bp.enabled && bp.source.uri.toString() === modelUri.toString()),
bp => `${ bp.desiredLineNumber }`
);
return this.session.setBreakpoints({ source: debug.Source.fromUri(modelUri).toRawSource(), lines: breakpointsToSend.map(bp => bp.desiredLineNumber) }).then(response => {
return this.session.setBreakpoints({ source: Source.fromUri(modelUri).toRawSource(), lines: breakpointsToSend.map(bp => bp.desiredLineNumber) }).then(response => {
let index = 0;
breakpointsToSend.forEach(bp => {
const lineNumber = response.body.breakpoints[index++].line;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册