An IFileNode is the root of the AST (abstract syntax tree) produced for a file.
IFileNode
If the file includes other files, a single IFileNode is produced.
The shape of this node is
IFileNode IASNode <-- getChild(0) IASNode <-- getChild(1) ...
888990919293949596
@Override @Test public void testPackageQualified_ClassBody() { IFileNode node = compileAS("package foo.bar.baz {public class A{public function A(){}}}"); asBlockWalker.visitFile(node); assertOut("goog.provide('foo.bar.baz.A');\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n};"); }
979899100101102103104105
@Override @Test public void testPackageQualified_ClassBodyMethodContents() { IFileNode node = compileAS("package foo.bar.baz {public class A{public function A(){if (a){for (var i:Object in obj){doit();}}}}}"); asBlockWalker.visitFile(node); assertOut("goog.provide('foo.bar.baz.A');\n\n/**\n * @constructor\n */\nfoo.bar.baz.A = function() {\n\tvar self = this;\n\tif (a) {\n\t\tfor (var /** @type {Object} */ i in obj) {\n\t\t\tdoit();\n\t\t}\n\t}\n};"); }
3637383940414243444546
public class TestGoogFile extends ASTestBase { @Test public void testFile_plain() { IFileNode node = compileAS("input", true, "goog" + File.separator + "files"); asBlockWalker.visitFile(node); assertOut(getCodeFromFile("output", true, "goog" + File.separator + "files")); }
4647484950515253545556
} @Test public void testFile_getset() { IFileNode node = compileAS("get-set", true, "goog" + File.separator + "files"); asBlockWalker.visitFile(node); assertOut(getCodeFromFile("get-set_result", true, "goog" + File.separator + "files")); }
5657585960616263646566
} @Test public void testFile_callsuper() { IFileNode node = compileAS("call-super", true, "goog" + File.separator + "files"); asBlockWalker.visitFile(node); assertOut(getCodeFromFile("call-super_result", true, "goog" + File.separator + "files")); }
6667686970717273747576
} @Test public void testFile_qualifynewobject() { IFileNode node = compileAS("qualify-new-object", true, "goog" + File.separator + "files"); asBlockWalker.visitFile(node); assertOut(getCodeFromFile("qualify-new-object_result", true, "goog" + File.separator + "files")); }
7677787980818283848586
} @Test public void testFile_poc() { IFileNode node = compileAS("poc", true, "goog" + File.separator + "files"); asBlockWalker.visitFile(node); assertOut(getCodeFromFile("poc_result", true, "goog" + File.separator + "files")); }
363738394041424344
//-------------------------------------------------------------------------- @Test public void testPackage_Simple() { IFileNode node = compileAS("package{}"); asBlockWalker.visitFile(node); assertOut("package {\n}"); }
444546474849505152
} @Test public void testPackage_SimpleName() { IFileNode node = compileAS("package foo {}"); asBlockWalker.visitFile(node); assertOut("package foo {\n}"); }
525354555657585960
} @Test public void testPackage_Name() { IFileNode node = compileAS("package foo.bar.baz {}"); asBlockWalker.visitFile(node); assertOut("package foo.bar.baz {\n}"); }