You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cd...@apache.org on 2016/04/13 20:56:11 UTC
[19/51] [partial] git commit: [flex-falcon]
[refs/heads/feature/maven-migration-test] - - Check-In of the migrated
project to make error analysis easier
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/MXMLTestBase.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/MXMLTestBase.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/MXMLTestBase.java
new file mode 100644
index 0000000..eee073c
--- /dev/null
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/MXMLTestBase.java
@@ -0,0 +1,141 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.flex.compiler.internal.test;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.driver.mxml.MXMLBackend;
+import org.apache.flex.compiler.internal.mxml.MXMLNamespaceMapping;
+import org.apache.flex.compiler.mxml.IMXMLNamespaceMapping;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLNode;
+import org.apache.flex.utils.ITestAdapter;
+import org.apache.flex.utils.TestAdapterFactory;
+import org.junit.Ignore;
+
+@Ignore
+public class MXMLTestBase extends TestBase
+{
+
+ protected ITestAdapter testAdapter;
+
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+
+ testAdapter = TestAdapterFactory.getTestAdapter();
+
+ asEmitter = backend.createEmitter(writer);
+ mxmlEmitter = backend.createMXMLEmitter(writer);
+
+ asBlockWalker = backend.createWalker(project, errors, asEmitter);
+ mxmlBlockWalker = backend.createMXMLWalker(project, errors,
+ mxmlEmitter, asEmitter, asBlockWalker);
+ }
+
+ @Override
+ protected void addLibraries(List<File> libraries)
+ {
+ libraries.addAll(testAdapter.getLibraries(true));
+
+ super.addLibraries(libraries);
+ }
+
+ @Override
+ protected void addNamespaceMappings(
+ List<IMXMLNamespaceMapping> namespaceMappings)
+ {
+ namespaceMappings.add(new MXMLNamespaceMapping(
+ "http://ns.adobe.com/mxml/2009",
+ testAdapter.getFlexManifestPath("mxml-2009")));
+ namespaceMappings.add(new MXMLNamespaceMapping(
+ "library://ns.adobe.com/flex/mx",
+ testAdapter.getFlexManifestPath("mx")));
+ namespaceMappings.add(new MXMLNamespaceMapping(
+ "library://ns.adobe.com/flex/spark",
+ testAdapter.getFlexManifestPath("spark")));
+
+ super.addNamespaceMappings(namespaceMappings);
+ }
+
+ @Override
+ protected IBackend createBackend()
+ {
+ return new MXMLBackend();
+ }
+
+ //--------------------------------------------------------------------------
+ // Node "factory"
+ //--------------------------------------------------------------------------
+
+ public static final int WRAP_LEVEL_DOCUMENT = 1;
+ public static final int WRAP_LEVEL_NODE = 2;
+
+ protected IMXMLNode getNode(String code, Class<? extends IMXMLNode> type,
+ int wrapLevel)
+ {
+ if (wrapLevel >= WRAP_LEVEL_NODE)
+ code = "<s:Button " + code + "></s:Button>";
+
+ if (wrapLevel >= WRAP_LEVEL_DOCUMENT)
+ code = ""
+ + "<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\""
+ + " xmlns:s=\"library://ns.adobe.com/flex/spark\""
+ + " xmlns:mx=\"library://ns.adobe.com/flex/mx\">" + code
+ + "</s:Application>";
+
+ IMXMLFileNode node = compileMXML(code);
+
+ if (wrapLevel >= WRAP_LEVEL_NODE) // for now: attributes
+ {
+ IMXMLNode pnode = findFirstDescendantOfType(node, type);
+
+ IMXMLNode cnode = findFirstDescendantOfType(pnode, type);
+
+ return cnode;
+ }
+ else
+ {
+ return findFirstDescendantOfType(node, type);
+ }
+ }
+
+ protected IMXMLNode findFirstDescendantOfType(IMXMLNode node,
+ Class<? extends IMXMLNode> nodeType)
+ {
+
+ int n = node.getChildCount();
+ for (int i = 0; i < n; i++)
+ {
+ IMXMLNode child = (IMXMLNode) node.getChild(i);
+ if (nodeType.isInstance(child))
+ return child;
+
+ IMXMLNode found = findFirstDescendantOfType(child,
+ nodeType);
+ if (found != null)
+ return found;
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/SourceMapTestBase.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/SourceMapTestBase.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/SourceMapTestBase.java
new file mode 100644
index 0000000..ac58f1c
--- /dev/null
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/SourceMapTestBase.java
@@ -0,0 +1,55 @@
+package org.apache.flex.compiler.internal.test;
+
+import java.util.List;
+
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.tree.as.IASNode;
+
+import com.google.debugging.sourcemap.FilePosition;
+import static org.junit.Assert.assertTrue;
+
+public class SourceMapTestBase extends ASTestBase
+{
+ protected IJSEmitter jsEmitter;
+
+ @Override
+ public void setUp()
+ {
+ super.setUp();
+
+ jsEmitter = (IJSEmitter) asEmitter;
+ }
+
+ protected void assertMapping(IASNode node, int nodeStartLine, int nodeStartColumn,
+ int outStartLine, int outStartColumn, int outEndLine, int outEndColumn)
+ {
+ int sourceStartLine = nodeStartLine + node.getLine();
+ int sourceStartColumn = nodeStartColumn;
+ if (nodeStartLine == 0)
+ {
+ sourceStartColumn += node.getColumn();
+ }
+ boolean foundMapping = false;
+ List<IJSEmitter.SourceMapMapping> mappings = jsEmitter.getSourceMapMappings();
+ for (IJSEmitter.SourceMapMapping mapping : mappings)
+ {
+ FilePosition sourcePosition = mapping.sourceStartPosition;
+ FilePosition startPosition = mapping.destStartPosition;
+ FilePosition endPosition = mapping.destEndPosition;
+ if (sourcePosition.getLine() == sourceStartLine
+ && sourcePosition.getColumn() == sourceStartColumn
+ && startPosition.getLine() == outStartLine
+ && startPosition.getColumn() == outStartColumn
+ && endPosition.getLine() == outEndLine
+ && endPosition.getColumn() == outEndColumn)
+ {
+ foundMapping = true;
+ break;
+ }
+ }
+ assertTrue("Mapping not found for node " + node.getNodeID() + ". Expected "
+ + "source: (" + nodeStartLine + ", " + nodeStartColumn + "), dest: (" + outStartLine + ", " + outStartColumn + ") to (" + outEndLine + ", " + outEndColumn + ")",
+ foundMapping);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
new file mode 100644
index 0000000..64a73f7
--- /dev/null
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/TestBase.java
@@ -0,0 +1,678 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.compiler.internal.test;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.constants.IASLanguageConstants;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.as.ASFilterWriter;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.projects.FlexProject;
+import org.apache.flex.compiler.internal.projects.FlexProjectConfigurator;
+import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.internal.tree.as.FunctionNode;
+import org.apache.flex.compiler.internal.tree.as.ImportNode;
+import org.apache.flex.compiler.internal.workspaces.Workspace;
+import org.apache.flex.compiler.mxml.IMXMLNamespaceMapping;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.utils.EnvProperties;
+import org.apache.flex.compiler.visitor.as.IASBlockWalker;
+import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
+import org.apache.flex.utils.FilenameNormalization;
+import org.apache.flex.utils.ITestAdapter;
+import org.apache.flex.utils.TestAdapterFactory;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+@Ignore
+public class TestBase implements ITestBase
+{
+ private static ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter();
+
+ protected List<ICompilerProblem> errors;
+
+ protected static EnvProperties env = EnvProperties.initiate();
+
+ protected static Workspace workspace = new Workspace();
+ protected FlexProject project;
+
+ protected IBackend backend;
+ protected ASFilterWriter writer;
+
+ protected IASEmitter asEmitter;
+ protected IMXMLEmitter mxmlEmitter;
+
+ protected IASBlockWalker asBlockWalker;
+ protected IMXMLBlockWalker mxmlBlockWalker;
+
+ protected String inputFileExtension;
+
+ protected String mCode;
+
+ protected File tempDir;
+
+ private List<File> sourcePaths = new ArrayList<File>();
+ private List<File> libraries = new ArrayList<File>();
+ private List<IMXMLNamespaceMapping> namespaceMappings = new ArrayList<IMXMLNamespaceMapping>();
+
+ @Before
+ public void setUp()
+ {
+ assertNotNull("Environment variable FLEX_HOME is not set", env.SDK);
+ assertNotNull("Environment variable PLAYERGLOBAL_HOME is not set",
+ env.FPSDK);
+
+ errors = new ArrayList<ICompilerProblem>();
+
+ if (project == null)
+ {
+ project = new FlexProject(workspace);
+ project.setProxyBaseClass("flash.utils.Proxy");
+ }
+ project.setProblems(errors);
+ FlexProjectConfigurator.configure(project);
+
+ backend = createBackend();
+ writer = backend.createWriterBuffer(project);
+
+ try
+ {
+ ISourceFileHandler sfh = backend.getSourceFileHandlerInstance();
+ inputFileExtension = "." + sfh.getExtensions()[0];
+ }
+ catch (Exception e)
+ {
+ inputFileExtension = ".as";
+ }
+
+ sourcePaths = new ArrayList<File>();
+ libraries = new ArrayList<File>();
+ namespaceMappings = new ArrayList<IMXMLNamespaceMapping>();
+
+ tempDir = new File(TestAdapterFactory.getTestAdapter().getTempDir()); // ensure this exists
+ }
+
+ @After
+ public void tearDown()
+ {
+ backend = null;
+ writer = null;
+ }
+
+ protected IBackend createBackend()
+ {
+ return null;
+ }
+
+ protected void assertOut(String code, boolean keepMetadata)
+ {
+ mCode = removeGeneratedString(writer.toString());
+ if (!keepMetadata)
+ mCode = removeMetadata(mCode);
+ //System.out.println(mCode);
+ assertThat(mCode, is(code));
+ }
+
+ protected void assertOut(String code)
+ {
+ assertOut(code, false);
+ }
+
+ protected void assertOutWithMetadata(String code)
+ {
+ assertOut(code, true);
+ }
+
+ protected String removeMetadata(String code)
+ {
+ int c = code.indexOf("\n\n\n/**\n * Metadata");
+ if (c != -1)
+ return code.substring(0, c);
+ return code;
+ }
+
+ protected String removeGeneratedString(String code)
+ {
+ int c = code.indexOf(" * Generated by Apache Flex Cross-Compiler");
+ if (c != -1)
+ {
+ int c2 = code.indexOf("\n", c);
+ String newString = code.substring(0, c);
+ newString += code.substring(c2 + 1);
+ return newString;
+ }
+ return code;
+ }
+
+ @Override
+ public String toString()
+ {
+ return writer.toString();
+ }
+
+ protected IFileNode compileAS(String input)
+ {
+ return compileAS(input, false, "");
+ }
+
+ protected IFileNode compileAS(String input, boolean isFileName,
+ String inputDir)
+ {
+ return compileAS(input, isFileName, inputDir, true);
+ }
+
+ protected IFileNode compileAS(String input, boolean isFileName,
+ String inputDir, boolean useTempFile)
+ {
+ return (IFileNode) compile(input, isFileName, inputDir, useTempFile);
+ }
+
+ protected IASNode compile(String input, boolean isFileName,
+ String inputDir, boolean useTempFile)
+ {
+ File tempFile = (useTempFile) ? writeCodeToTempFile(input, isFileName, inputDir) :
+ new File(inputDir + File.separator + input + inputFileExtension);
+
+ addDependencies();
+
+ String normalizedMainFileName = FilenameNormalization
+ .normalize(tempFile.getAbsolutePath());
+
+ Collection<ICompilationUnit> mainFileCompilationUnits = workspace
+ .getCompilationUnits(normalizedMainFileName, project);
+
+ ICompilationUnit cu = null;
+ for (ICompilationUnit cu2 : mainFileCompilationUnits)
+ {
+ if (cu2 != null)
+ cu = cu2;
+ }
+
+ IASNode fileNode = null;
+ try
+ {
+ fileNode = cu.getSyntaxTreeRequest().get().getAST();
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+
+ return fileNode;
+ }
+
+ protected List<String> compileProject(String inputFileName,
+ String inputDirName)
+ {
+ return compileProject(inputFileName, inputDirName, new StringBuilder(), true);
+ }
+
+ protected List<String> compileProject(String inputFileName,
+ String inputDirName, StringBuilder sb, boolean ignoreErrors)
+ {
+ List<String> compiledFileNames = new ArrayList<String>();
+
+ String mainFileName = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
+ inputDirName + "/" + inputFileName + inputFileExtension).getPath();
+
+ addDependencies();
+
+ ICompilationUnit mainCU = Iterables
+ .getOnlyElement(workspace.getCompilationUnits(
+ FilenameNormalization.normalize(mainFileName), project));
+
+ if (project instanceof FlexJSProject)
+ ((FlexJSProject) project).mainCU = mainCU;
+
+ Configurator projectConfigurator = backend.createConfigurator();
+
+ JSTarget target = (JSTarget) backend.createTarget(project,
+ projectConfigurator.getTargetSettings(null), null);
+
+ ArrayList<ICompilerProblem> errors = new ArrayList<ICompilerProblem>();
+ target.build(mainCU, errors);
+
+ if (!ignoreErrors && errors.size() > 0)
+ {
+ for (ICompilerProblem error : errors)
+ {
+ String fn = error.getSourcePath();
+ if(fn != null) {
+ int c = fn.indexOf(testAdapter.getUnitTestBaseDir().getPath());
+ fn = fn.substring(c);
+ sb.append(fn);
+ sb.append("(" + error.getLine() + ":" + error.getColumn() + ")\n");
+ sb.append(error.toString() + "\n");
+ }
+ }
+ System.out.println(sb.toString());
+ return compiledFileNames;
+ }
+ List<ICompilationUnit> reachableCompilationUnits = project
+ .getReachableCompilationUnitsInSWFOrder(ImmutableSet.of(mainCU));
+ for (final ICompilationUnit cu : reachableCompilationUnits)
+ {
+ try
+ {
+ ICompilationUnit.UnitType cuType = cu.getCompilationUnitType();
+
+ if (cuType == ICompilationUnit.UnitType.AS_UNIT
+ || cuType == ICompilationUnit.UnitType.MXML_UNIT)
+ {
+ File outputRootDir = new File(
+ FilenameNormalization.normalize(tempDir
+ + File.separator + inputDirName));
+
+ String qname = cu.getQualifiedNames().get(0);
+
+ compiledFileNames.add(qname.replace(".", "/"));
+
+ final File outputClassFile = getOutputClassFile(qname
+ + "_output", outputRootDir);
+
+ ASFilterWriter writer = backend.createWriterBuffer(project);
+ IASEmitter emitter = backend.createEmitter(writer);
+ IASBlockWalker walker = backend.createWalker(project,
+ errors, emitter);
+
+ walker.visitCompilationUnit(cu);
+
+ //System.out.println(writer.toString());
+
+ BufferedOutputStream out = new BufferedOutputStream(
+ new FileOutputStream(outputClassFile));
+
+ out.write(emitter.postProcess(writer.toString()).getBytes());
+ out.flush();
+ out.close();
+ }
+ }
+ catch (Exception e)
+ {
+ //System.out.println(e.getMessage());
+ }
+ }
+
+ File outputRootDir = new File(
+ FilenameNormalization.normalize(tempDir
+ + File.separator + inputDirName));
+ String qname;
+ try {
+ qname = mainCU.getQualifiedNames().get(0);
+ final File outputClassFile = getOutputClassFile(qname
+ + "_output", outputRootDir);
+ appendLanguageAndXML(outputClassFile.getAbsolutePath(), qname);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return compiledFileNames;
+ }
+
+ protected void writeFile(String path, String content, boolean append)
+ throws IOException
+ {
+ File tgtFile = new File(path);
+
+ if (!tgtFile.exists())
+ tgtFile.createNewFile();
+
+ FileWriter fw = new FileWriter(tgtFile, append);
+ fw.write(content);
+ fw.close();
+ }
+
+ private void appendLanguageAndXML(String path, String projectName) throws IOException
+ {
+ StringBuilder appendString = new StringBuilder();
+ appendString.append(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+ appendString.append(ASEmitterTokens.PAREN_OPEN.getToken());
+ appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+ appendString.append(JSFlexJSEmitterTokens.LANGUAGE_QNAME.getToken());
+ appendString.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+ appendString.append(ASEmitterTokens.PAREN_CLOSE.getToken());
+ appendString.append(ASEmitterTokens.SEMICOLON.getToken());
+ appendString.append("\n");
+
+ String fileData = readCode(new File(path));
+ int reqidx = fileData.indexOf(appendString.toString());
+ if (reqidx == -1 && project instanceof FlexJSProject && ((FlexJSProject)project).needLanguage)
+ {
+ boolean afterProvide = false;
+ reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+ if (reqidx == -1)
+ {
+ afterProvide = true;
+ reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
+ }
+ reqidx = fileData.indexOf(";", reqidx);
+ String after = fileData.substring(reqidx + 1);
+ String before = fileData.substring(0, reqidx + 1);
+ if (afterProvide)
+ before += "\n";
+ String s = before + "\n" + appendString.toString() + after;
+ writeFile(path, s, false);
+ }
+
+ StringBuilder appendStringXML = new StringBuilder();
+ appendStringXML.append(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+ appendStringXML.append(ASEmitterTokens.PAREN_OPEN.getToken());
+ appendStringXML.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+ appendStringXML.append(IASLanguageConstants.XML);
+ appendStringXML.append(ASEmitterTokens.SINGLE_QUOTE.getToken());
+ appendStringXML.append(ASEmitterTokens.PAREN_CLOSE.getToken());
+ appendStringXML.append(ASEmitterTokens.SEMICOLON.getToken());
+ appendStringXML.append("\n");
+
+ if (project instanceof FlexJSProject && ((FlexJSProject)project).needXML)
+ {
+ fileData = readCode(new File(path));
+ reqidx = fileData.indexOf(appendStringXML.toString());
+ if (reqidx == -1)
+ {
+ boolean afterProvide = false;
+ reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+ if (reqidx == -1)
+ {
+ afterProvide = true;
+ reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
+ }
+ reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+ if (reqidx == -1)
+ reqidx = fileData.lastIndexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
+ reqidx = fileData.indexOf(";", reqidx);
+ String after = fileData.substring(reqidx + 1);
+ String before = fileData.substring(0, reqidx + 1);
+ if (afterProvide)
+ before += "\n";
+ String s = before + "\n" + appendStringXML.toString() + after;
+ writeFile(path, s, false);
+ }
+ }
+ }
+
+ protected String readCode(File file)
+ {
+ String code = "";
+ try
+ {
+ BufferedReader in = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file), "UTF8"));
+
+ String line = in.readLine();
+
+ while (line != null)
+ {
+ code += line + "\n";
+ line = in.readLine();
+ }
+ code = code.substring(0, code.length() - 1);
+
+ in.close();
+ }
+ catch (Exception e)
+ {
+ // nothing to see, move along...
+ }
+
+ return code;
+ }
+
+ protected File getOutputClassFile(String qname, File outputFolder)
+ {
+ String[] cname = qname.split("\\.");
+ String sdirPath = outputFolder + File.separator;
+ if (cname.length > 0)
+ {
+ for (int i = 0, n = cname.length - 1; i < n; i++)
+ {
+ sdirPath += cname[i] + File.separator;
+ }
+
+ File sdir = new File(sdirPath);
+ if (!sdir.exists())
+ sdir.mkdirs();
+
+ qname = cname[cname.length - 1];
+ }
+
+ return new File(sdirPath + qname + "." + backend.getOutputExtension());
+ }
+
+ protected IMXMLFileNode compileMXML(String input)
+ {
+ return compileMXML(input, false, "");
+ }
+
+ protected IMXMLFileNode compileMXML(String input, boolean isFileName,
+ String inputDir)
+ {
+ return compileMXML(input, isFileName, inputDir, true);
+ }
+
+ protected IMXMLFileNode compileMXML(String input, boolean isFileName,
+ String inputDir, boolean useTempFile)
+ {
+ return (IMXMLFileNode) compile(input, isFileName, inputDir, useTempFile);
+ }
+
+ protected File writeCodeToTempFile(String input, boolean isFileName,
+ String inputDir)
+ {
+ File tempASFile = null;
+ try
+ {
+ String tempFileName = (isFileName) ? input : getClass()
+ .getSimpleName();
+
+ tempASFile = File.createTempFile(tempFileName, inputFileExtension,
+ new File(TestAdapterFactory.getTestAdapter().getTempDir()));
+ tempASFile.deleteOnExit();
+
+ String code = "";
+ if (!isFileName)
+ {
+ code = input;
+ }
+ else
+ {
+ code = getCodeFromFile(input, false, inputDir);
+ }
+
+ BufferedWriter out = new BufferedWriter(new FileWriter(tempASFile));
+ out.write(code);
+ out.close();
+ }
+ catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
+
+ return tempASFile;
+ }
+
+ protected void writeResultToFile(String result, String fileName)
+ {
+ BufferedWriter writer = null;
+ try
+ {
+ writer = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(new File(tempDir, fileName + ".js")),
+ "utf-8"));
+ writer.write(result);
+ }
+ catch (IOException e1)
+ {
+ e1.printStackTrace();
+ }
+ finally
+ {
+ try
+ {
+ writer.close();
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+ }
+
+ /**
+ * Overridable setup of dependencies, default adds source, libraries and
+ * namepsaces.
+ * <p>
+ * The test will then set the dependencies on the current
+ * {@link ICompilerProject}.
+ */
+ protected void addDependencies()
+ {
+ addSourcePaths(sourcePaths);
+ addLibraries(libraries);
+ addNamespaceMappings(namespaceMappings);
+
+ project.setSourcePath(sourcePaths);
+ project.setLibraries(libraries);
+ project.setNamespaceMappings(namespaceMappings);
+ }
+
+ protected void addLibraries(List<File> libraries)
+ {
+ }
+
+ protected void addSourcePaths(List<File> sourcePaths)
+ {
+ sourcePaths.add(tempDir);
+ }
+
+ protected void addNamespaceMappings(
+ List<IMXMLNamespaceMapping> namespaceMappings)
+ {
+ }
+
+ protected String getCodeFromFile(String fileName, boolean isJS,
+ String sourceDir)
+ {
+ File testFile = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
+ sourceDir + "/" + fileName
+ + (isJS ? ".js" : inputFileExtension));
+
+ return readCodeFile(testFile);
+ }
+
+ protected String readCodeFile(File file)
+ {
+ boolean isResult = file.getName().contains("_result") || file.getName().equals("output.js");
+ String code = "";
+ try
+ {
+ BufferedReader in = new BufferedReader(new InputStreamReader(
+ new FileInputStream(file), "UTF8"));
+
+ String line = in.readLine();
+ if (line.contains("/**") && isResult)
+ {
+ // eat opening comment which should be apache header
+ while (line != null)
+ {
+ line = in.readLine();
+ if (line.contains("*/"))
+ {
+ line = in.readLine();
+ break;
+ }
+ }
+ }
+ while (line != null)
+ {
+ code += line + "\n";
+ line = in.readLine();
+ }
+ code = code.substring(0, code.length() - 1);
+ code = removeGeneratedString(code);
+
+ in.close();
+ }
+ catch (Exception e)
+ {
+ }
+ return code;
+ }
+
+ protected IASNode findFirstDescendantOfType(IASNode node,
+ Class<? extends IASNode> nodeType)
+ {
+ int n = node.getChildCount();
+ for (int i = 0; i < n; i++)
+ {
+ IASNode child = node.getChild(i);
+ if (child instanceof ImportNode)
+ continue; // not interested in these and they have BinaryOps inside
+ if (child instanceof FunctionNode)
+ {
+ ((FunctionNode) child).parseFunctionBody(errors);
+ }
+ if (nodeType.isInstance(child))
+ return child;
+
+ IASNode found = findFirstDescendantOfType(child, nodeType);
+ if (found != null)
+ return found;
+ }
+
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSMXMLTestBase.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSMXMLTestBase.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSMXMLTestBase.java
new file mode 100644
index 0000000..a421d5e
--- /dev/null
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSMXMLTestBase.java
@@ -0,0 +1,219 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.flex.compiler.internal.test;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.as.ASFilterWriter;
+import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.utils.FilenameNormalization;
+import org.apache.flex.utils.TestAdapterFactory;
+import org.junit.Ignore;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+@Ignore
+public class VF2JSMXMLTestBase extends MXMLTestBase
+{
+
+ @Override
+ public void setUp()
+ {
+ project = new FlexJSProject(workspace);
+
+ super.setUp();
+ }
+
+ @Override
+ protected IBackend createBackend()
+ {
+ return new MXMLVF2JSBackend();
+ }
+
+
+ @Override
+ protected List<String> compileProject(String inputFileName,
+ String inputDirName)
+ {
+ List<String> compiledFileNames = new ArrayList<String>();
+
+ String mainFileName = new File(TestAdapterFactory.getTestAdapter().getUnitTestBaseDir(),
+ inputDirName + "/" + inputFileName + inputFileExtension).getPath();
+
+ addDependencies();
+
+ String normalizedFileName = FilenameNormalization.normalize(
+ mainFileName);
+ Collection<ICompilationUnit> compilationUnits =
+ workspace.getCompilationUnits(normalizedFileName, project);
+ ICompilationUnit mainCU = Iterables.getOnlyElement(
+ compilationUnits);
+
+ if (project instanceof FlexJSProject)
+ ((FlexJSProject) project).mainCU = mainCU;
+
+ Configurator projectConfigurator = backend.createConfigurator();
+
+ JSTarget target = (JSTarget) backend.createTarget(project,
+ projectConfigurator.getTargetSettings(null), null);
+
+ target.build(mainCU, new ArrayList<ICompilerProblem>());
+
+ List<ICompilationUnit> reachableCompilationUnits = project
+ .getReachableCompilationUnitsInSWFOrder(ImmutableSet.of(mainCU));
+ for (final ICompilationUnit cu : reachableCompilationUnits)
+ {
+ ICompilationUnit.UnitType cuType = cu.getCompilationUnitType();
+
+ if (cuType == ICompilationUnit.UnitType.AS_UNIT
+ || cuType == ICompilationUnit.UnitType.MXML_UNIT)
+ {
+ File outputRootDir = new File(
+ FilenameNormalization.normalize(tempDir
+ + File.separator + inputDirName));
+
+ String qname = "";
+ try
+ {
+ qname = cu.getQualifiedNames().get(0);
+ }
+ catch (InterruptedException error)
+ {
+ System.out.println(error);
+ }
+
+ compiledFileNames.add(qname.replace(".", "/"));
+
+ final File outputClassFile = getOutputClassFile(qname
+ + "_output", outputRootDir);
+
+ ASFilterWriter outputWriter = backend.createWriterBuffer(project);
+
+ if (cuType == ICompilationUnit.UnitType.AS_UNIT)
+ {
+ asEmitter = backend.createEmitter(outputWriter);
+ asBlockWalker = backend.createWalker(project, errors, asEmitter);
+
+ asBlockWalker.visitCompilationUnit(cu);
+ }
+ else
+ {
+ mxmlEmitter = backend.createMXMLEmitter(outputWriter);
+
+ mxmlBlockWalker = backend.createMXMLWalker(project, errors,
+ mxmlEmitter, asEmitter, asBlockWalker);
+
+ mxmlBlockWalker.visitCompilationUnit(cu);
+ }
+
+ //System.out.println(outputWriter.toString());
+
+ try
+ {
+ BufferedOutputStream out = new BufferedOutputStream(
+ new FileOutputStream(outputClassFile));
+
+ out.write(outputWriter.toString().getBytes());
+ out.flush();
+ out.close();
+ }
+ catch (Exception error)
+ {
+ System.out.println(error);
+ }
+
+ outputWriter = null;
+ }
+ }
+
+ return compiledFileNames;
+ }
+
+ //--------------------------------------------------------------------------
+ // Node "factory"
+ //--------------------------------------------------------------------------
+
+ public static final int WRAP_LEVEL_DOCUMENT = 1;
+ public static final int WRAP_LEVEL_NODE = 2;
+
+ protected IMXMLNode getNode(String code, Class<? extends IMXMLNode> type,
+ int wrapLevel)
+ {
+ if (wrapLevel >= WRAP_LEVEL_NODE)
+ code = "<s:Button " + code + "></s:Button>";
+
+ if (wrapLevel >= WRAP_LEVEL_DOCUMENT)
+ code = ""
+ + "<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\""
+ + " xmlns:s=\"library://ns.adobe.com/flex/spark\""
+ + " xmlns:mx=\"library://ns.adobe.com/flex/mx\">\n"
+ + code + "\n"
+ + "</s:Application>";
+
+ IMXMLFileNode node = compileMXML(code);
+
+ if (wrapLevel >= WRAP_LEVEL_NODE) // for now: attributes
+ {
+ IMXMLNode pnode = findFirstDescendantOfType(node, type);
+
+ IMXMLNode cnode = findFirstDescendantOfType(pnode, type);
+
+ return cnode;
+ }
+ else
+ {
+ return findFirstDescendantOfType(node, type);
+ }
+ }
+
+ protected IMXMLNode findFirstDescendantOfType(IMXMLNode node,
+ Class<? extends IMXMLNode> nodeType)
+ {
+
+ int n = node.getChildCount();
+ for (int i = 0; i < n; i++)
+ {
+ IMXMLNode child = (IMXMLNode) node.getChild(i);
+ if (nodeType.isInstance(child))
+ return child;
+
+ IMXMLNode found = findFirstDescendantOfType(child,
+ nodeType);
+ if (found != null)
+ return found;
+ }
+
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSTestBase.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
new file mode 100644
index 0000000..f6cbf58
--- /dev/null
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/test/VF2JSTestBase.java
@@ -0,0 +1,238 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.flex.compiler.internal.test;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.as.ASFilterWriter;
+import org.apache.flex.compiler.internal.driver.js.vf2js.VF2JSBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.tree.mxml.IMXMLNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.utils.FilenameNormalization;
+import org.apache.flex.utils.ITestAdapter;
+import org.apache.flex.utils.TestAdapterFactory;
+import org.junit.Ignore;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+@Ignore
+public class VF2JSTestBase extends MXMLTestBase
+{
+ private static ITestAdapter testAdapter = TestAdapterFactory.getTestAdapter();
+
+ @Override
+ public void setUp()
+ {
+ project = new FlexJSProject(workspace);
+
+ super.setUp();
+ }
+
+ @Override
+ public void tearDown()
+ {
+ asEmitter = null;
+ asBlockWalker = null;
+ mxmlEmitter = null;
+ mxmlBlockWalker = null;
+
+ super.tearDown();
+ }
+
+ @Override
+ protected void addSourcePaths(List<File> sourcePaths)
+ {
+ //sourcePaths.add(new File(FilenameNormalization.normalize("")));
+
+ super.addSourcePaths(sourcePaths);
+ }
+
+ @Override
+ protected IBackend createBackend()
+ {
+ return new VF2JSBackend();
+ }
+
+ @Override
+ protected List<String> compileProject(String inputFileName,
+ String inputDirName)
+ {
+ List<String> compiledFileNames = new ArrayList<String>();
+
+ String mainFileName = new File(testAdapter.getUnitTestBaseDir(),
+ inputDirName + "/" + inputFileName + inputFileExtension).getPath();
+
+ addDependencies();
+
+ String normalizedFileName = FilenameNormalization.normalize(
+ mainFileName);
+ Collection<ICompilationUnit> compilationUnits =
+ workspace.getCompilationUnits(normalizedFileName, project);
+ ICompilationUnit mainCU = Iterables.getOnlyElement(
+ compilationUnits);
+
+ if (project instanceof FlexJSProject)
+ ((FlexJSProject) project).mainCU = mainCU;
+
+ Configurator projectConfigurator = backend.createConfigurator();
+
+ JSTarget target = (JSTarget) backend.createTarget(project,
+ projectConfigurator.getTargetSettings(null), null);
+
+ target.build(mainCU, new ArrayList<ICompilerProblem>());
+
+ List<ICompilationUnit> reachableCompilationUnits = project
+ .getReachableCompilationUnitsInSWFOrder(ImmutableSet.of(mainCU));
+ for (final ICompilationUnit cu : reachableCompilationUnits)
+ {
+ ICompilationUnit.UnitType cuType = cu.getCompilationUnitType();
+
+ if (cuType == ICompilationUnit.UnitType.AS_UNIT
+ || cuType == ICompilationUnit.UnitType.MXML_UNIT)
+ {
+ File outputRootDir = new File(
+ FilenameNormalization.normalize(tempDir
+ + File.separator + inputDirName));
+
+ String qname = "";
+ try
+ {
+ qname = cu.getQualifiedNames().get(0);
+ }
+ catch (InterruptedException error)
+ {
+ System.out.println(error);
+ }
+
+ compiledFileNames.add(qname.replace(".", "/"));
+
+ final File outputClassFile = getOutputClassFile(qname
+ + "_output", outputRootDir);
+
+ ASFilterWriter outputWriter = backend.createWriterBuffer(project);
+
+ //asEmitter = backend.createEmitter(outputWriter);
+ //asBlockWalker = backend.createWalker(project, errors, asEmitter);
+
+ if (cuType == ICompilationUnit.UnitType.AS_UNIT)
+ {
+ asBlockWalker.visitCompilationUnit(cu);
+ }
+ else
+ {
+ //mxmlEmitter = backend.createMXMLEmitter(outputWriter);
+
+ //mxmlBlockWalker = backend.createMXMLWalker(project, errors,
+ // mxmlEmitter, asEmitter, asBlockWalker);
+
+ mxmlBlockWalker.visitCompilationUnit(cu);
+ }
+
+ System.out.println(outputWriter.toString());
+
+ try
+ {
+ BufferedOutputStream out = new BufferedOutputStream(
+ new FileOutputStream(outputClassFile));
+
+ out.write(outputWriter.toString().getBytes());
+ out.flush();
+ out.close();
+ }
+ catch (Exception error)
+ {
+ System.out.println(error);
+ }
+
+ outputWriter = null;
+ }
+ }
+
+ return compiledFileNames;
+ }
+
+ //--------------------------------------------------------------------------
+ // Node "factory"
+ //--------------------------------------------------------------------------
+
+ public static final int WRAP_LEVEL_DOCUMENT = 1;
+ public static final int WRAP_LEVEL_NODE = 2;
+
+ protected IMXMLNode getNode(String code, Class<? extends IMXMLNode> type,
+ int wrapLevel)
+ {
+ if (wrapLevel >= WRAP_LEVEL_NODE)
+ code = "<s:Button " + code + "></s:Button>";
+
+ if (wrapLevel >= WRAP_LEVEL_DOCUMENT)
+ code = ""
+ + "<s:Application xmlns:fx=\"http://ns.adobe.com/mxml/2009\""
+ + " xmlns:s=\"library://ns.adobe.com/flex/spark\""
+ + " xmlns:mx=\"library://ns.adobe.com/flex/mx\">\n"
+ + code + "\n"
+ + "</s:Application>";
+
+ IMXMLFileNode node = compileMXML(code);
+
+ if (wrapLevel >= WRAP_LEVEL_NODE) // for now: attributes
+ {
+ IMXMLNode pnode = findFirstDescendantOfType(node, type);
+
+ IMXMLNode cnode = findFirstDescendantOfType(pnode, type);
+
+ return cnode;
+ }
+ else
+ {
+ return findFirstDescendantOfType(node, type);
+ }
+ }
+
+ protected IMXMLNode findFirstDescendantOfType(IMXMLNode node,
+ Class<? extends IMXMLNode> nodeType)
+ {
+
+ int n = node.getChildCount();
+ for (int i = 0; i < n; i++)
+ {
+ IMXMLNode child = (IMXMLNode) node.getChild(i);
+ if (nodeType.isInstance(child))
+ return child;
+
+ IMXMLNode found = findFirstDescendantOfType(child,
+ nodeType);
+ if (found != null)
+ return found;
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/java/org/apache/flex/utils/EnvProperties.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/utils/EnvProperties.java b/compiler-jx/src/test/java/org/apache/flex/utils/EnvProperties.java
new file mode 100644
index 0000000..97d4835
--- /dev/null
+++ b/compiler-jx/src/test/java/org/apache/flex/utils/EnvProperties.java
@@ -0,0 +1,149 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.flex.utils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+
+/**
+ * EnvProperties checks in following order for a value.
+ *
+ * 1) unittest.properties
+ * 2) environment variables
+ * 3) for key FLEX_HOME & PLAYERGLOBAL_HOME sets a default value.
+ */
+public class EnvProperties {
+
+ /**
+ * FLEX_HOME
+ */
+ public String SDK;
+
+ /**
+ * TLF_HOME
+ */
+ public String TLF;
+
+ /**
+ * PLAYERGLOBAL_HOME
+ */
+ public String FPSDK;
+
+ /**
+ * AIR_HOME
+ */
+ public String AIRSDK;
+
+ /**
+ * FLASHPLAYER_DEBUGGER
+ */
+ public String FDBG;
+
+ /**
+ * ASJS_HOME
+ */
+ public String ASJS;
+
+ /**
+ * PLAYERGLOBAL_VERSION
+ */
+ public String FPVER;
+
+
+ private static EnvProperties env;
+
+ public static EnvProperties initiate() {
+ if(env == null) {
+ env = new EnvProperties();
+ env.setup();
+ }
+ return env;
+ }
+
+ private void setup()
+ {
+ String prefix = "";
+ Properties p = new Properties();
+ String envFileName = FilenameNormalization.normalize("../env.properties");
+ try {
+ File f = new File(envFileName);
+ if (f.exists())
+ {
+ p.load(new FileInputStream( f ));
+ prefix = "env.";
+ }
+ } catch (FileNotFoundException e) {
+ System.out.println(envFileName + " not found");
+ try {
+ File f = new File("unittest.properties");
+ p.load(new FileInputStream( f ));
+ } catch (FileNotFoundException e1) {
+ System.out.println("unittest.properties not found");
+ } catch (IOException e1) {
+ // Ignore
+ }
+ } catch (IOException e) {
+ // Ignore
+ }
+
+ SDK = p.getProperty(prefix + "FLEX_HOME", System.getenv("FLEX_HOME"));
+ if(SDK == null)
+ {
+ SDK = FilenameNormalization.normalize("../../flex-sdk");
+ File mxmlc = new File(SDK + "/lib/mxmlc.jar");
+ if (!mxmlc.exists())
+ SDK = FilenameNormalization.normalize("../compiler/generated/dist/sdk");
+ }
+ System.out.println("environment property - FLEX_HOME = " + SDK);
+
+ FPSDK = p.getProperty(prefix + "PLAYERGLOBAL_HOME", System.getenv("PLAYERGLOBAL_HOME"));
+ if(FPSDK == null)
+ FPSDK = FilenameNormalization.normalize("../compiler/generated/dist/sdk/frameworks/libs/player");
+ System.out.println("environment property - PLAYERGLOBAL_HOME = " + FPSDK);
+
+ FPVER = p.getProperty(prefix + "PLAYERGLOBAL_VERSION", System.getenv("PLAYERGLOBAL_VERSION"));
+ if (FPVER == null)
+ FPVER = "11.1";
+ System.out.println("environment property - PLAYERGLOBAL_VERSION = " + FPVER);
+
+ TLF = p.getProperty(prefix + "TLF_HOME", System.getenv("TLF_HOME"));
+ if (TLF == null)
+ {
+ TLF = FilenameNormalization.normalize("../../flex-tlf");
+ }
+ System.out.println("environment property - TLF_HOME = " + TLF);
+
+ AIRSDK = p.getProperty(prefix + "AIR_HOME", System.getenv("AIR_HOME"));
+ System.out.println("environment property - AIR_HOME = " + AIRSDK);
+
+ FDBG = p.getProperty(prefix + "FLASHPLAYER_DEBUGGER", System.getenv("FLASHPLAYER_DEBUGGER"));
+ System.out.println("environment property - FLASHPLAYER_DEBUGGER = " + FDBG);
+
+ ASJS = p.getProperty(prefix + "ASJS_HOME", System.getenv("ASJS_HOME"));
+ if (ASJS == null)
+ ASJS = FilenameNormalization.normalize("../../flex-asjs");
+ System.out.println("environment property - ASJS_HOME = " + ASJS);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/amd/simple-project/src/HelloWorld.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/amd/simple-project/src/HelloWorld.as b/compiler-jx/src/test/resources/amd/simple-project/src/HelloWorld.as
new file mode 100644
index 0000000..a8464e6
--- /dev/null
+++ b/compiler-jx/src/test/resources/amd/simple-project/src/HelloWorld.as
@@ -0,0 +1,55 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package {
+
+import com.acme.A;
+import com.acme.B;
+import com.acme.I;
+import com.acme.sub.IOther;
+import com.acme.sub.ISub;
+
+//noinspection JSUnusedGlobalSymbols
+public class HelloWorld {
+
+ //noinspection JSUnusedGlobalSymbols
+ public function HelloWorld() {
+ trace(B.now);
+ trace(B.nowPlusOne());
+
+ var b:B = new B('hello ');
+ trace("b = new B('hello '):", b);
+ trace("b.foo(3):", b.foo(3));
+ trace("b.baz():", b.baz());
+ trace("b is A:", b is A);
+ trace("b is B:", b is B);
+ trace("b is I:", b is I);
+ trace("b is ISub:", b is ISub);
+ trace("b is IOther:", b is IOther);
+
+ var a:A = new A('123');
+ trace("a = new A('123'):", a);
+ trace("a is A:", a is A);
+ trace("a is B:", a is B);
+ trace("a is I:", a is I);
+ trace("a is ISub:", a is ISub);
+ trace("a is IOther:", a is IOther);
+ }
+}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/A.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/A.as b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/A.as
new file mode 100644
index 0000000..a6ca41e
--- /dev/null
+++ b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/A.as
@@ -0,0 +1,57 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.acme {
+public class A implements I {
+
+ public function A(msg:String) {
+ this.msg = msg;
+ }
+
+ private var _msg:int;
+
+ public function get msg():String {
+ return String(this._msg);
+ }
+
+ trace("Class A is initialized!");
+
+ public function set msg(value:String):void {
+ this._msg = parseInt(value, 10);
+ }
+
+ private function secret(n) {
+ return msg + n;
+ }
+
+ public function foo(x) {
+ return this.secret(A.bar(x));
+ }
+
+ public function baz() {
+ var tmp = this.secret;
+ return tmp("-bound");
+ }
+
+ public static function bar(x) {
+ return x + 1;
+ }
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/B.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/B.as b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/B.as
new file mode 100644
index 0000000..eac2c60
--- /dev/null
+++ b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/B.as
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.acme {
+import com.acme.sub.IOther;
+import com.acme.sub.ISub;
+
+public class B extends A implements IOther, ISub {
+
+ public static function nowPlusOne() {
+ return new Date(B.now.getTime() + 60*60*1000);
+ }
+
+ public function B(msg, count) {
+ super(msg);
+ this.count = count;
+ trace("now: " + B.now);
+ }
+
+ public var count = 0;
+
+ public var barfoo = A.bar(3);
+
+ public override function foo(x) {
+ return super.foo(x + 2) + "-sub";
+ }
+
+ public static var now = new Date();
+
+}
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/I.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/I.as b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/I.as
new file mode 100644
index 0000000..4766279
--- /dev/null
+++ b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/I.as
@@ -0,0 +1,26 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.acme {
+public interface I {
+
+ function get msg():String;
+
+}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/IOther.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/IOther.as b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/IOther.as
new file mode 100644
index 0000000..e211130
--- /dev/null
+++ b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/IOther.as
@@ -0,0 +1,25 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.acme.sub {
+
+public interface IOther {
+
+}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/ISub.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/ISub.as b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/ISub.as
new file mode 100644
index 0000000..6259ce6
--- /dev/null
+++ b/compiler-jx/src/test/resources/amd/simple-project/src/com/acme/sub/ISub.as
@@ -0,0 +1,28 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package com.acme.sub {
+import com.acme.I;
+
+public interface ISub extends I {
+
+ function foo(x);
+
+}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/externals/app1/as_src/Main.as
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/externals/app1/as_src/Main.as b/compiler-jx/src/test/resources/externals/app1/as_src/Main.as
new file mode 100644
index 0000000..3c5095a
--- /dev/null
+++ b/compiler-jx/src/test/resources/externals/app1/as_src/Main.as
@@ -0,0 +1,34 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package
+{
+public class Main
+{
+ public function start():void
+ {
+ var button:Element = document.createElement("button");
+ button.onclick = function ():void {
+ alert("Hello browser from FalconJX!");
+ };
+ button.textContent = "Say Hello";
+ document.body.appendChild(button);
+ }
+}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/externals_unit_tests/annotation_enum.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/externals_unit_tests/annotation_enum.js b/compiler-jx/src/test/resources/externals_unit_tests/annotation_enum.js
new file mode 100644
index 0000000..1b578cd
--- /dev/null
+++ b/compiler-jx/src/test/resources/externals_unit_tests/annotation_enum.js
@@ -0,0 +1,61 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @enum {string}
+ * @see http://dev.w3.org/csswg/css-font-loading/#enumdef-fontfaceloadstatus
+ */
+var FontFaceLoadStatus = {
+ ERROR: 'error',
+ LOADED: 'loaded',
+ LOADING: 'loading',
+ UNLOADED: 'unloaded'
+};
+
+/**
+ * @enum
+ * @see http://dev.w3.org/csswg/css-font-loading/#enumdef-fontfacesetloadstatus
+ */
+var FontFaceSetLoadStatus = {
+ FOO_LOADED: 'loaded',
+ FOO_LOADING: 'loading'
+};
+
+/** @const */
+var foo = {};
+/** @const */
+foo.bar = {};
+/** @const */
+foo.bar.baz = {};
+
+/**
+ * @enum
+ */
+foo.bar.baz.QualifiedEnum = {
+ One: '1',
+ Two: '2'
+};
+
+
+
+
+
+
+
+
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/externals_unit_tests/constructor_members.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/externals_unit_tests/constructor_members.js b/compiler-jx/src/test/resources/externals_unit_tests/constructor_members.js
new file mode 100644
index 0000000..fef6730
--- /dev/null
+++ b/compiler-jx/src/test/resources/externals_unit_tests/constructor_members.js
@@ -0,0 +1,57 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// define class
+/**
+ * @constructor
+ * @param {number} y
+ * @param {*=} opt_separator
+ * @param {...*} var_args
+ */
+function Foo(arg1, opt_arg2, var_args) {}
+
+// property
+/**
+ * @type {Function}
+ */
+Foo.prototype.bar;
+
+// global variable instance
+/**
+ * @type {!Foo}
+ */
+var foo;
+
+// method with arg and no return
+/**
+ * @param {string} arg1
+ */
+Foo.prototype.method1 = function(arg1) {};
+
+// method with arg and return
+/**
+ * @param {string} arg1
+ * @return {boolean}
+ */
+Foo.prototype.method2 = function(arg1) {};
+
+/**
+ * @const
+ */
+var bar;
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/externals_unit_tests/constructor_params.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/externals_unit_tests/constructor_params.js b/compiler-jx/src/test/resources/externals_unit_tests/constructor_params.js
new file mode 100644
index 0000000..2e8d7eb
--- /dev/null
+++ b/compiler-jx/src/test/resources/externals_unit_tests/constructor_params.js
@@ -0,0 +1,81 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * A constructor with no args.
+ *
+ * @constructor
+ */
+function FooNoArgs() {}
+
+/**
+ * A constructor with arg and opt arg.
+ *
+ * @constructor
+ * @param {number} arg1
+ * @param {*=} opt_arg2
+ */
+function FooOptArgs(arg1, opt_arg2) {}
+
+/**
+ * A constructor with arg and var args.
+ *
+ * @constructor
+ * @param {number} arg1
+ * @param {...*} var_args
+ */
+function FooVarArgs(arg1, var_args) {}
+
+/**
+ * A constructor with arg, opt arg and var args.
+ *
+ * @constructor
+ * @param {number} arg1 The arg 1.
+ * @param {*=} opt_arg2 The arg that is
+ * wrapped by another
+ * line in the comment.
+ * @param {...*} var_args A var agr param.
+ * @see http://foo.bar.com
+ * @returns {FooVarArgs} Another instance.
+ */
+function FooOptVarArgs(arg1, opt_arg2, var_args) {}
+
+/**
+ * A constructor with no args.
+ *
+ * @constructor
+ */
+AssignFooNoArgs = function () {};
+
+/**
+ * A constructor with no args.
+ *
+ * @constructor
+ */
+var VarAssignFooNoArgs = function () {};
+
+/**
+ * @const
+ */
+var FinalClass = {};
+
+/**
+ * A static method.
+ */
+FinalClass.bar = function () {};
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/externals_unit_tests/imports/import_constructor_signatures.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/externals_unit_tests/imports/import_constructor_signatures.js b/compiler-jx/src/test/resources/externals_unit_tests/imports/import_constructor_signatures.js
new file mode 100644
index 0000000..9f80e7e
--- /dev/null
+++ b/compiler-jx/src/test/resources/externals_unit_tests/imports/import_constructor_signatures.js
@@ -0,0 +1,43 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+ * @constructor
+ * @param {foo.Qux|foo.Bar} qux
+ * @param {foo.Bar} bar
+ * @param {number} value
+ * @param {foo.Baz?} baz
+ */
+ImportConstructorSignature = function(qux, bar, value, baz) {};
+
+/**
+ * @constructor
+ */
+foo.Bar = function() {};
+
+/**
+ * @constructor
+ */
+foo.Baz = function() {};
+
+/**
+ * @constructor
+ */
+foo.Qux = function() {};
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/externals_unit_tests/imports/import_functions.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/externals_unit_tests/imports/import_functions.js b/compiler-jx/src/test/resources/externals_unit_tests/imports/import_functions.js
new file mode 100644
index 0000000..b6c170b
--- /dev/null
+++ b/compiler-jx/src/test/resources/externals_unit_tests/imports/import_functions.js
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+ * @param {foo.Bar} bar
+ * @param {foo.Baz} baz
+ * @param {Quux} quux
+ * @return {!foo.Qux}
+ */
+function ImportFunction(bar, baz, quux) {}
+
+/**
+ * @constructor
+ */
+Quux = function() {};
+
+/**
+ * @constructor
+ */
+foo.Bar = function() {};
+
+/**
+ * @constructor
+ */
+foo.Baz = function() {};
+
+/**
+ * @constructor
+ */
+foo.Qux = function() {};
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/externals_unit_tests/imports/import_interfaces.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/externals_unit_tests/imports/import_interfaces.js b/compiler-jx/src/test/resources/externals_unit_tests/imports/import_interfaces.js
new file mode 100644
index 0000000..97a711f
--- /dev/null
+++ b/compiler-jx/src/test/resources/externals_unit_tests/imports/import_interfaces.js
@@ -0,0 +1,49 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @constructor
+ * @implements {Qux}
+ * @implements {API.Foo}
+ */
+ImportInterfaces = function() {};
+
+
+/**
+ * @interface
+ */
+Qux = function() {};
+
+/**
+ * @interface
+ * @extends {Qux}
+ * @extends {API.Bar}
+ * @extends {API.foo.Baz}
+ */
+API.Foo = function() {};
+
+/**
+ * @interface
+ */
+API.Bar = function() {};
+
+/**
+ * @interface
+ */
+API.foo.Baz = function() {};
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/externals_unit_tests/imports/import_method_signatures.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/externals_unit_tests/imports/import_method_signatures.js b/compiler-jx/src/test/resources/externals_unit_tests/imports/import_method_signatures.js
new file mode 100644
index 0000000..6524dc5
--- /dev/null
+++ b/compiler-jx/src/test/resources/externals_unit_tests/imports/import_method_signatures.js
@@ -0,0 +1,71 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @constructor
+ */
+ImportMethodSignature = function() {};
+
+/**
+ * @param {foo.Quux|foo.Bar} bar
+ * @param {number} value
+ * @param {foo.Baz?} baz
+ */
+ImportMethodSignature.myMethod = function(bar, value, baz) {};
+
+/**
+ * @param {foo.Bar} bar
+ * @param {number} value
+ * @param {foo.Baz?} baz
+ * @return {foo.Qux}
+ */
+ImportMethodSignature.prototype.myMethodWithReturnType = function(bar, value, baz) {};
+
+/**
+ * @param {foo.Bar} bar
+ * @param {number} value
+ * @param {foo.Baz?} baz
+ * @return {foo.Quuux|foo.Bar}
+ */
+ImportMethodSignature.myMethodWithUnionReturnType = function(bar, value, baz) {};
+
+/**
+ * @constructor
+ */
+foo.Bar = function() {};
+
+/**
+ * @constructor
+ */
+foo.Baz = function() {};
+
+/**
+ * @constructor
+ */
+foo.Qux = function() {};
+
+/**
+ * @constructor
+ */
+foo.Quux = function() {};
+
+/**
+ * @constructor
+ */
+foo.Quuux = function() {};
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/externals_unit_tests/imports/import_superclasses.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/externals_unit_tests/imports/import_superclasses.js b/compiler-jx/src/test/resources/externals_unit_tests/imports/import_superclasses.js
new file mode 100644
index 0000000..1a549d7
--- /dev/null
+++ b/compiler-jx/src/test/resources/externals_unit_tests/imports/import_superclasses.js
@@ -0,0 +1,46 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @constructor
+ * @extends {Qux}
+ */
+ImportSuperClass1 = function() {};
+
+/**
+ * @constructor
+ * @extends {BASE.Foo}
+ */
+ImportSuperClass2 = function() {};
+
+/**
+ * @constructor
+ */
+Qux = function() {};
+
+/**
+ * @constructor
+ * @extends {BASE.Bar}
+ */
+BASE.Foo = function() {};
+
+/**
+ * @constructor
+ */
+BASE.Bar = function() {};
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/externals_unit_tests/package_namespace.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/externals_unit_tests/package_namespace.js b/compiler-jx/src/test/resources/externals_unit_tests/package_namespace.js
new file mode 100644
index 0000000..3ea2fbf
--- /dev/null
+++ b/compiler-jx/src/test/resources/externals_unit_tests/package_namespace.js
@@ -0,0 +1,48 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @constructor
+ */
+Foo = function () {};
+
+/**
+ * @const
+ */
+var foo = {};
+
+/**
+ * @const
+ */
+foo.bar = {};
+
+ /**
+ * @constructor
+ */
+foo.bar.Baz = function () {};
+
+/**
+ * @constructor
+ */
+function Goo () {}
+
+/**
+ * @typedef {Foo}
+ */
+var ATypeDef;
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/externals_unit_tests/type_inheritence.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/externals_unit_tests/type_inheritence.js b/compiler-jx/src/test/resources/externals_unit_tests/type_inheritence.js
new file mode 100644
index 0000000..f9ebe8e
--- /dev/null
+++ b/compiler-jx/src/test/resources/externals_unit_tests/type_inheritence.js
@@ -0,0 +1,62 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// type logic uses Object as the top of the tree
+/**
+ * @constructor
+ */
+function Object() {}
+
+/**
+ * @interface
+ */
+function EventTarget() {}
+
+/**
+ * @param {string} type
+ * @param {EventListener|function(!Event):(boolean|undefined)} listener
+ * @param {boolean} useCapture
+ * @return {undefined}
+ */
+EventTarget.prototype.addEventListener = function(type, listener, useCapture) {};
+
+/**
+ * @constructor
+ * @implements {EventTarget}
+ */
+function Foo () {}
+
+/**
+ * @param {boolean=} opt_useCapture
+ * @override
+ */
+Foo.prototype.addEventListener = function(type, listener, opt_useCapture) {};
+
+/**
+ * @constructor
+ * @extends {Foo}
+ */
+function Bar () {}
+
+
+/**
+ * @constructor
+ * @extends {Bar}
+ */
+function Baz () {}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/test/resources/externals_unit_tests/types_param.js
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/resources/externals_unit_tests/types_param.js b/compiler-jx/src/test/resources/externals_unit_tests/types_param.js
new file mode 100644
index 0000000..76cfe03
--- /dev/null
+++ b/compiler-jx/src/test/resources/externals_unit_tests/types_param.js
@@ -0,0 +1,82 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+ * @const
+ */
+var foo = {};
+
+/**
+ * @const
+ */
+foo.bar = {};
+
+ /**
+ * @constructor
+ */
+foo.bar.Baz = function () {};
+
+ /**
+ * @constructor
+ */
+function Foo () {}
+
+/**
+ * @param {string} arg1
+ */
+Foo.test1 = function (arg1) {};
+
+/**
+ * @param {foo.bar.Baz} arg1
+ */
+Foo.test2 = function (arg1) {};
+
+/**
+ * @param {{myNum: number, myObject}} arg1
+ */
+Foo.test3 = function (arg1) {};
+
+/**
+ * @param {?number} arg1
+ */
+Foo.test4 = function (arg1) {};
+
+/**
+ * @param {!Object} arg1
+ */
+Foo.test5 = function (arg1) {};
+
+/**
+ * @param {function(string, boolean)} arg1
+ */
+Foo.test6 = function (arg1) {};
+
+
+
+
+
+
+
+
+
+
+
+
+