зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1129784 - Implement column sliding for source mapped sources;r=jlong
This commit is contained in:
Родитель
9e32948b63
Коммит
8769806b40
|
@ -21,7 +21,7 @@ function test() {
|
|||
|
||||
const BP_LOCATION = {
|
||||
line: 5,
|
||||
column: 11
|
||||
// column: 0
|
||||
};
|
||||
|
||||
function findSource() {
|
||||
|
|
|
@ -439,7 +439,7 @@ GeneratedLocation.prototype = {
|
|||
|
||||
equals: function (other) {
|
||||
return this.generatedSourceActor.url == other.generatedSourceActor.url &&
|
||||
this.generatedLine === other.originalLine;
|
||||
this.generatedLine === other.generatedLine;
|
||||
},
|
||||
|
||||
toJSON: function () {
|
||||
|
|
|
@ -2605,44 +2605,22 @@ SourceActor.prototype = {
|
|||
return DevToolsUtils.yieldingEach(mappings._array, m => {
|
||||
let mapping = {
|
||||
generated: {
|
||||
line: m.generatedLine,
|
||||
column: m.generatedColumn
|
||||
line: m.originalLine,
|
||||
column: m.originalColumn
|
||||
}
|
||||
};
|
||||
if (m.source) {
|
||||
mapping.source = m.source;
|
||||
mapping.original = {
|
||||
line: m.originalLine,
|
||||
column: m.originalColumn
|
||||
line: m.generatedLine,
|
||||
column: m.generatedColumn
|
||||
};
|
||||
mapping.name = m.name;
|
||||
}
|
||||
generator.addMapping(mapping);
|
||||
}).then(() => {
|
||||
generator.setSourceContent(this.url, code);
|
||||
const consumer = SourceMapConsumer.fromSourceMap(generator);
|
||||
|
||||
// XXX bug 918802: Monkey punch the source map consumer, because iterating
|
||||
// over all mappings and inverting each of them, and then creating a new
|
||||
// SourceMapConsumer is slow.
|
||||
|
||||
const getOrigPos = consumer.originalPositionFor.bind(consumer);
|
||||
const getGenPos = consumer.generatedPositionFor.bind(consumer);
|
||||
|
||||
consumer.originalPositionFor = ({ line, column }) => {
|
||||
const location = getGenPos({
|
||||
line: line,
|
||||
column: column,
|
||||
source: this.url
|
||||
});
|
||||
location.source = this.url;
|
||||
return location;
|
||||
};
|
||||
|
||||
consumer.generatedPositionFor = ({ line, column }) => getOrigPos({
|
||||
line: line,
|
||||
column: column
|
||||
});
|
||||
let consumer = SourceMapConsumer.fromSourceMap(generator);
|
||||
|
||||
return {
|
||||
code: code,
|
||||
|
@ -2896,40 +2874,63 @@ SourceActor.prototype = {
|
|||
return originalLocation;
|
||||
}
|
||||
} else {
|
||||
if (originalColumn === undefined) {
|
||||
let loop = (actualLocation) => {
|
||||
let {
|
||||
originalLine: actualLine,
|
||||
originalColumn: actualColumn
|
||||
} = actualLocation;
|
||||
let slideByColumn = (actualColumn) => {
|
||||
return this.sources.getAllGeneratedLocations(new OriginalLocation(
|
||||
this,
|
||||
originalLine,
|
||||
actualColumn
|
||||
)).then((generatedLocations) => {
|
||||
// Because getAllGeneratedLocations will always return the list of
|
||||
// generated locations for the closest column that is greater than
|
||||
// the one we are searching for if no exact match can be found, if
|
||||
// the list of generated locations is empty, we've reached the end
|
||||
// of the original line, and sliding continues by line.
|
||||
if (generatedLocations.length === 0) {
|
||||
return slideByLine(originalLine + 1);
|
||||
}
|
||||
|
||||
return this.threadActor.sources.getAllGeneratedLocations(actualLocation)
|
||||
.then((generatedLocations) => {
|
||||
// Because getAllGeneratedLocations will always return the list of
|
||||
// generated locations for the closest line that is greater than
|
||||
// the one we are searching for if no exact match can be found, if
|
||||
// the list of generated locations is empty, we've reached the end
|
||||
// of the original source, and breakpoint sliding failed.
|
||||
if (generatedLocations.length === 0) {
|
||||
return originalLocation;
|
||||
}
|
||||
// If at least one script has an offset that matches one of the
|
||||
// generated locations in the list, then breakpoint sliding
|
||||
// succeeded.
|
||||
if (this._setBreakpointAtAllGeneratedLocations(actor, generatedLocations)) {
|
||||
return this.threadActor.sources.getOriginalLocation(generatedLocations[0]);
|
||||
}
|
||||
|
||||
// If at least one script has an offset that matches one of the
|
||||
// generated locations in the list, then breakpoint sliding
|
||||
// succeeded.
|
||||
if (this._setBreakpointAtAllGeneratedLocations(actor, generatedLocations)) {
|
||||
return this.threadActor.sources.getOriginalLocation(generatedLocations[0]);
|
||||
}
|
||||
// Try the next column in the original source.
|
||||
return slideByColumn(actualColumn + 1);
|
||||
});
|
||||
};
|
||||
|
||||
// Try the next line in the original source.
|
||||
return loop(new OriginalLocation(this, actualLine + 1));
|
||||
});
|
||||
};
|
||||
let slideByLine = (actualLine) => {
|
||||
return this.sources.getAllGeneratedLocations(new OriginalLocation(
|
||||
this,
|
||||
actualLine
|
||||
)).then((generatedLocations) => {
|
||||
// Because getAllGeneratedLocations will always return the list of
|
||||
// generated locations for the closest line that is greater than
|
||||
// the one we are searching for if no exact match can be found, if
|
||||
// the list of generated locations is empty, we've reached the end
|
||||
// of the original source, and breakpoint sliding failed.
|
||||
if (generatedLocations.length === 0) {
|
||||
return originalLocation;
|
||||
}
|
||||
|
||||
return loop(new OriginalLocation(this, originalLine + 1));
|
||||
// If at least one script has an offset that matches one of the
|
||||
// generated locations in the list, then breakpoint sliding
|
||||
// succeeded.
|
||||
if (this._setBreakpointAtAllGeneratedLocations(actor, generatedLocations)) {
|
||||
return this.threadActor.sources.getOriginalLocation(generatedLocations[0]);
|
||||
}
|
||||
|
||||
// Try the next line in the original source.
|
||||
return slideByLine(actualLine + 1);
|
||||
});
|
||||
};
|
||||
|
||||
if (originalColumn !== undefined) {
|
||||
return slideByColumn(originalColumn + 1);
|
||||
} else {
|
||||
// TODO: Implement breakpoint sliding for column breakpoints
|
||||
return originalLocation;
|
||||
return slideByLine(originalLine + 1);
|
||||
}
|
||||
}
|
||||
}).then((actualLocation) => {
|
||||
|
@ -3040,8 +3041,6 @@ SourceActor.prototype = {
|
|||
return lineNumber === generatedLine;
|
||||
});
|
||||
for (let { columnNumber: column, offset } of columnToOffsetMap) {
|
||||
// TODO: What we are actually interested in here is a range of
|
||||
// columns, rather than a single one.
|
||||
if (column >= generatedColumn && column <= generatedLastColumn) {
|
||||
entryPoints.push({ script, offsets: [offset] });
|
||||
}
|
||||
|
|
|
@ -597,40 +597,29 @@ TabSources.prototype = {
|
|||
originalColumn
|
||||
} = originalLocation;
|
||||
|
||||
if (originalColumn === undefined) {
|
||||
let source = originalSourceActor.source ||
|
||||
originalSourceActor.generatedSource;
|
||||
let source = originalSourceActor.source ||
|
||||
originalSourceActor.generatedSource;
|
||||
|
||||
return this.fetchSourceMap(source).then((map) => {
|
||||
if (map) {
|
||||
map.computeColumnSpans();
|
||||
return this.fetchSourceMap(source).then((map) => {
|
||||
if (map) {
|
||||
map.computeColumnSpans();
|
||||
|
||||
return map.allGeneratedPositionsFor({
|
||||
source: originalSourceActor.url,
|
||||
line: originalLine
|
||||
}).map(({ line, column, lastColumn }) => {
|
||||
return new GeneratedLocation(
|
||||
this.createNonSourceMappedActor(source),
|
||||
line,
|
||||
column,
|
||||
lastColumn
|
||||
);
|
||||
});
|
||||
}
|
||||
return map.allGeneratedPositionsFor({
|
||||
source: originalSourceActor.url,
|
||||
line: originalLine,
|
||||
column: originalColumn
|
||||
}).map(({ line, column, lastColumn }) => {
|
||||
return new GeneratedLocation(
|
||||
this.createNonSourceMappedActor(source),
|
||||
line,
|
||||
column,
|
||||
lastColumn
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return [GeneratedLocation.fromOriginalLocation(originalLocation)];
|
||||
});
|
||||
} else {
|
||||
// TODO: Some source maps have multiple mappings for the same column
|
||||
return this.getGeneratedLocation(originalLocation)
|
||||
.then((generatedLocation) => {
|
||||
if (generatedLocation.generatedLine === null &&
|
||||
generatedLocation.generatedColumn === null) {
|
||||
return [];
|
||||
}
|
||||
return [generatedLocation];
|
||||
});
|
||||
}
|
||||
return [GeneratedLocation.fromOriginalLocation(originalLocation)];
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче