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

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

Issue 2551023005: Prepare for decoupling analyzer ASTs from element model. (Closed)
Patch Set: Created 4 years 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/resolution_accessors.dart';
6 import 'package:source_maps/source_maps.dart' hide Printer; 7 import 'package:source_maps/source_maps.dart' hide Printer;
7 import 'package:source_span/source_span.dart' show SourceLocation; 8 import 'package:source_span/source_span.dart' show SourceLocation;
8 9
9 import '../js_ast/js_ast.dart' as JS; 10 import '../js_ast/js_ast.dart' as JS;
10 11
11 class SourceMapPrintingContext extends JS.SimpleJavaScriptPrintingContext { 12 class SourceMapPrintingContext extends JS.SimpleJavaScriptPrintingContext {
12 /// Current line in the buffer; 13 /// Current line in the buffer;
13 int _line = 0; 14 int _line = 0;
14 15
15 /// Current column in the buffer. 16 /// Current column in the buffer.
(...skipping 25 matching lines...) Expand all
41 42
42 void enterNode(JS.Node jsNode) { 43 void enterNode(JS.Node jsNode) {
43 AstNode node = jsNode.sourceInformation; 44 AstNode node = jsNode.sourceInformation;
44 if (node == null || node.offset == -1) return; 45 if (node == null || node.offset == -1) return;
45 if (unit == null) { 46 if (unit == null) {
46 // This is a top-level declaration. Note: consecutive top-level 47 // This is a top-level declaration. Note: consecutive top-level
47 // declarations may come from different compilation units due to 48 // declarations may come from different compilation units due to
48 // parts. 49 // parts.
49 _currentTopLevelDeclaration = node; 50 _currentTopLevelDeclaration = node;
50 unit = node.getAncestor((n) => n is CompilationUnit); 51 unit = node.getAncestor((n) => n is CompilationUnit);
51 sourcePath = unit.element.source.fullName; 52 sourcePath = elementForCompilationUnit(unit).source.fullName;
52 } 53 }
53 54
54 _mark(node.offset, _getIdentifier(node)); 55 _mark(node.offset, _getIdentifier(node));
55 } 56 }
56 57
57 void exitNode(JS.Node jsNode) { 58 void exitNode(JS.Node jsNode) {
58 AstNode node = jsNode.sourceInformation; 59 AstNode node = jsNode.sourceInformation;
59 if (unit == null || node == null || node.offset == -1) return; 60 if (unit == null || node == null || node.offset == -1) return;
60 61
61 // TODO(jmesserly): in many cases marking the end will be unnecessary. 62 // TODO(jmesserly): in many cases marking the end will be unnecessary.
(...skipping 17 matching lines...) Expand all
79 sourceUrl: sourcePath, 80 sourceUrl: sourcePath,
80 line: loc.lineNumber - 1, 81 line: loc.lineNumber - 1,
81 column: loc.columnNumber - 1), 82 column: loc.columnNumber - 1),
82 new SourceLocation(buffer.length, line: _line, column: _column), 83 new SourceLocation(buffer.length, line: _line, column: _column),
83 identifier); 84 identifier);
84 } 85 }
85 } 86 }
86 87
87 const int _LF = 10; 88 const int _LF = 10;
88 const int _CR = 13; 89 const int _CR = 13;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698