Skip to content

Commit

Permalink
Revert of DevTools: support resolving a UILocation to multiple raw sc…
Browse files Browse the repository at this point in the history
…ript locations (patchset #3 id:60001 of https://codereview.chromium.org/2857453002/ )

Reason for revert:
We decided that we don't need that.

Original issue's description:
> DevTools: support resolving a UILocation to multiple raw script locations
>
> This turns uiLocationToRawLocation into uiLocationToRawLocations and makes it return an array
>
> BUG=717694
>
> Review-Url: https://codereview.chromium.org/2857453002
> Cr-Commit-Position: refs/heads/master@{#468825}
> Committed: https://chromium.googlesource.com/chromium/src/+/421b9c4b9736e52c903123994d977b4ed406cf72

[email protected],[email protected]
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=717694

Review-Url: https://codereview.chromium.org/2859073002
Cr-Commit-Position: refs/heads/master@{#469206}
  • Loading branch information
caseq authored and Commit bot committed May 3, 2017
1 parent 59c0d0a commit dff718f
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 70 deletions.
14 changes: 6 additions & 8 deletions front_end/bindings/BreakpointManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,13 @@ Bindings.BreakpointManager = class extends Common.Object {
* @return {!Promise<!Array<!Workspace.UILocation>>}
*/
possibleBreakpoints(uiSourceCode, textRange) {
var startLocations = Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(
var startLocation = Bindings.debuggerWorkspaceBinding.uiLocationToRawLocation(
uiSourceCode, textRange.startLine, textRange.startColumn);
var endLocations = Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(
uiSourceCode, textRange.endLine, textRange.endColumn);
var startLocationsByScript = new Map(startLocations.map(location => [location.script(), location]));
var endLocation = endLocations.find(location => location.script() && startLocationsByScript.get(location.script()));
if (!endLocation)
var endLocation =
Bindings.debuggerWorkspaceBinding.uiLocationToRawLocation(uiSourceCode, textRange.endLine, textRange.endColumn);
if (!startLocation || !endLocation || startLocation.debuggerModel !== endLocation.debuggerModel)
return Promise.resolve([]);
var startLocation = startLocationsByScript.get(endLocation.script());

return startLocation.debuggerModel
.getPossibleBreakpoints(startLocation, endLocation, /* restrictToFunction */ false)
.then(toUILocations.bind(this));
Expand Down Expand Up @@ -811,7 +809,7 @@ Bindings.BreakpointManager.ModelBreakpoint = class {
var condition = this._breakpoint.condition();

var debuggerLocation = uiSourceCode &&
Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber)[0];
Bindings.debuggerWorkspaceBinding.uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber);
var newState;
if (this._breakpoint._isRemoved || !this._breakpoint.enabled() || this._scriptDiverged()) {
newState = null;
Expand Down
19 changes: 11 additions & 8 deletions front_end/bindings/CompilerScriptMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,19 @@ Bindings.CompilerScriptMapping = class {
* @param {!Workspace.UISourceCode} uiSourceCode
* @param {number} lineNumber
* @param {number} columnNumber
* @return {!Array<!SDK.DebuggerModel.Location>}
* @return {?SDK.DebuggerModel.Location}
*/
uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber) {
uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) {
var script = uiSourceCode[Bindings.CompilerScriptMapping._scriptSymbol];
var sourceMap = script && this._sourceMapManager.sourceMapForClient(script);
if (!script)
return null;
var sourceMap = this._sourceMapManager.sourceMapForClient(script);
if (!sourceMap)
return [];
return sourceMap.mappingsForLine(uiSourceCode.url(), lineNumber)
.map(entry => this._debuggerModel.createRawLocation(script, entry.lineNumber, entry.columnNumber))
.filter(location => !!location);
return null;
var entry = sourceMap.firstSourceLineMapping(uiSourceCode.url(), lineNumber);
if (!entry)
return null;
return this._debuggerModel.createRawLocation(script, entry.lineNumber, entry.columnNumber);
}

/**
Expand Down Expand Up @@ -275,7 +278,7 @@ Bindings.CompilerScriptMapping = class {
var sourceMap = script ? this._sourceMapManager.sourceMapForClient(script) : null;
if (!sourceMap)
return true;
return sourceMap.mappingsForLine(uiSourceCode.url(), lineNumber).length > 0;
return !!sourceMap.firstSourceLineMapping(uiSourceCode.url(), lineNumber);
}

dispose() {
Expand Down
18 changes: 9 additions & 9 deletions front_end/bindings/DebuggerWorkspaceBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,22 +170,22 @@ Bindings.DebuggerWorkspaceBinding = class extends Common.Object {
* @param {!Workspace.UISourceCode} uiSourceCode
* @param {number} lineNumber
* @param {number} columnNumber
* @return {!Array<!SDK.DebuggerModel.Location>}
* @return {?SDK.DebuggerModel.Location}
*/
uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber) {
uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) {
var sourceMapping = uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMappingSymbol];
return sourceMapping ? sourceMapping.uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber) : [];
return sourceMapping && sourceMapping.uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber);
}

/**
* @param {!Workspace.UILocation} uiLocation
* @return {!Workspace.UILocation}
*/
normalizeUILocation(uiLocation) {
var rawLocations =
this.uiLocationToRawLocations(uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber);
if (rawLocations.length)
return this.rawLocationToUILocation(rawLocations[0]);
var rawLocation =
this.uiLocationToRawLocation(uiLocation.uiSourceCode, uiLocation.lineNumber, uiLocation.columnNumber);
if (rawLocation)
return this.rawLocationToUILocation(rawLocation);
return uiLocation;
}

Expand Down Expand Up @@ -586,9 +586,9 @@ Bindings.DebuggerSourceMapping.prototype = {
* @param {!Workspace.UISourceCode} uiSourceCode
* @param {number} lineNumber
* @param {number} columnNumber
* @return {!Array<!SDK.DebuggerModel.Location>}
* @return {?SDK.DebuggerModel.Location}
*/
uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber) {},
uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) {},

/**
* @return {boolean}
Expand Down
11 changes: 4 additions & 7 deletions front_end/bindings/DefaultScriptMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,15 @@ Bindings.DefaultScriptMapping = class {
* @param {!Workspace.UISourceCode} uiSourceCode
* @param {number} lineNumber
* @param {number} columnNumber
* @return {!Array<!SDK.DebuggerModel.Location>}
* @return {?SDK.DebuggerModel.Location}
*/
uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber) {
uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) {
var script = uiSourceCode[Bindings.DefaultScriptMapping._scriptSymbol];
var location;
if (script.isInlineScriptWithSourceURL()) {
location = this._debuggerModel.createRawLocation(
return this._debuggerModel.createRawLocation(
script, lineNumber + script.lineOffset, lineNumber ? columnNumber : columnNumber + script.columnOffset);
} else {
location = this._debuggerModel.createRawLocation(script, lineNumber, columnNumber);
}
return location ? [location] : [];
return this._debuggerModel.createRawLocation(script, lineNumber, columnNumber);
}

/**
Expand Down
11 changes: 4 additions & 7 deletions front_end/bindings/ResourceScriptMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,17 @@ Bindings.ResourceScriptMapping = class {
* @param {!Workspace.UISourceCode} uiSourceCode
* @param {number} lineNumber
* @param {number} columnNumber
* @return {!Array<!SDK.DebuggerModel.Location>}
* @return {?SDK.DebuggerModel.Location}
*/
uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber) {
uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) {
var scripts = this._scriptsForUISourceCode(uiSourceCode);
console.assert(scripts.length);
var script = scripts[scripts.length - 1];
var location;
if (script.isInlineScriptWithSourceURL()) {
location = this._debuggerModel.createRawLocation(
return this._debuggerModel.createRawLocation(
script, lineNumber + script.lineOffset, lineNumber ? columnNumber : columnNumber + script.columnOffset);
} else {
location = this._debuggerModel.createRawLocation(script, lineNumber, columnNumber);
}
return location ? [location] : [];
return this._debuggerModel.createRawLocation(script, lineNumber, columnNumber);
}

/**
Expand Down
22 changes: 15 additions & 7 deletions front_end/sdk/SourceMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,15 +345,23 @@ SDK.TextSourceMap = class {
/**
* @param {string} sourceURL
* @param {number} lineNumber
* @return {!Array<!SDK.SourceMapEntry>}
* @return {?SDK.SourceMapEntry}
*/
mappingsForLine(sourceURL, lineNumber) {
firstSourceLineMapping(sourceURL, lineNumber) {
var mappings = this._reversedMappings(sourceURL);
var startIndex = mappings.lowerBound(lineNumber, (lineNumber, mapping) => lineNumber - mapping.sourceLineNumber);
var endIndex = startIndex;
while (endIndex < mappings.length && mappings[endIndex].sourceLineNumber === lineNumber)
++endIndex;
return mappings.slice(startIndex, endIndex);
var index = mappings.lowerBound(lineNumber, lineComparator);
if (index >= mappings.length || mappings[index].sourceLineNumber !== lineNumber)
return null;
return mappings[index];

/**
* @param {number} lineNumber
* @param {!SDK.SourceMapEntry} mapping
* @return {number}
*/
function lineComparator(lineNumber, mapping) {
return lineNumber - mapping.sourceLineNumber;
}
}

/**
Expand Down
12 changes: 6 additions & 6 deletions front_end/snippets/ScriptSnippetModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,14 @@ Snippets.SnippetScriptMapping = class {
* @param {!Workspace.UISourceCode} uiSourceCode
* @param {number} lineNumber
* @param {number} columnNumber
* @return {!Array<!SDK.DebuggerModel.Location>}
* @return {?SDK.DebuggerModel.Location}
*/
uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber) {
uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) {
var script = this._scriptForUISourceCode.get(uiSourceCode);
var location;
if (script)
location = this._debuggerModel.createRawLocation(script, lineNumber, columnNumber);
return location ? [location] : [];
if (!script)
return null;

return this._debuggerModel.createRawLocation(script, lineNumber, columnNumber);
}

/**
Expand Down
16 changes: 8 additions & 8 deletions front_end/sources/SourceFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,17 @@ Sources.SourceFormatter.ScriptMapping = class {
* @param {!Workspace.UISourceCode} uiSourceCode
* @param {number} lineNumber
* @param {number} columnNumber
* @return {!Array<!SDK.DebuggerModel.Location>}
* @return {?SDK.DebuggerModel.Location}
*/
uiLocationToRawLocations(uiSourceCode, lineNumber, columnNumber) {
uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) {
var formatData = Sources.SourceFormatData._for(uiSourceCode);
if (!formatData)
return [];
return null;
var originalLocation = formatData.mapping.formattedToOriginal(lineNumber, columnNumber);
var scripts = this._scriptsForUISourceCode(formatData.originalSourceCode);
if (!scripts.length)
return [];
var location = scripts[0].debuggerModel.createRawLocation(scripts[0], originalLocation[0], originalLocation[1]);
return location ? [location] : [];
return null;
return scripts[0].debuggerModel.createRawLocation(scripts[0], originalLocation[0], originalLocation[1]);
}

/**
Expand Down Expand Up @@ -226,8 +225,9 @@ Sources.SourceFormatter.ScriptMapping = class {
}
}
if (uiSourceCode.contentType().isScript()) {
return Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSourceCode, 0, 0)
.map(location => location.script());
var rawLocation = Bindings.debuggerWorkspaceBinding.uiLocationToRawLocation(uiSourceCode, 0, 0);
if (rawLocation)
return [rawLocation.script()];
}
return [];
}
Expand Down
8 changes: 4 additions & 4 deletions front_end/sources/SourceMapNamesResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ Sources.SourceMapNamesResolver.resolveExpression = function(
*/
Sources.SourceMapNamesResolver._resolveExpression = function(
uiSourceCode, lineNumber, startColumnNumber, endColumnNumber) {
var rawLocations =
Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiSourceCode, lineNumber, startColumnNumber);
if (!rawLocations.length)
var rawLocation =
Bindings.debuggerWorkspaceBinding.uiLocationToRawLocation(uiSourceCode, lineNumber, startColumnNumber);
if (!rawLocation)
return Promise.resolve('');

var script = rawLocations[0].script();
var script = rawLocation.script();
if (!script)
return Promise.resolve('');
var sourceMap = Bindings.debuggerWorkspaceBinding.sourceMapForScript(script);
Expand Down
10 changes: 4 additions & 6 deletions front_end/sources/SourcesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,16 +645,14 @@ Sources.SourcesPanel = class extends UI.Panel {
if (!executionContext)
return;
// Always use 0 column.
var rawLocations =
Bindings.debuggerWorkspaceBinding.uiLocationToRawLocations(uiLocation.uiSourceCode, uiLocation.lineNumber, 0);
// TODO(kozyatinskiy): make it possible to continue to multiple locations (whichever is hit first).
var location = rawLocations.find(location => location.debuggerModel === executionContext.debuggerModel);
if (!location)
var rawLocation =
Bindings.debuggerWorkspaceBinding.uiLocationToRawLocation(uiLocation.uiSourceCode, uiLocation.lineNumber, 0);
if (!rawLocation || rawLocation.debuggerModel !== executionContext.debuggerModel)
return;
if (!this._prepareToResume())
return;

location.continueToLocation();
rawLocation.continueToLocation();
}

_toggleBreakpointsActive() {
Expand Down

0 comments on commit dff718f

Please sign in to comment.