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

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
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,39 @@
+// 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.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
+ public Object visitUnit(DartUnit node) {
+ if(!isIgnored(node)){
+ String txtFilePath = outputDir + File.separator
+ + currentUnit.getSource().getUri() + ".ast.txt";
+ makeParentDirs(txtFilePath);
+ try {
+ //Set output to text file
+ out = new FileWriter(new File(txtFilePath));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ visitChildren(node);
+ }
+ return null;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698