Chromium Code Reviews| 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 import 'package:analyzer/dart/ast/ast.dart'; | 5 import 'package:analyzer/dart/ast/ast.dart'; |
| 6 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 6 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 7 import 'package:source_maps/source_maps.dart' hide Printer; | 7 import 'package:source_maps/source_maps.dart' hide Printer; |
| 8 import 'package:source_span/source_span.dart' show SourceLocation; | 8 import 'package:source_span/source_span.dart' show SourceLocation; |
| 9 | 9 |
| 10 import '../js_ast/js_ast.dart' as JS; | 10 import '../js_ast/js_ast.dart' as JS; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 _currentTopLevelDeclaration == null; | 69 _currentTopLevelDeclaration == null; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 // TODO(jmesserly): prefix identifiers too, if they map to a named element. | 73 // TODO(jmesserly): prefix identifiers too, if they map to a named element. |
| 74 String _getIdentifier(AstNode node) => | 74 String _getIdentifier(AstNode node) => |
| 75 node is SimpleIdentifier ? node.name : null; | 75 node is SimpleIdentifier ? node.name : null; |
| 76 | 76 |
| 77 void _mark(int offset, [String identifier]) { | 77 void _mark(int offset, [String identifier]) { |
| 78 var loc = unit.lineInfo.getLocation(offset); | 78 var loc = unit.lineInfo.getLocation(offset); |
| 79 var next = unit.lineInfo.getLocation(offset + 1); | |
|
vsm
2017/04/11 18:39:51
Can you add a comment here to explain? This looks
Alan Knight
2017/04/11 20:32:06
Done.
| |
| 80 if (next.lineNumber == loc.lineNumber + 1) { | |
| 81 loc = next; | |
| 82 } | |
| 79 sourceMap.addLocation( | 83 sourceMap.addLocation( |
| 80 new SourceLocation(offset, | 84 new SourceLocation(offset, |
| 81 sourceUrl: sourcePath, | 85 sourceUrl: sourcePath, |
| 82 line: loc.lineNumber - 1, | 86 line: loc.lineNumber - 1, |
| 83 column: loc.columnNumber - 1), | 87 column: loc.columnNumber - 1), |
| 84 new SourceLocation(buffer.length, line: _line, column: _column), | 88 new SourceLocation(buffer.length, line: _line, column: _column), |
| 85 identifier); | 89 identifier); |
| 86 } | 90 } |
| 87 } | 91 } |
| 88 | 92 |
| 89 const int _LF = 10; | 93 const int _LF = 10; |
| 90 const int _CR = 13; | 94 const int _CR = 13; |
| OLD | NEW |