| 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 'package:kernel/ast.dart' show Location; | 7 import 'package:kernel/ast.dart' show Location; |
| 8 import '../common.dart'; | 8 import '../common.dart'; |
| 9 import '../elements/elements.dart' | 9 import '../elements/elements.dart' |
| 10 show | 10 show |
| 11 AstElement, | 11 AstElement, |
| 12 CompilationUnitElement, | 12 CompilationUnitElement, |
| 13 LocalElement, | 13 LocalElement, |
| 14 ResolvedAst, | 14 ResolvedAst, |
| 15 ResolvedAstKind; | 15 ResolvedAstKind; |
| 16 import '../elements/entities.dart'; |
| 16 import '../js/js.dart' show JavaScriptNodeSourceInformation; | 17 import '../js/js.dart' show JavaScriptNodeSourceInformation; |
| 17 import '../script.dart'; | 18 import '../script.dart'; |
| 18 import '../tree/tree.dart' show Node; | 19 import '../tree/tree.dart' show Node; |
| 19 import 'source_file.dart'; | 20 import 'source_file.dart'; |
| 20 | 21 |
| 21 /// Interface for passing source information, for instance for use in source | 22 /// Interface for passing source information, for instance for use in source |
| 22 /// maps, through the backend. | 23 /// maps, through the backend. |
| 23 abstract class SourceInformation extends JavaScriptNodeSourceInformation { | 24 abstract class SourceInformation extends JavaScriptNodeSourceInformation { |
| 24 const SourceInformation(); | 25 const SourceInformation(); |
| 25 | 26 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 38 List<SourceLocation> get sourceLocations; | 39 List<SourceLocation> get sourceLocations; |
| 39 | 40 |
| 40 /// Return a short textual representation of the source location. | 41 /// Return a short textual representation of the source location. |
| 41 String get shortText; | 42 String get shortText; |
| 42 } | 43 } |
| 43 | 44 |
| 44 /// Strategy for creating, processing and applying [SourceInformation]. | 45 /// Strategy for creating, processing and applying [SourceInformation]. |
| 45 class SourceInformationStrategy { | 46 class SourceInformationStrategy { |
| 46 const SourceInformationStrategy(); | 47 const SourceInformationStrategy(); |
| 47 | 48 |
| 48 /// Create a [SourceInformationBuilder] for [resolvedAst]. | 49 /// Create a [SourceInformationBuilder] for [member]. |
| 49 SourceInformationBuilder createBuilderForContext(ResolvedAst resolvedAst) { | 50 SourceInformationBuilder createBuilderForContext(MemberEntity member) { |
| 50 return const SourceInformationBuilder(); | 51 return const SourceInformationBuilder(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 /// Generate [SourceInformation] marker for non-preamble code. | 54 /// Generate [SourceInformation] marker for non-preamble code. |
| 54 SourceInformation buildSourceMappedMarker() => null; | 55 SourceInformation buildSourceMappedMarker() => null; |
| 55 | 56 |
| 56 /// Called when compilation has completed. | 57 /// Called when compilation has completed. |
| 57 void onComplete() {} | 58 void onComplete() {} |
| 58 } | 59 } |
| 59 | 60 |
| 60 /// Interface for generating [SourceInformation]. | 61 /// Interface for generating [SourceInformation]. |
| 61 class SourceInformationBuilder { | 62 class SourceInformationBuilder { |
| 62 const SourceInformationBuilder(); | 63 const SourceInformationBuilder(); |
| 63 | 64 |
| 64 /// Create a [SourceInformationBuilder] for [resolvedAst]. | 65 /// Create a [SourceInformationBuilder] for [member]. |
| 65 SourceInformationBuilder forContext(ResolvedAst resolvedAst) => this; | 66 SourceInformationBuilder forContext(MemberEntity member) => this; |
| 66 | 67 |
| 67 /// Generate [SourceInformation] the declaration of the element in | 68 /// Generate [SourceInformation] the declaration of the [member]. |
| 68 /// [resolvedAst]. | 69 SourceInformation buildDeclaration(MemberEntity member) => null; |
| 69 SourceInformation buildDeclaration(ResolvedAst resolvedAst) => null; | |
| 70 | 70 |
| 71 /// Generate [SourceInformation] for the generic [node]. | 71 /// Generate [SourceInformation] for the generic [node]. |
| 72 @deprecated | 72 @deprecated |
| 73 SourceInformation buildGeneric(Node node) => null; | 73 SourceInformation buildGeneric(Node node) => null; |
| 74 | 74 |
| 75 /// Generate [SourceInformation] for an instantiation of a class using [node] | 75 /// Generate [SourceInformation] for an instantiation of a class using [node] |
| 76 /// for the source position. | 76 /// for the source position. |
| 77 SourceInformation buildCreate(Node node) => null; | 77 SourceInformation buildCreate(Node node) => null; |
| 78 | 78 |
| 79 /// Generate [SourceInformation] for the return [node]. | 79 /// Generate [SourceInformation] for the return [node]. |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 @override | 316 @override |
| 317 int get line => null; | 317 int get line => null; |
| 318 | 318 |
| 319 @override | 319 @override |
| 320 int get offset => null; | 320 int get offset => null; |
| 321 | 321 |
| 322 String get shortName => '<no-location>'; | 322 String get shortName => '<no-location>'; |
| 323 | 323 |
| 324 String toString() => '<no-location>'; | 324 String toString() => '<no-location>'; |
| 325 } | 325 } |
| OLD | NEW |