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

Unified Diff: compiler/java/com/google/dart/compiler/DartCompiler.java

Issue 9958049: Add some command line options to debug AST parsing of illegal dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removed 'highlight unresolved', it didn't do much good Created 8 years, 9 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
Index: compiler/java/com/google/dart/compiler/DartCompiler.java
diff --git a/compiler/java/com/google/dart/compiler/DartCompiler.java b/compiler/java/com/google/dart/compiler/DartCompiler.java
index aff1a5359b1b90e32ecaad14d362ed50ddd4296f..8a89af73d9d9c6db96d5fa77372938f9f3ff13a1 100644
--- a/compiler/java/com/google/dart/compiler/DartCompiler.java
+++ b/compiler/java/com/google/dart/compiler/DartCompiler.java
@@ -16,6 +16,7 @@ import com.google.dart.compiler.UnitTestBatchRunner.Invocation;
import com.google.dart.compiler.ast.DartDirective;
import com.google.dart.compiler.ast.DartLibraryDirective;
import com.google.dart.compiler.ast.DartNode;
+import com.google.dart.compiler.ast.DartToSourceVisitor;
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.ast.LibraryNode;
import com.google.dart.compiler.ast.LibraryUnit;
@@ -41,6 +42,7 @@ import com.google.dart.compiler.resolver.ResolverErrorCode;
import com.google.dart.compiler.resolver.SupertypeResolver;
import com.google.dart.compiler.resolver.TopLevelElementBuilder;
import com.google.dart.compiler.type.TypeAnalyzer;
+import com.google.dart.compiler.util.DefaultTextOutput;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
@@ -1027,11 +1029,25 @@ public class DartCompiler {
try {
File outputDirectory = config.getOutputDirectory();
DefaultDartArtifactProvider provider = new DefaultDartArtifactProvider(outputDirectory);
- DefaultDartCompilerListener listener = new DefaultDartCompilerListener(
- config.printErrorFormat());
-
// Compile the Dart application and its dependencies.
- LibrarySource lib = new UrlLibrarySource(sourceFile);
+ final LibrarySource lib = new UrlLibrarySource(sourceFile);
+ DefaultDartCompilerListener listener;
+ if (config.getCompilerOptions().showSourceFromAst()) {
+ listener = new DefaultDartCompilerListener(config.printErrorFormat()) {
+ @Override
+ public void unitCompiled(DartUnit unit) {
+ if (unit.getLibrary() != null) {
+ if (unit.getLibrary().getSource() == lib) {
+ DefaultTextOutput output = new DefaultTextOutput(false);
+ unit.accept(new DartToSourceVisitor(output));
+ System.out.println(output.toString());
+ }
+ }
+ }
+ };
+ } else {
+ listener = new DefaultDartCompilerListener(config.printErrorFormat());
+ }
String errorString = compileLib(lib, config, provider, listener);
return errorString;
} finally {

Powered by Google App Engine
This is Rietveld 408576698