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

Side by Side Diff: lib/src/codegen/js_printer.dart

Issue 1230903002: fixes #6, refactor to use AnalysisError/Listener throughout dev_compiler (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « lib/src/checker/checker.dart ('k') | lib/src/dependency_graph.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library dev_compiler.src.codegen.js_printer; 5 library dev_compiler.src.codegen.js_printer;
6 6
7 import 'dart:io' show Directory, File; 7 import 'dart:io' show Directory, File;
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:path/path.dart' as path; 9 import 'package:path/path.dart' as path;
10 import 'package:source_maps/source_maps.dart' as srcmaps show Printer; 10 import 'package:source_maps/source_maps.dart' as srcmaps show Printer;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 if (name != null) { 77 if (name != null) {
78 // TODO(jmesserly): mark only uses the beginning of the span, but 78 // TODO(jmesserly): mark only uses the beginning of the span, but
79 // we're required to pass this as a valid span. 79 // we're required to pass this as a valid span.
80 var end = _location(node.end); 80 var end = _location(node.end);
81 printer.mark(new SourceMapSpan(loc, end, name, isIdentifier: true)); 81 printer.mark(new SourceMapSpan(loc, end, name, isIdentifier: true));
82 } else { 82 } else {
83 printer.mark(loc); 83 printer.mark(loc);
84 } 84 }
85 } 85 }
86 86
87 SourceLocation _location(int offset) => locationForOffset(unit, uri, offset); 87 SourceLocation _location(int offset) =>
88 locationForOffset(unit.lineInfo, uri, offset);
88 89
89 Uri _makeRelativeUri(Uri src) { 90 Uri _makeRelativeUri(Uri src) {
90 return new Uri(path: path.relative(src.path, from: outputDir)); 91 return new Uri(path: path.relative(src.path, from: outputDir));
91 } 92 }
92 93
93 void exitNode(JS.Node jsNode) { 94 void exitNode(JS.Node jsNode) {
94 AstNode node = jsNode.sourceInformation; 95 AstNode node = jsNode.sourceInformation;
95 if (node is CompilationUnit) { 96 if (node is CompilationUnit) {
96 unit = null; 97 unit = null;
97 uri = null; 98 uri = null;
98 return; 99 return;
99 } 100 }
100 if (unit == null || node == null || node.offset == -1) return; 101 if (unit == null || node == null || node.offset == -1) return;
101 102
102 // TODO(jmesserly): in many cases marking the end will be unnecessary. 103 // TODO(jmesserly): in many cases marking the end will be unnecessary.
103 printer.mark(_location(node.end)); 104 printer.mark(_location(node.end));
104 } 105 }
105 106
106 String _getIdentifier(AstNode node) { 107 String _getIdentifier(AstNode node) {
107 if (node is SimpleIdentifier) return node.name; 108 if (node is SimpleIdentifier) return node.name;
108 return null; 109 return null;
109 } 110 }
110 } 111 }
OLDNEW
« no previous file with comments | « lib/src/checker/checker.dart ('k') | lib/src/dependency_graph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698