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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 | 42 |
| 43 void enterNode(JS.Node jsNode) { | 43 void enterNode(JS.Node jsNode) { |
| 44 AstNode node = jsNode.sourceInformation; | 44 AstNode node = jsNode.sourceInformation; |
| 45 if (node == null || node.offset == -1 || node.isSynthetic) return; | 45 if (node == null || node.offset == -1 || node.isSynthetic) return; |
| 46 if (unit == null) { | 46 if (unit == null) { |
| 47 // This is a top-level declaration. Note: consecutive top-level | 47 // This is a top-level declaration. Note: consecutive top-level |
| 48 // declarations may come from different compilation units due to | 48 // declarations may come from different compilation units due to |
| 49 // parts. | 49 // parts. |
| 50 _currentTopLevelDeclaration = node; | 50 _currentTopLevelDeclaration = node; |
| 51 unit = node.getAncestor((n) => n is CompilationUnit); | 51 unit = node.getAncestor((n) => n is CompilationUnit); |
| 52 var source = resolutionMap.elementDeclaredByCompilationUnit(unit).source; | |
| 53 // Use the uri for dart: uris instead of the path of the source file | |
| 54 // on disk as that results in much cleaner stack traces. | |
| 55 // Example: | |
| 56 // source.uri = dart:core/object.dart | |
| 57 // source.fullName = gen/patched_sdk/lib/core/object.dart | |
| 52 sourcePath = | 58 sourcePath = |
| 53 resolutionMap.elementDeclaredByCompilationUnit(unit).source.fullName; | 59 source.isInSystemLibrary ? source.uri.toString() : source.fullName; |
| 54 } | 60 } |
|
Jacob
2017/04/15 02:26:49
Jenny please review this change. This switches to
Jennifer Messerly
2017/04/17 21:37:05
Nice!!!
| |
| 55 // Skip MethodDeclarations - in the case of a one line function it finds the | 61 // Skip MethodDeclarations - in the case of a one line function it finds the |
| 56 // declaration rather than the body and confuses devtools. | 62 // declaration rather than the body and confuses devtools. |
| 57 if (node is MethodDeclaration) return; | 63 if (node is MethodDeclaration) return; |
| 58 _mark(node.offset, _getIdentifier(node)); | 64 _mark(node.offset, _getIdentifier(node)); |
| 59 } | 65 } |
| 60 | 66 |
| 61 void exitNode(JS.Node jsNode) { | 67 void exitNode(JS.Node jsNode) { |
| 62 AstNode node = jsNode.sourceInformation; | 68 AstNode node = jsNode.sourceInformation; |
| 63 if (unit == null || node == null || node.offset == -1) return; | 69 if (unit == null || node == null || node.offset == -1) return; |
| 64 | 70 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 94 sourceUrl: sourcePath, | 100 sourceUrl: sourcePath, |
| 95 line: loc.lineNumber - 1, | 101 line: loc.lineNumber - 1, |
| 96 column: loc.columnNumber - 1), | 102 column: loc.columnNumber - 1), |
| 97 new SourceLocation(buffer.length, line: _line, column: _column), | 103 new SourceLocation(buffer.length, line: _line, column: _column), |
| 98 identifier); | 104 identifier); |
| 99 } | 105 } |
| 100 } | 106 } |
| 101 | 107 |
| 102 const int _LF = 10; | 108 const int _LF = 10; |
| 103 const int _CR = 13; | 109 const int _CR = 13; |
| OLD | NEW |