Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/source_map_printer.dart

Issue 2833633002: Various DDC fixes for windows (Closed)
Patch Set: Fix formatting Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 source.isInSystemLibrary ? source.uri.toString() : source.fullName; 59 source.isInSystemLibrary ? source.uri.toString() : source.fullName;
60 } 60 }
61 // 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
62 // declaration rather than the body and confuses devtools. 62 // declaration rather than the body and confuses devtools.
63 if (node is MethodDeclaration) return; 63 if (node is MethodDeclaration) return;
64 _mark(node.offset, _getIdentifier(node)); 64 _mark(node.offset, _getIdentifier(node));
65 } 65 }
66 66
67 void exitNode(JS.Node jsNode) { 67 void exitNode(JS.Node jsNode) {
68 AstNode node = jsNode.sourceInformation; 68 AstNode node = jsNode.sourceInformation;
69 if (unit == null || node == null || node.offset == -1) return; 69 if (unit == null || node == null || node.offset == -1 || node.isSynthetic) {
70 return;
71 }
70 72
71 // TODO(jmesserly): in many cases marking the end will be unnecessary. 73 // TODO(jmesserly): in many cases marking the end will be unnecessary.
72 // Skip MethodDeclarations - in the case of a one line function it finds the 74 // Skip MethodDeclarations - in the case of a one line function it finds the
73 // declaration rather than the body and confuses devtools. 75 // declaration rather than the body and confuses devtools.
74 if (node is! MethodDeclaration) { 76 if (node is! MethodDeclaration) {
75 _mark(node.end); 77 _mark(node.end);
76 } 78 }
77 79
78 if (identical(node, _currentTopLevelDeclaration)) { 80 if (identical(node, _currentTopLevelDeclaration)) {
79 unit = null; 81 unit = null;
80 sourcePath = null; 82 sourcePath = null;
81 _currentTopLevelDeclaration == null; 83 _currentTopLevelDeclaration == null;
82 } 84 }
83 } 85 }
84 86
85 // TODO(jmesserly): prefix identifiers too, if they map to a named element. 87 // TODO(jmesserly): prefix identifiers too, if they map to a named element.
86 String _getIdentifier(AstNode node) => 88 String _getIdentifier(AstNode node) =>
87 node is SimpleIdentifier ? node.name : null; 89 node is SimpleIdentifier ? node.name : null;
88 90
89 void _mark(int offset, [String identifier]) { 91 void _mark(int offset, [String identifier]) {
90 var loc = unit.lineInfo.getLocation(offset); 92 var loc = unit.lineInfo.getLocation(offset);
91 // Chrome Devtools wants a mapping for the beginning of 93 // Chrome Devtools wants a mapping for the beginning of
92 // a line, so bump locations at the end of a line to the beginning of 94 // a line, so bump locations at the end of a line to the beginning of
93 // the next line. 95 // the next line.
94 var next = unit.lineInfo.getLocation(offset + 1); 96 var next = unit.lineInfo.getLocation(offset + 1);
95 if (next.lineNumber == loc.lineNumber + 1) { 97 if (next.lineNumber == loc.lineNumber + 1) {
96 loc = next; 98 loc = next;
97 } 99 }
100 var sourceUrl =
101 sourcePath.startsWith('dart:') || sourcePath.startsWith('package:')
102 ? sourcePath
103 : new Uri.file(sourcePath);
98 sourceMap.addLocation( 104 sourceMap.addLocation(
99 new SourceLocation(offset, 105 new SourceLocation(offset,
100 sourceUrl: sourcePath, 106 sourceUrl: sourceUrl,
101 line: loc.lineNumber - 1, 107 line: loc.lineNumber - 1,
102 column: loc.columnNumber - 1), 108 column: loc.columnNumber - 1),
103 new SourceLocation(buffer.length, line: _line, column: _column), 109 new SourceLocation(buffer.length, line: _line, column: _column),
104 identifier); 110 identifier);
105 } 111 }
106 } 112 }
107 113
108 const int _LF = 10; 114 const int _LF = 10;
109 const int _CR = 13; 115 const int _CR = 13;
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/src/compiler/compiler.dart ('k') | pkg/dev_compiler/test/codegen_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698