Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return null;
}
/* istanbul ignore if: edge case too hard to test for */
if (start.line === null || start.column === null) {
return null;
}
/* istanbul ignore if: edge case too hard to test for */
if (end.line === null || end.column === null) {
return null;
}
if (start.line === end.line && start.column === end.column) {
end = sourceMap.originalPositionFor({
line: location.end.line,
column: location.end.column,
bias: SourceMapConsumer.LEAST_UPPER_BOUND,
});
end.column -= 1;
}
return {
source: start.source,
loc: {
start: {
line: start.line,
column: start.column,
},
end: {
line: end.line,
column: end.column,
},
skip: location.skip,
// generated location in the file when there were multiple generated
// locations. The current comparison fn in 0.7 does not appear to take
// generated location into account properly.
let match;
for (const pos of positions) {
if (!match || pos.line < match.line || pos.column < match.column) {
match = pos;
}
}
if (!match) {
match = map.generatedPositionFor({
source: originalSource.url,
line: location.line,
column: location.column == null ? 0 : location.column,
bias: SourceMapConsumer.LEAST_UPPER_BOUND
});
}
return {
sourceId: generatedSourceId,
line: match.line,
column: match.column
};
}
function pickBestSourceRange(configuration: Configuration, filename: string, source: string, consumer: ReturnType , start: SourcePosition, end: SourcePosition): MappedSourceRange | SourceRange {
let generated = { filename, start, end, source };
// Fun fact! The positions returned by the source map consumer use a 1-based
// index for lines, and a 0-based index for columns.
let startOrigin: NullableMappedPosition = consumer.originalPositionFor({ line: start.line, column: start.column - 1, bias: SourceMapConsumer.LEAST_UPPER_BOUND});
let endOrigin: NullableMappedPosition = consumer.originalPositionFor({ line: end.line, column: end.column - 1, bias: SourceMapConsumer.LEAST_UPPER_BOUND});
// If the start and end locations of the origins are in different files,
// we try different biases to see if we can get something that agrees.
if (startOrigin.source && startOrigin.source !== endOrigin.source) {
let startOrigin2: NullableMappedPosition = consumer.originalPositionFor({ line: start.line, column: start.column - 1, bias: SourceMapConsumer.GREATEST_LOWER_BOUND });
let endOrigin2: NullableMappedPosition = consumer.originalPositionFor({ line: end.line, column: end.column - 1, bias: SourceMapConsumer.GREATEST_LOWER_BOUND });
if (startOrigin2.source && startOrigin2.source === endOrigin.source) {
startOrigin = startOrigin2;
} else if (endOrigin2.source && startOrigin.source === endOrigin2.source) {
endOrigin = endOrigin2;
} else if (startOrigin2.source && endOrigin2.source && startOrigin2.source === endOrigin2.source) {
startOrigin = startOrigin2;
endOrigin = endOrigin2;
} else if (startOrigin.line !== null && startOrigin.column !== null) {
// pick the starting file's location and add a character.
endOrigin = { ...startOrigin, ...{ column: startOrigin.column + 1 } };
function pickBestSourceRange(configuration: Configuration, filename: string, source: string, consumer: ReturnType , start: SourcePosition, end: SourcePosition): MappedSourceRange | SourceRange {
let generated = { filename, start, end, source };
// Fun fact! The positions returned by the source map consumer use a 1-based
// index for lines, and a 0-based index for columns.
let startOrigin: NullableMappedPosition = consumer.originalPositionFor({ line: start.line, column: start.column - 1, bias: SourceMapConsumer.LEAST_UPPER_BOUND});
let endOrigin: NullableMappedPosition = consumer.originalPositionFor({ line: end.line, column: end.column - 1, bias: SourceMapConsumer.LEAST_UPPER_BOUND});
// If the start and end locations of the origins are in different files,
// we try different biases to see if we can get something that agrees.
if (startOrigin.source && startOrigin.source !== endOrigin.source) {
let startOrigin2: NullableMappedPosition = consumer.originalPositionFor({ line: start.line, column: start.column - 1, bias: SourceMapConsumer.GREATEST_LOWER_BOUND });
let endOrigin2: NullableMappedPosition = consumer.originalPositionFor({ line: end.line, column: end.column - 1, bias: SourceMapConsumer.GREATEST_LOWER_BOUND });
if (startOrigin2.source && startOrigin2.source === endOrigin.source) {
startOrigin = startOrigin2;
} else if (endOrigin2.source && startOrigin.source === endOrigin2.source) {
endOrigin = endOrigin2;
} else if (startOrigin2.source && endOrigin2.source && startOrigin2.source === endOrigin2.source) {
startOrigin = startOrigin2;
endOrigin = endOrigin2;
} else if (startOrigin.line !== null && startOrigin.column !== null) {
// pick the starting file's location and add a character.
endOrigin = { ...startOrigin, ...{ column: startOrigin.column + 1 } };
} else if (endOrigin.line !== null && endOrigin.column !== null && endOrigin.column > 0) {
function getOriginalPositionName(
map: SourceMapConsumer,
generatedPosition: SourceMapPosition,
): (string|null) {
const originalPosition = map.originalPositionFor(generatedPosition);
if (!originalPosition || !originalPosition.name) {
return null;
}
// Verify if it's the exact position.
const originalPositionTest = map.originalPositionFor({
line: generatedPosition.line,
column: generatedPosition.column,
bias: SourceMapConsumer.LEAST_UPPER_BOUND
});
if (
!originalPositionTest ||
originalPositionTest.column !== originalPosition.column ||
originalPositionTest.line !== originalPosition.line
) {
return null;
}
return originalPosition.name;
}
for (const metadata of set) {
if (!metadata.compiledPath) {
return;
}
const map = await sourceUtils.loadSourceMap(metadata);
if (!map) {
continue;
}
for (const b of params.breakpoints || []) {
const entry = map.generatedPositionFor({
source: metadata.sourceUrl,
line: b.line,
column: b.column || 1,
bias: SourceMapConsumer.LEAST_UPPER_BOUND,
});
if (entry.line === null) {
continue;
}
const { lineNumber, columnNumber } = uiToRawOffset(
{ lineNumber: entry.line || 1, columnNumber: entry.column ? entry.column + 1 : 1 },
kNodeScriptOffset,
);
const predicted: PredictedLocation = {
source: {
absolutePath,
lineNumber: b.line,
columnNumber: b.column || 1,
},
compiled: {