| 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 that maps spans of Dart AST nodes to spans of | 5 /// Source information system that maps spans of Dart AST nodes to spans of |
| 6 /// JavaScript nodes. | 6 /// JavaScript nodes. |
| 7 | 7 |
| 8 library dart2js.source_information.start_end; | 8 library dart2js.source_information.start_end; |
| 9 | 9 |
| 10 import 'package:front_end/src/fasta/scanner.dart' show Token; | 10 import 'package:front_end/src/fasta/scanner.dart' show Token; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 endSourcePosition = new OffsetSourceLocation(sourceFile, end, name); | 84 endSourcePosition = new OffsetSourceLocation(sourceFile, end, name); |
| 85 } | 85 } |
| 86 return new StartEndSourceInformation(sourcePosition, endSourcePosition); | 86 return new StartEndSourceInformation(sourcePosition, endSourcePosition); |
| 87 } | 87 } |
| 88 | 88 |
| 89 /// Create a textual representation of the source information using [uriText] | 89 /// Create a textual representation of the source information using [uriText] |
| 90 /// as the Uri representation. | 90 /// as the Uri representation. |
| 91 String _computeText(String uriText) { | 91 String _computeText(String uriText) { |
| 92 StringBuffer sb = new StringBuffer(); | 92 StringBuffer sb = new StringBuffer(); |
| 93 sb.write('$uriText:'); | 93 sb.write('$uriText:'); |
| 94 // Use 1-based line/startPosition info to match usual dart tool output. | 94 sb.write('[${startPosition.line},${startPosition.column}]'); |
| 95 sb.write('[${startPosition.line + 1},${startPosition.column + 1}]'); | |
| 96 if (endPosition != null) { | 95 if (endPosition != null) { |
| 97 sb.write('-[${endPosition.line + 1},${endPosition.column + 1}]'); | 96 sb.write('-[${endPosition.line},${endPosition.column}]'); |
| 98 } | 97 } |
| 99 return sb.toString(); | 98 return sb.toString(); |
| 100 } | 99 } |
| 101 | 100 |
| 102 String get shortText { | 101 String get shortText { |
| 103 return _computeText(startPosition.sourceUri.pathSegments.last); | 102 return _computeText(startPosition.sourceUri.pathSegments.last); |
| 104 } | 103 } |
| 105 | 104 |
| 106 String toString() { | 105 String toString() { |
| 107 return _computeText('${startPosition.sourceUri}'); | 106 return _computeText('${startPosition.sourceUri}'); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 251 |
| 253 @override | 252 @override |
| 254 SourceInformation buildIf(Node node) => buildGeneric(node); | 253 SourceInformation buildIf(Node node) => buildGeneric(node); |
| 255 | 254 |
| 256 @override | 255 @override |
| 257 SourceInformationBuilder forContext(ResolvedAst resolvedAst, | 256 SourceInformationBuilder forContext(ResolvedAst resolvedAst, |
| 258 {SourceInformation sourceInformation}) { | 257 {SourceInformation sourceInformation}) { |
| 259 return new StartEndSourceInformationBuilder(resolvedAst); | 258 return new StartEndSourceInformationBuilder(resolvedAst); |
| 260 } | 259 } |
| 261 } | 260 } |
| OLD | NEW |