| 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 /// Source information system mapping that attempts a semantic mapping between | 5 /// Source information system mapping that attempts a semantic mapping between |
| 6 /// offsets of JavaScript code points to offsets of Dart code points. | 6 /// offsets of JavaScript code points to offsets of Dart code points. |
| 7 | 7 |
| 8 library dart2js.source_information.position; | 8 library dart2js.source_information.position; |
| 9 | 9 |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| 11 import '../elements/elements.dart' show AstElement, FieldElement; | 11 import '../elements/elements.dart' show AstElement, FieldElement, ResolvedAst, R
esolvedAstKind; |
| 12 import '../js/js.dart' as js; | 12 import '../js/js.dart' as js; |
| 13 import '../js/js_debug.dart'; | 13 import '../js/js_debug.dart'; |
| 14 import '../js/js_source_mapping.dart'; | 14 import '../js/js_source_mapping.dart'; |
| 15 import '../tree/tree.dart' show FunctionExpression, Node, Send; | 15 import '../tree/tree.dart' show FunctionExpression, Node, Send; |
| 16 import 'code_output.dart' show CodeBuffer; | 16 import 'code_output.dart' show CodeBuffer; |
| 17 import 'source_file.dart'; | 17 import 'source_file.dart'; |
| 18 import 'source_information.dart'; | 18 import 'source_information.dart'; |
| 19 | 19 |
| 20 /// [SourceInformation] that consists of an offset position into the source | 20 /// [SourceInformation] that consists of an offset position into the source |
| 21 /// code. | 21 /// code. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 class PositionSourceInformationBuilder implements SourceInformationBuilder { | 140 class PositionSourceInformationBuilder implements SourceInformationBuilder { |
| 141 final SourceFile sourceFile; | 141 final SourceFile sourceFile; |
| 142 final String name; | 142 final String name; |
| 143 final AstElement element; | 143 final AstElement element; |
| 144 | 144 |
| 145 PositionSourceInformationBuilder(AstElement element) | 145 PositionSourceInformationBuilder(AstElement element) |
| 146 : this.element = element, | 146 : this.element = element, |
| 147 sourceFile = element.implementation.compilationUnit.script.file, | 147 sourceFile = element.implementation.compilationUnit.script.file, |
| 148 name = computeElementNameForSourceMaps(element); | 148 name = computeElementNameForSourceMaps(element); |
| 149 | 149 |
| 150 SourceInformation buildDeclaration(AstElement element) { | 150 SourceInformation buildDeclaration(ResolvedAst resolvedAst) { |
| 151 if (element.isSynthesized) { | 151 if (resolvedAst.kind != ResolvedAstKind.PARSED) { |
| 152 SourceSpan span = resolvedAst.element.sourcePosition; |
| 152 return new PositionSourceInformation(new OffsetSourceLocation( | 153 return new PositionSourceInformation(new OffsetSourceLocation( |
| 153 sourceFile, element.position.charOffset, name)); | 154 sourceFile, span.begin, name)); |
| 154 } else { | 155 } else { |
| 155 return new PositionSourceInformation( | 156 return new PositionSourceInformation( |
| 156 new OffsetSourceLocation(sourceFile, | 157 new OffsetSourceLocation(sourceFile, |
| 157 element.resolvedAst.node.getBeginToken().charOffset, name), | 158 resolvedAst.node.getBeginToken().charOffset, name), |
| 158 new OffsetSourceLocation(sourceFile, | 159 new OffsetSourceLocation(sourceFile, |
| 159 element.resolvedAst.node.getEndToken().charOffset, name)); | 160 resolvedAst.node.getEndToken().charOffset, name)); |
| 160 } | 161 } |
| 161 } | 162 } |
| 162 | 163 |
| 163 /// Builds a source information object pointing the start position of [node]. | 164 /// Builds a source information object pointing the start position of [node]. |
| 164 SourceInformation buildBegin(Node node) { | 165 SourceInformation buildBegin(Node node) { |
| 165 return new PositionSourceInformation(new OffsetSourceLocation( | 166 return new PositionSourceInformation(new OffsetSourceLocation( |
| 166 sourceFile, node.getBeginToken().charOffset, name)); | 167 sourceFile, node.getBeginToken().charOffset, name)); |
| 167 } | 168 } |
| 168 | 169 |
| 169 @override | 170 @override |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 | 1281 |
| 1281 @override | 1282 @override |
| 1282 CodePosition operator [](js.Node node) { | 1283 CodePosition operator [](js.Node node) { |
| 1283 CodePosition codePosition = codePositions[node]; | 1284 CodePosition codePosition = codePositions[node]; |
| 1284 if (codePosition == null) { | 1285 if (codePosition == null) { |
| 1285 coverage.registerNodesWithoutOffset(node); | 1286 coverage.registerNodesWithoutOffset(node); |
| 1286 } | 1287 } |
| 1287 return codePosition; | 1288 return codePosition; |
| 1288 } | 1289 } |
| 1289 } | 1290 } |
| OLD | NEW |