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

Unified Diff: lib/src/dart_parser.dart

Issue 22962005: Merge pull request #581 from kevmoo/polymer (Closed) Base URL: https://github.com/dart-lang/web-ui.git@polymer
Patch Set: Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/src/css_emitters.dart ('k') | lib/src/emitters.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/dart_parser.dart
diff --git a/lib/src/dart_parser.dart b/lib/src/dart_parser.dart
index dfc55b4e1ee5e27fefb93a6506e880547cb1836e..58a84a69f921b1a87259368bcf0933242a0ac4f6 100644
--- a/lib/src/dart_parser.dart
+++ b/lib/src/dart_parser.dart
@@ -7,20 +7,16 @@
*/
library dart_parser;
-import 'dart:utf';
-import 'dart:math' as math;
import 'package:analyzer_experimental/src/generated/ast.dart';
import 'package:analyzer_experimental/src/generated/error.dart';
import 'package:analyzer_experimental/src/generated/parser.dart';
import 'package:analyzer_experimental/src/generated/scanner.dart';
import 'package:source_maps/span.dart' show SourceFile, SourceFileSegment, Location;
-import 'info.dart';
import 'messages.dart';
-import 'refactor.dart' show $CR, $LF;
-import 'utils.dart';
+import 'utils.dart' show escapeDartString;
/** Information extracted from a source Dart file. */
-class DartCodeInfo extends Hashable {
+class DartCodeInfo {
/** Library qualified identifier, if any. */
final String libraryName;
@@ -44,7 +40,7 @@ class DartCodeInfo extends Hashable {
this.sourceFile, [compilationUnit])
: this.code = code,
this.compilationUnit = compilationUnit == null
- ? parseCompilationUnit(code) : compilationUnit;
+ ? _parseCompilationUnit(code) : compilationUnit;
bool get isPart =>
compilationUnit.directives.any((d) => d is PartOfDirective);
@@ -89,12 +85,10 @@ SimpleStringLiteral createStringLiteral(String contents) {
/**
* Parse and extract top-level directives from [code].
*
- * Adds emitted error/warning messages to [messages], if [messages] is
- * supplied.
*/
-DartCodeInfo parseDartCode(String path, String code, Messages messages,
- [Location offset]) {
- var unit = parseCompilationUnit(code, path: path, messages: messages);
+// TODO(sigmund): log emitted error/warning messages
+DartCodeInfo parseDartCode(String path, String code, [Location offset]) {
+ var unit = _parseCompilationUnit(code);
// Extract some information from the compilation unit.
String libraryName, partName;
@@ -125,39 +119,12 @@ DartCodeInfo parseDartCode(String path, String code, Messages messages,
sourceFile, unit);
}
-CompilationUnit parseCompilationUnit(String code, {String path,
- Messages messages}) {
-
+CompilationUnit _parseCompilationUnit(String code) {
var errorListener = new _ErrorCollector();
var scanner = new StringScanner(null, code, errorListener);
var token = scanner.tokenize();
var parser = new Parser(null, errorListener);
- var unit = parser.parseCompilationUnit(token);
-
- if (path == null || messages == null) return unit;
-
- // TODO(jmesserly): removed this for now because the analyzer doesn't format
- // messages properly, so you end up with things like "Unexpected token '%s'".
- // This used to convert parser messages into our messages. Enable this
- // once analyzer is fixed.
- // TODO(sigmund): once we enable this, we need to fix compiler.dart to clear
- // out the output of the compiler if we see compilation errors.
- if (false) {
- var file = new SourceFile.text(path, code);
- for (var e in errorListener.errors) {
- var span = file.span(e.offset, e.offset + e.length);
-
- var severity = e.errorCode.errorSeverity;
- if (severity == ErrorSeverity.ERROR) {
- messages.error(e.message, span);
- } else {
- assert(severity == ErrorSeverity.WARNING);
- messages.warning(e.message, span);
- }
- }
- }
-
- return unit;
+ return parser.parseCompilationUnit(token);
}
class _ErrorCollector extends AnalysisErrorListener {
« no previous file with comments | « lib/src/css_emitters.dart ('k') | lib/src/emitters.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698