Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Resolve sourcemapped program at launch for microsoft/vscode-node-debu…
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Sep 21, 2016
1 parent a37b727 commit e7ddfee
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/chrome/chromeDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export abstract class ChromeDebugAdapter extends BaseDebugAdapter {
protected _chromeConnection: ChromeConnection;

private _lineNumberTransformer: LineNumberTransformer;
private _sourceMapTransformer: BaseSourceMapTransformer;
protected _sourceMapTransformer: BaseSourceMapTransformer;
private _pathTransformer: BasePathTransformer;

private _hasTerminated: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/debugAdapterInterfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type ISourceMapPathOverrides = { [pattern: string]: string };
export interface CommonRequestArgs {
webRoot?: string;
outDir?: string;
outDirs?: string[];
outFiles?: string[];
sourceMaps?: boolean;
diagnosticLogging?: boolean;
verboseDiagnosticLogging?: boolean;
Expand Down
21 changes: 20 additions & 1 deletion src/transformers/baseSourceMapTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {Handles} from 'vscode-debugadapter';

import {ISetBreakpointsArgs, ILaunchRequestArgs, IAttachRequestArgs,
ISetBreakpointsResponseBody, IStackTraceResponseBody} from '../debugAdapterInterfaces';
import {MappedPosition} from '../sourceMaps/sourceMap';
import {SourceMaps} from '../sourceMaps/sourceMaps';
import * as utils from '../utils';
import * as logger from '../logger';
Expand All @@ -32,10 +33,16 @@ export class BaseSourceMapTransformer {
private _pendingBreakpointsByPath = new Map<string, IPendingBreakpoint>();
private _authoredPathsToMappedBPs: Map<string, DebugProtocol.SourceBreakpoint[]>;

protected _preLoad = Promise.resolve<void>();

constructor(sourceHandles: Handles<ISourceContainer>) {
this._sourceHandles = sourceHandles;
}

public get sourceMaps(): SourceMaps {
return this._sourceMaps;
}

public launch(args: ILaunchRequestArgs): void {
this.init(args);
}
Expand Down Expand Up @@ -231,13 +238,25 @@ export class BaseSourceMapTransformer {
if (this._sourceMaps) {
const mapped = this._sourceMaps.mapToAuthored(scriptPath, bp.line, bp.column);
if (mapped) {
// Not sending back the path here, since the bp has an ID
// No need to send back the path, the bp can only move within its script
bp.line = mapped.line;
bp.column = mapped.column;
}
}
}

public mapToGenerated(authoredPath: string, line: number, column: number): Promise<MappedPosition> {
return this._preLoad.then(() => this._sourceMaps.mapToGenerated(authoredPath, line, column));
}

public mapToAuthored(pathToGenerated: string, line: number, column: number): Promise<MappedPosition> {
return this._preLoad.then(() => this._sourceMaps.mapToAuthored(pathToGenerated, line, column));
}

public getGeneratedPathFromAuthoredPath(authoredPath: string): Promise<string> {
return this._preLoad.then(() => this._sourceMaps.getGeneratedPathFromAuthoredPath(authoredPath));
}

/**
* Resolve any pending breakpoints for this script
*/
Expand Down
5 changes: 2 additions & 3 deletions src/transformers/eagerSourceMapTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ import * as logger from '../logger';
*/
export class EagerSourceMapTransformer extends BaseSourceMapTransformer {
private static SOURCE_MAPPING_MATCHER = new RegExp('^//[#@] ?sourceMappingURL=(.+)$');
private _preLoad: Promise<void>;

protected init(args: ILaunchRequestArgs | IAttachRequestArgs): void {
super.init(args);
if (args.sourceMaps) {
const generatedCodeGlobs = args.outDirs ?
args.outDirs :
const generatedCodeGlobs = args.outFiles ?
args.outFiles :
args.outDir ?
[path.join(args.outDir, '**/*.js')] :
[];
Expand Down

0 comments on commit e7ddfee

Please sign in to comment.