提交 38c54228 编写于 作者: I isidor

debug: reuse Source.getEncodedDebugData

上级 35209395
......@@ -13,6 +13,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import { ITextModelService, ITextModelContentProvider } from 'vs/editor/common/services/resolverService';
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { DEBUG_SCHEME, IDebugService, IProcess } from 'vs/workbench/parts/debug/common/debug';
import { Source } from 'vs/workbench/parts/debug/common/debugSource';
/**
* Debug URI format
......@@ -48,21 +49,9 @@ export class DebugContentProvider implements IWorkbenchContribution, ITextModelC
let sourceRef: number;
if (resource.query) {
const keyvalues = resource.query.split('&');
for (let keyvalue of keyvalues) {
const pair = keyvalue.split('=');
if (pair.length === 2) {
switch (pair[0]) {
case 'session':
const processId = decodeURIComponent(pair[1]);
process = this.debugService.getModel().getProcesses().filter(p => p.getId() === processId).pop();
break;
case 'ref':
sourceRef = parseInt(pair[1]);
break;
}
}
}
const data = Source.getEncodedDebugData(resource);
process = this.debugService.getModel().getProcesses().filter(p => p.getId() === data.processId).pop();
sourceRef = data.sourceReference;
}
if (!process) {
......
......@@ -70,11 +70,10 @@ export class Source {
}, sideBySide);
}
public static createRawSource(modelUri: uri): DebugProtocol.Source {
let name = resources.basenameOrAuthority(modelUri);
public static getEncodedDebugData(modelUri: uri): { name: string, path: string, processId: string, sourceReference: number } {
let path: string;
let sourceRef: number;
let sourceReference: number;
let processId: string;
switch (modelUri.scheme) {
case 'file':
......@@ -89,9 +88,10 @@ export class Source {
if (pair.length === 2) {
switch (pair[0]) {
case 'session':
processId = decodeURIComponent(pair[1]);
break;
case 'ref':
sourceRef = parseInt(pair[1]);
sourceReference = parseInt(pair[1]);
break;
}
}
......@@ -103,10 +103,11 @@ export class Source {
break;
}
const src: DebugProtocol.Source = { name, path };
if (sourceRef) {
src.sourceReference = sourceRef;
}
return src;
return {
name: resources.basenameOrAuthority(modelUri),
path,
sourceReference,
processId
};
}
}
\ No newline at end of file
......@@ -1110,7 +1110,14 @@ export class DebugService implements debug.IDebugService {
const breakpointsToSend = this.model.getBreakpoints().filter(bp => this.model.areBreakpointsActivated() && bp.enabled && bp.uri.toString() === modelUri.toString());
const source = process.sources.get(modelUri.toString());
const rawSource = source ? source.raw : Source.createRawSource(modelUri);
let rawSource: DebugProtocol.Source;
if (source) {
rawSource = source.raw;
} else {
const data = Source.getEncodedDebugData(modelUri);
rawSource = { name: data.name, path: data.path, sourceReference: data.sourceReference };
}
if (breakpointsToSend.length && !rawSource.adapterData) {
rawSource.adapterData = breakpointsToSend[0].adapterData;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册