Index: tests/compiler/dart2js/sourcemaps/sourcemap_helper.dart |
diff --git a/tests/compiler/dart2js/sourcemaps/sourcemap_helper.dart b/tests/compiler/dart2js/sourcemaps/sourcemap_helper.dart |
index 3a5befd7dd3910f37d8afdd6739a79110cf1cdfb..fa8ea093443b49c50726d58d97a387b27e552cde 100644 |
--- a/tests/compiler/dart2js/sourcemaps/sourcemap_helper.dart |
+++ b/tests/compiler/dart2js/sourcemaps/sourcemap_helper.dart |
@@ -77,7 +77,7 @@ class CloningOutputProvider extends OutputProvider { |
RandomAccessFileOutputProvider outputProvider; |
CloningOutputProvider(Uri jsUri, Uri jsMapUri) |
- : outputProvider = new RandomAccessFileOutputProvider(jsUri, jsMapUri); |
+ : outputProvider = new RandomAccessFileOutputProvider(jsUri, jsMapUri); |
@override |
EventSink<String> createEventSink(String name, String extension) { |
@@ -114,14 +114,11 @@ class RecordingPrintingContext extends LenientPrintingContext { |
RecordingPrintingContext(this.listener); |
@override |
- void exitNode(js.Node node, |
- int startPosition, |
- int endPosition, |
- int closingPosition) { |
+ void exitNode( |
+ js.Node node, int startPosition, int endPosition, int closingPosition) { |
codePositions[node] = |
new CodePosition(startPosition, endPosition, closingPosition); |
- listener.onPositions( |
- node, startPosition, endPosition, closingPosition); |
+ listener.onPositions(node, startPosition, endPosition, closingPosition); |
} |
} |
@@ -148,17 +145,12 @@ class RecordingSourceInformationProcessor |
final CodePositionRecorder codePositions; |
final LocationMap nodeToSourceLocationsMap; |
- RecordingSourceInformationProcessor( |
- this.wrapper, |
- this.processor, |
- this.codePositions, |
- this.nodeToSourceLocationsMap); |
+ RecordingSourceInformationProcessor(this.wrapper, this.processor, |
+ this.codePositions, this.nodeToSourceLocationsMap); |
@override |
- void onPositions(js.Node node, |
- int startPosition, |
- int endPosition, |
- int closingPosition) { |
+ void onPositions( |
+ js.Node node, int startPosition, int endPosition, int closingPosition) { |
codePositions.registerPositions( |
node, startPosition, endPosition, closingPosition); |
processor.onPositions(node, startPosition, endPosition, closingPosition); |
@@ -180,13 +172,9 @@ class RecordedSourceInformationProcess { |
final LocationMap nodeToSourceLocationsMap; |
RecordedSourceInformationProcess( |
- this.root, |
- this.code, |
- this.codePositions, |
- this.nodeToSourceLocationsMap); |
+ this.root, this.code, this.codePositions, this.nodeToSourceLocationsMap); |
} |
- |
/// A wrapper of [JavaScriptSourceInformationStrategy] that records |
/// [RecordedSourceInformationProcess]. |
class RecordingSourceInformationStrategy |
@@ -206,20 +194,21 @@ class RecordingSourceInformationStrategy |
@override |
SourceInformationProcessor createProcessor(SourceMapper sourceMapper) { |
- LocationMap nodeToSourceLocationsMap = |
- new _LocationRecorder(); |
+ LocationMap nodeToSourceLocationsMap = new _LocationRecorder(); |
CodePositionRecorder codePositions = new CodePositionRecorder(); |
return new RecordingSourceInformationProcessor( |
this, |
- strategy.createProcessor(new RecordingSourceMapper( |
- sourceMapper, nodeToSourceLocationsMap)), |
- codePositions, nodeToSourceLocationsMap); |
+ strategy.createProcessor( |
+ new RecordingSourceMapper(sourceMapper, nodeToSourceLocationsMap)), |
+ codePositions, |
+ nodeToSourceLocationsMap); |
} |
- void registerProcess(js.Node root, |
- BufferedCodeOutput code, |
- CodePositionRecorder codePositions, |
- LocationMap nodeToSourceLocationsMap) { |
+ void registerProcess( |
+ js.Node root, |
+ BufferedCodeOutput code, |
+ CodePositionRecorder codePositions, |
+ LocationMap nodeToSourceLocationsMap) { |
RecordedSourceInformationProcess subProcess = |
new RecordedSourceInformationProcess( |
root, code.getText(), codePositions, nodeToSourceLocationsMap); |
@@ -302,11 +291,8 @@ class SourceMapProcessor { |
} |
/// Computes the [SourceMapInfo] for the compiled elements. |
- Future<SourceMaps> process( |
- List<String> options, |
- {bool verbose: true, |
- bool perElement: true, |
- bool forMain: false}) async { |
+ Future<SourceMaps> process(List<String> options, |
+ {bool verbose: true, bool perElement: true, bool forMain: false}) async { |
OutputProvider outputProvider = outputToFile |
? new CloningOutputProvider(targetUri, sourceMapFileUri) |
: new OutputProvider(); |
@@ -320,16 +306,16 @@ class SourceMapProcessor { |
outputProvider: outputProvider, |
// TODO(johnniwinther): Use [verbose] to avoid showing diagnostics. |
options: ['--out=$targetUri', '--source-map=$sourceMapFileUri'] |
- ..addAll(options)); |
+ ..addAll(options)); |
JavaScriptBackend backend = compiler.backend; |
var handler = compiler.handler; |
SourceFileProvider sourceFileProvider = handler.provider; |
- sourceFileManager = new ProviderSourceFileManager( |
- sourceFileProvider, |
- outputProvider); |
+ sourceFileManager = |
+ new ProviderSourceFileManager(sourceFileProvider, outputProvider); |
RecordingSourceInformationStrategy strategy = |
- new RecordingSourceInformationStrategy(backend.sourceInformationStrategy); |
+ new RecordingSourceInformationStrategy( |
+ backend.sourceInformationStrategy); |
backend.sourceInformationStrategy = strategy; |
await compiler.run(inputUri); |
@@ -354,12 +340,7 @@ class SourceMapProcessor { |
new JavaScriptTracer(codePositions, [visitor]).apply(node); |
List<CodePoint> codePoints = visitor.codePoints; |
elementSourceMapInfos[element] = new SourceMapInfo( |
- element, |
- code, |
- node, |
- codePoints, |
- codePositions, |
- nodeMap); |
+ element, code, node, codePoints, codePositions, nodeMap); |
}); |
} |
if (forMain) { |
@@ -377,17 +358,11 @@ class SourceMapProcessor { |
new JavaScriptTracer(codePositions, [visitor]).apply(node); |
List<CodePoint> codePoints = visitor.codePoints; |
mainSourceMapInfo = new SourceMapInfo( |
- null, code, node, |
- codePoints, |
- codePositions, |
- nodeMap); |
+ null, code, node, codePoints, codePositions, nodeMap); |
} |
return new SourceMaps( |
- compiler, |
- sourceFileManager, |
- mainSourceMapInfo, |
- elementSourceMapInfos); |
+ compiler, sourceFileManager, mainSourceMapInfo, elementSourceMapInfos); |
} |
} |
@@ -398,11 +373,8 @@ class SourceMaps { |
final SourceMapInfo mainSourceMapInfo; |
final Map<Element, SourceMapInfo> elementSourceMapInfos; |
- SourceMaps( |
- this.compiler, |
- this.sourceFileManager, |
- this.mainSourceMapInfo, |
- this.elementSourceMapInfos); |
+ SourceMaps(this.compiler, this.sourceFileManager, this.mainSourceMapInfo, |
+ this.elementSourceMapInfos); |
} |
/// Source mapping information for the JavaScript code of an [Element]. |
@@ -415,15 +387,10 @@ class SourceMapInfo { |
final CodePositionMap jsCodePositions; |
final LocationMap nodeMap; |
- SourceMapInfo( |
- Element element, |
- this.code, |
- this.node, |
- this.codePoints, |
- this.jsCodePositions, |
- this.nodeMap) |
+ SourceMapInfo(Element element, this.code, this.node, this.codePoints, |
+ this.jsCodePositions, this.nodeMap) |
: this.name = |
- element != null ? computeElementNameForSourceMaps(element) : '', |
+ element != null ? computeElementNameForSourceMaps(element) : '', |
this.element = element; |
String toString() { |
@@ -436,29 +403,28 @@ class SourceMapInfo { |
abstract class LocationMap { |
Iterable<js.Node> get nodes; |
- Map<int, List<SourceLocation>> operator[] (js.Node node); |
+ Map<int, List<SourceLocation>> operator [](js.Node node); |
factory LocationMap.recorder() = _LocationRecorder; |
factory LocationMap.filter(Set<js.Node> nodes, LocationMap map) = |
_FilteredLocationMap; |
- |
} |
-class _LocationRecorder |
- implements SourceMapper, LocationMap { |
+class _LocationRecorder implements SourceMapper, LocationMap { |
final Map<js.Node, Map<int, List<SourceLocation>>> _nodeMap = {}; |
@override |
void register(js.Node node, int codeOffset, SourceLocation sourceLocation) { |
- _nodeMap.putIfAbsent(node, () => {}) |
+ _nodeMap |
+ .putIfAbsent(node, () => {}) |
.putIfAbsent(codeOffset, () => []) |
.add(sourceLocation); |
} |
Iterable<js.Node> get nodes => _nodeMap.keys; |
- Map<int, List<SourceLocation>> operator[] (js.Node node) { |
+ Map<int, List<SourceLocation>> operator [](js.Node node) { |
return _nodeMap[node]; |
} |
} |
@@ -471,12 +437,11 @@ class _FilteredLocationMap implements LocationMap { |
Iterable<js.Node> get nodes => map.nodes.where((n) => _nodes.contains(n)); |
- Map<int, List<SourceLocation>> operator[] (js.Node node) { |
+ Map<int, List<SourceLocation>> operator [](js.Node node) { |
return map[node]; |
} |
} |
- |
/// Visitor that computes the [CodePoint]s for source mapping locations. |
class CodePointComputer extends TraceListener { |
final SourceFileManager sourceFileManager; |
@@ -511,15 +476,16 @@ class CodePointComputer extends TraceListener { |
} |
void register(StepKind kind, js.Node node, {bool expectInfo: true}) { |
- |
String dartCodeFromSourceLocation(SourceLocation sourceLocation) { |
SourceFile sourceFile = |
- sourceFileManager.getSourceFile(sourceLocation.sourceUri); |
+ sourceFileManager.getSourceFile(sourceLocation.sourceUri); |
if (sourceFile == null) { |
return sourceLocation.shortText; |
} |
- return sourceFile.getLineText(sourceLocation.line) |
- .substring(sourceLocation.column).trim(); |
+ return sourceFile |
+ .getLineText(sourceLocation.line) |
+ .substring(sourceLocation.column) |
+ .trim(); |
} |
void addLocation(SourceLocation sourceLocation, String jsCode) { |
@@ -532,12 +498,12 @@ class CodePointComputer extends TraceListener { |
sourceLocation = sourceInformation.sourceLocations.first; |
dartCode = dartCodeFromSourceLocation(sourceLocation); |
} |
- codePoints.add(new CodePoint( |
- kind, jsCode, sourceLocation, dartCode, isMissing: true)); |
+ codePoints.add(new CodePoint(kind, jsCode, sourceLocation, dartCode, |
+ isMissing: true)); |
} |
} else { |
- codePoints.add(new CodePoint(kind, jsCode, sourceLocation, |
- dartCodeFromSourceLocation(sourceLocation))); |
+ codePoints.add(new CodePoint(kind, jsCode, sourceLocation, |
+ dartCodeFromSourceLocation(sourceLocation))); |
} |
} |
@@ -563,16 +529,12 @@ class CodePoint { |
final String dartCode; |
final bool isMissing; |
- CodePoint( |
- this.kind, |
- this.jsCode, |
- this.sourceLocation, |
- this.dartCode, |
+ CodePoint(this.kind, this.jsCode, this.sourceLocation, this.dartCode, |
{this.isMissing: false}); |
String toString() { |
return 'CodePoint[kind=$kind,js=$jsCode,dart=$dartCode,' |
- 'location=$sourceLocation]'; |
+ 'location=$sourceLocation]'; |
} |
} |