| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// Source information strategy that concurrently builds sourcemaps for each of | 5 /// Source information strategy that concurrently builds sourcemaps for each of |
| 6 /// child strategies. | 6 /// child strategies. |
| 7 | 7 |
| 8 library dart2js.dual_source_information; | 8 library dart2js.dual_source_information; |
| 9 | 9 |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| 11 import '../elements/elements.dart'; | 11 import '../elements/elements.dart'; |
| 12 import '../elements/entities.dart'; |
| 12 import '../js/js_source_mapping.dart'; | 13 import '../js/js_source_mapping.dart'; |
| 13 import '../js/js.dart' as js; | 14 import '../js/js.dart' as js; |
| 14 import '../tree/nodes.dart'; | 15 import '../tree/nodes.dart'; |
| 15 import 'code_output.dart' show BufferedCodeOutput; | 16 import 'code_output.dart' show BufferedCodeOutput; |
| 16 import 'source_information.dart'; | 17 import 'source_information.dart'; |
| 17 | 18 |
| 18 class MultiSourceInformationStrategy | 19 class MultiSourceInformationStrategy |
| 19 implements JavaScriptSourceInformationStrategy { | 20 implements JavaScriptSourceInformationStrategy { |
| 20 final List<JavaScriptSourceInformationStrategy> strategies; | 21 final List<JavaScriptSourceInformationStrategy> strategies; |
| 21 | 22 |
| 22 const MultiSourceInformationStrategy(this.strategies); | 23 const MultiSourceInformationStrategy(this.strategies); |
| 23 | 24 |
| 24 @override | 25 @override |
| 25 SourceInformationBuilder createBuilderForContext(ResolvedAst resolvedAst) { | 26 SourceInformationBuilder createBuilderForContext(MemberEntity member) { |
| 26 return new MultiSourceInformationBuilder( | 27 return new MultiSourceInformationBuilder( |
| 27 strategies.map((s) => s.createBuilderForContext(resolvedAst)).toList()); | 28 strategies.map((s) => s.createBuilderForContext(member)).toList()); |
| 28 } | 29 } |
| 29 | 30 |
| 30 @override | 31 @override |
| 31 void onComplete() { | 32 void onComplete() { |
| 32 strategies.forEach((s) => s.onComplete()); | 33 strategies.forEach((s) => s.onComplete()); |
| 33 } | 34 } |
| 34 | 35 |
| 35 @override | 36 @override |
| 36 SourceInformation buildSourceMappedMarker() { | 37 SourceInformation buildSourceMappedMarker() { |
| 37 return new MultiSourceInformation( | 38 return new MultiSourceInformation( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 processors.forEach((p) => p.process(node, code)); | 74 processors.forEach((p) => p.process(node, code)); |
| 74 } | 75 } |
| 75 } | 76 } |
| 76 | 77 |
| 77 class MultiSourceInformationBuilder implements SourceInformationBuilder { | 78 class MultiSourceInformationBuilder implements SourceInformationBuilder { |
| 78 final List<SourceInformationBuilder> builders; | 79 final List<SourceInformationBuilder> builders; |
| 79 | 80 |
| 80 MultiSourceInformationBuilder(this.builders); | 81 MultiSourceInformationBuilder(this.builders); |
| 81 | 82 |
| 82 @override | 83 @override |
| 83 SourceInformationBuilder forContext(ResolvedAst resolvedAst) { | 84 SourceInformationBuilder forContext(MemberEntity member) { |
| 84 return new MultiSourceInformationBuilder( | 85 return new MultiSourceInformationBuilder( |
| 85 builders.map((b) => b.forContext(resolvedAst)).toList()); | 86 builders.map((b) => b.forContext(member)).toList()); |
| 86 } | 87 } |
| 87 | 88 |
| 88 @override | 89 @override |
| 89 SourceInformation buildSwitchCase(Node node) { | 90 SourceInformation buildSwitchCase(Node node) { |
| 90 return new MultiSourceInformation( | 91 return new MultiSourceInformation( |
| 91 builders.map((b) => b.buildSwitchCase(node)).toList()); | 92 builders.map((b) => b.buildSwitchCase(node)).toList()); |
| 92 } | 93 } |
| 93 | 94 |
| 94 @override | 95 @override |
| 95 SourceInformation buildSwitch(Node node) { | 96 SourceInformation buildSwitch(Node node) { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 builders.map((b) => b.buildCreate(node)).toList()); | 236 builders.map((b) => b.buildCreate(node)).toList()); |
| 236 } | 237 } |
| 237 | 238 |
| 238 @override | 239 @override |
| 239 SourceInformation buildGeneric(Node node) { | 240 SourceInformation buildGeneric(Node node) { |
| 240 return new MultiSourceInformation( | 241 return new MultiSourceInformation( |
| 241 builders.map((b) => b.buildGeneric(node)).toList()); | 242 builders.map((b) => b.buildGeneric(node)).toList()); |
| 242 } | 243 } |
| 243 | 244 |
| 244 @override | 245 @override |
| 245 SourceInformation buildDeclaration(ResolvedAst resolvedAst) { | 246 SourceInformation buildDeclaration(MemberEntity member) { |
| 246 return new MultiSourceInformation( | 247 return new MultiSourceInformation( |
| 247 builders.map((b) => b.buildDeclaration(resolvedAst)).toList()); | 248 builders.map((b) => b.buildDeclaration(member)).toList()); |
| 248 } | 249 } |
| 249 } | 250 } |
| 250 | 251 |
| 251 class MultiSourceInformation implements SourceInformation { | 252 class MultiSourceInformation implements SourceInformation { |
| 252 final List<SourceInformation> infos; | 253 final List<SourceInformation> infos; |
| 253 | 254 |
| 254 MultiSourceInformation(this.infos); | 255 MultiSourceInformation(this.infos); |
| 255 | 256 |
| 256 @override | 257 @override |
| 257 String get shortText => infos.first?.shortText; | 258 String get shortText => infos.first?.shortText; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 281 MultiSourceInformationReader(this.reader, this.index); | 282 MultiSourceInformationReader(this.reader, this.index); |
| 282 | 283 |
| 283 @override | 284 @override |
| 284 SourceInformation getSourceInformation(js.Node node) { | 285 SourceInformation getSourceInformation(js.Node node) { |
| 285 MultiSourceInformation sourceInformation = | 286 MultiSourceInformation sourceInformation = |
| 286 reader.getSourceInformation(node); | 287 reader.getSourceInformation(node); |
| 287 if (sourceInformation == null) return null; | 288 if (sourceInformation == null) return null; |
| 288 return sourceInformation.infos[index]; | 289 return sourceInformation.infos[index]; |
| 289 } | 290 } |
| 290 } | 291 } |
| OLD | NEW |