| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart2js.source_information; | 5 library dart2js.source_information; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../elements/elements.dart' show | 8 import '../elements/elements.dart' show |
| 9 AstElement, | 9 AstElement, |
| 10 LocalElement; | 10 LocalElement; |
| 11 import '../tree/tree.dart' show | 11 import '../tree/tree.dart' show |
| 12 Node, | 12 Node, |
| 13 Send; | 13 Send; |
| 14 import '../js/js.dart' show | 14 import '../js/js.dart' show |
| 15 JavaScriptNodeSourceInformation; | 15 JavaScriptNodeSourceInformation; |
| 16 import 'source_file.dart'; | 16 import 'source_file.dart'; |
| 17 | 17 |
| 18 bool useNewSourceInfo = | 18 bool useNewSourceInfo = |
| 19 const bool.fromEnvironment('USE_NEW_SOURCE_INFO', defaultValue: false); | 19 const bool.fromEnvironment('USE_NEW_SOURCE_INFO', defaultValue: false); |
| 20 | 20 |
| 21 /// Interface for passing source information, for instance for use in source | 21 /// Interface for passing source information, for instance for use in source |
| 22 /// maps, through the backend. | 22 /// maps, through the backend. |
| 23 abstract class SourceInformation extends JavaScriptNodeSourceInformation { | 23 abstract class SourceInformation extends JavaScriptNodeSourceInformation { |
| 24 const SourceInformation(); |
| 25 |
| 24 SourceSpan get sourceSpan; | 26 SourceSpan get sourceSpan; |
| 25 | 27 |
| 26 /// The source location associated with the start of the JS node. | 28 /// The source location associated with the start of the JS node. |
| 27 SourceLocation get startPosition => null; | 29 SourceLocation get startPosition => null; |
| 28 | 30 |
| 29 /// The source location associated with the closing of the JS node. | 31 /// The source location associated with the closing of the JS node. |
| 30 SourceLocation get closingPosition => null; | 32 SourceLocation get closingPosition => null; |
| 31 | 33 |
| 32 /// The source location associated with the end of the JS node. | 34 /// The source location associated with the end of the JS node. |
| 33 SourceLocation get endPosition => null; | 35 SourceLocation get endPosition => null; |
| 34 | 36 |
| 35 /// All source locations associated with this source information. | 37 /// All source locations associated with this source information. |
| 36 List<SourceLocation> get sourceLocations; | 38 List<SourceLocation> get sourceLocations; |
| 37 | 39 |
| 38 /// Return a short textual representation of the source location. | 40 /// Return a short textual representation of the source location. |
| 39 String get shortText; | 41 String get shortText; |
| 40 } | 42 } |
| 41 | 43 |
| 42 /// Strategy for creating, processing and applying [SourceInformation]. | 44 /// Strategy for creating, processing and applying [SourceInformation]. |
| 43 class SourceInformationStrategy { | 45 class SourceInformationStrategy { |
| 44 const SourceInformationStrategy(); | 46 const SourceInformationStrategy(); |
| 45 | 47 |
| 46 /// Create a [SourceInformationBuilder] for [element]. | 48 /// Create a [SourceInformationBuilder] for [element]. |
| 47 SourceInformationBuilder createBuilderForContext(AstElement element) { | 49 SourceInformationBuilder createBuilderForContext(AstElement element) { |
| 48 return const SourceInformationBuilder(); | 50 return const SourceInformationBuilder(); |
| 49 } | 51 } |
| 52 |
| 53 /// Generate [SourceInformation] marker for non-preamble code. |
| 54 SourceInformation buildSourceMappedMarker() => null; |
| 55 |
| 56 /// Called when compilation has completed. |
| 57 void onComplete() {} |
| 50 } | 58 } |
| 51 | 59 |
| 52 /// Interface for generating [SourceInformation]. | 60 /// Interface for generating [SourceInformation]. |
| 53 class SourceInformationBuilder { | 61 class SourceInformationBuilder { |
| 54 const SourceInformationBuilder(); | 62 const SourceInformationBuilder(); |
| 55 | 63 |
| 56 /// Create a [SourceInformationBuilder] for [element]. | 64 /// Create a [SourceInformationBuilder] for [element]. |
| 57 SourceInformationBuilder forContext(AstElement element) => this; | 65 SourceInformationBuilder forContext(AstElement element) => this; |
| 58 | 66 |
| 59 /// Generate [SourceInformation] the declaration of [element]. | 67 /// Generate [SourceInformation] the declaration of [element]. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 return '${computeElementNameForSourceMaps(local.executableContext)}.$name'; | 198 return '${computeElementNameForSourceMaps(local.executableContext)}.$name'; |
| 191 } else if (element.enclosingClass != null) { | 199 } else if (element.enclosingClass != null) { |
| 192 if (element.enclosingClass.isClosure) { | 200 if (element.enclosingClass.isClosure) { |
| 193 return computeElementNameForSourceMaps(element.enclosingClass); | 201 return computeElementNameForSourceMaps(element.enclosingClass); |
| 194 } | 202 } |
| 195 return '${element.enclosingClass.name}.${element.name}'; | 203 return '${element.enclosingClass.name}.${element.name}'; |
| 196 } else { | 204 } else { |
| 197 return element.name; | 205 return element.name; |
| 198 } | 206 } |
| 199 } | 207 } |
| OLD | NEW |