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

Unified Diff: compiler/java/com/google/dart/compiler/ast/viz/TextWriter.java

Issue 8566019: Added support for dumping AST to console, text file or dot file (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | « compiler/java/com/google/dart/compiler/ast/viz/DotWriter.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/ast/viz/TextWriter.java
===================================================================
--- compiler/java/com/google/dart/compiler/ast/viz/TextWriter.java (revision 0)
+++ compiler/java/com/google/dart/compiler/ast/viz/TextWriter.java (revision 0)
@@ -0,0 +1,49 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.google.dart.compiler.ast.viz;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import com.google.common.io.Closeables;
+import com.google.dart.compiler.ast.DartUnit;
+
+/**
+ * Write the AST in Text format. Output file is placed next to the JS file in the output directory
+ */
+public class TextWriter extends ConsoleWriter {
+
+ public TextWriter(String outputDir) {
+ super(outputDir);
+ }
+
+ @Override
+ protected void startHook(DartUnit unit) {
+ if (!isIgnored(unit)) {
+ String txtFilePath = outputDir + File.separator + unit.getSource().getUri()
+ + ".ast.txt";
+ makeParentDirs(txtFilePath);
+ try {
+ //Set output to text file
+ out = new FileWriter(new File(txtFilePath));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ protected void endHook(DartUnit unit) {
+ if (!isIgnored(unit)) {
+ try {
+ Closeables.close(out, true);
+ } catch (IOException e) {
+ System.err.println("Error closing AST output file");
+ e.printStackTrace();
+ }
+ }
+ }
+}
« no previous file with comments | « compiler/java/com/google/dart/compiler/ast/viz/DotWriter.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698