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/10/21 15:17:04 UTC

[26/44] git commit: [flex-falcon] [refs/heads/feature-autobuild/maven-archetypes] - get raw output from asdoc into .txt files. Next step is to create dita files

get raw output from asdoc into .txt files.  Next step is to create dita files


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/f938cb72
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/f938cb72
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/f938cb72

Branch: refs/heads/feature-autobuild/maven-archetypes
Commit: f938cb721f121d1afdf675e4011ce18804ebb640
Parents: c5a1025
Author: Alex Harui <ah...@apache.org>
Authored: Tue Oct 11 09:30:09 2016 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Oct 11 22:33:11 2016 -0700

----------------------------------------------------------------------
 .../apache/flex/compiler/clients/ASDOCJSC.java  |  445 ++++++
 .../apache/flex/compiler/clients/MXMLJSC.java   |    2 +-
 .../codegen/js/flexjs/JSFlexJSASDocEmitter.java |  456 ++++++
 .../mxml/flexjs/MXMLFlexJSASDocEmitter.java     | 1478 ++++++++++++++++++
 .../driver/js/goog/ASDocConfiguration.java      |  566 +++++++
 .../driver/mxml/ASDocASSourceFileHandler.java   |   89 ++
 .../driver/mxml/ASDocMXMLSourceFileHandler.java |   89 ++
 .../mxml/flexjs/MXMLFlexJSASDocBackend.java     |  140 ++
 .../internal/projects/FlexJSProject.java        |    2 +
 9 files changed, 3266 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f938cb72/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ASDOCJSC.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ASDOCJSC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ASDOCJSC.java
new file mode 100644
index 0000000..5bab139
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ASDOCJSC.java
@@ -0,0 +1,445 @@
+/*
+ *
+ *  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.clients;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Set;
+import java.util.zip.Deflater;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.flex.compiler.codegen.as.IASWriter;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.driver.js.IJSApplication;
+import org.apache.flex.compiler.exceptions.ConfigurationException;
+import org.apache.flex.compiler.exceptions.ConfigurationException.IOError;
+import org.apache.flex.compiler.exceptions.ConfigurationException.MustSpecifyTarget;
+import org.apache.flex.compiler.internal.codegen.js.JSSharedData;
+import org.apache.flex.compiler.internal.driver.as.ASBackend;
+import org.apache.flex.compiler.internal.driver.js.amd.AMDBackend;
+import org.apache.flex.compiler.internal.driver.js.goog.ASDocConfiguration;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSASDocBackend;
+import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSSWCBackend;
+import org.apache.flex.compiler.internal.driver.mxml.jsc.MXMLJSCJSSWCBackend;
+import org.apache.flex.compiler.internal.driver.mxml.vf2js.MXMLVF2JSSWCBackend;
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.internal.targets.FlexJSSWCTarget;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.problems.FileNotFoundProblem;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.problems.InternalCompilerProblem;
+import org.apache.flex.compiler.problems.LibraryNotFoundProblem;
+import org.apache.flex.compiler.problems.UnableToBuildSWFProblem;
+import org.apache.flex.compiler.targets.ITarget.TargetType;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.swc.ISWC;
+import org.apache.flex.swc.io.SWCReader;
+
+/**
+ * @author Erik de Bruin
+ * @author Michael Schmalle
+ */
+public class ASDOCJSC extends MXMLJSC
+{
+    /*
+     * Exit code enumerations.
+     */
+    static enum ExitCode
+    {
+        SUCCESS(0),
+        PRINT_HELP(1),
+        FAILED_WITH_PROBLEMS(2),
+        FAILED_WITH_EXCEPTIONS(3),
+        FAILED_WITH_CONFIG_PROBLEMS(4);
+
+        ExitCode(int code)
+        {
+            this.code = code;
+        }
+
+        final int code;
+    }
+
+    @Override
+    public String getName()
+    {
+        return FLEX_TOOL_ASDOC;
+    }
+
+    @Override
+    public int execute(String[] args)
+    {
+        return staticMainNoExit(args);
+    }
+
+    /**
+     * Java program entry point.
+     * 
+     * @param args command line arguments
+     */
+    public static void main(final String[] args)
+    {
+        int exitCode = staticMainNoExit(args);
+        System.exit(exitCode);
+    }
+
+    /**
+     * Entry point for the {@code <compc>} Ant task.
+     *
+     * @param args Command line arguments.
+     * @return An exit code.
+     */
+    public static int staticMainNoExit(final String[] args)
+    {
+        long startTime = System.nanoTime();
+
+        IBackend backend = new ASBackend();
+        for (String s : args)
+        {
+            if (s.contains("js-output-type"))
+            {
+                jsOutputType = JSOutputType.fromString(s.split("=")[1]);
+
+                switch (jsOutputType)
+                {
+                case AMD:
+                    backend = new AMDBackend();
+                    break;
+
+                case JSC:
+                    backend = new MXMLJSCJSSWCBackend();
+                    break;
+
+                case FLEXJS:
+                case FLEXJS_DUAL:
+                    backend = new MXMLFlexJSASDocBackend();
+                    break;
+
+                case GOOG:
+                    backend = new GoogBackend();
+                    break;
+
+                case VF2JS:
+                    backend = new MXMLVF2JSSWCBackend();
+                    break;
+
+                default:
+                    throw new UnsupportedOperationException();
+                }
+            }
+        }
+
+        final ASDOCJSC mxmlc = new ASDOCJSC(backend);
+        final List<ICompilerProblem> problems = new ArrayList<ICompilerProblem>();
+        final int exitCode = mxmlc.mainNoExit(args, problems, true);
+
+        long endTime = System.nanoTime();
+        JSSharedData.instance.stdout((endTime - startTime) / 1e9 + " seconds");
+
+        return exitCode;
+    }
+
+    public ASDOCJSC(IBackend backend)
+    {
+        super(backend);
+    }
+
+    /**
+     * Main body of this program. This method is called from the public static
+     * method's for this program.
+     * 
+     * @return true if compiler succeeds
+     * @throws IOException
+     * @throws InterruptedException
+     */
+    @Override
+    protected boolean compile()
+    {
+        boolean compilationSuccess = false;
+
+        try
+        {
+            project.getSourceCompilationUnitFactory().addHandler(asFileHandler);
+
+            if (setupTargetFile())
+                buildArtifact();
+
+            if (jsTarget != null)
+            {
+                Collection<ICompilerProblem> errors = new ArrayList<ICompilerProblem>();
+                Collection<ICompilerProblem> warnings = new ArrayList<ICompilerProblem>();
+
+                if (!config.getCreateTargetWithErrors())
+                {
+                    problems.getErrorsAndWarnings(errors, warnings);
+                    if (errors.size() > 0)
+                        return false;
+                }
+
+                String outputFolderName = getOutputFilePath();
+
+                File outputFolder = null;
+            	outputFolder = new File(outputFolderName);
+
+                Set<String> externs = config.getExterns();
+                List<String> excludeClasses = ((ASDocConfiguration)config).getExcludeClasses();
+                List<String> excludeSources = ((ASDocConfiguration)config).getExcludeSources();
+                Collection<ICompilationUnit> roots = ((FlexJSSWCTarget)target).getReachableCompilationUnits(errors);
+                Collection<ICompilationUnit> reachableCompilationUnits = project.getReachableCompilationUnitsInSWFOrder(roots);
+                for (final ICompilationUnit cu : reachableCompilationUnits)
+                {
+                    ICompilationUnit.UnitType cuType = cu.getCompilationUnitType();
+
+                    if (cuType == ICompilationUnit.UnitType.AS_UNIT
+                            || cuType == ICompilationUnit.UnitType.MXML_UNIT)
+                    {
+                    	String symbol = cu.getQualifiedNames().get(0);
+                    	if (externs.contains(symbol)) continue;
+                    	if (excludeClasses.contains(symbol)) continue;
+                    	String sourceFile = cu.getAbsoluteFilename();
+                    	if (excludeSources.contains(sourceFile)) continue;                    		
+                    	
+                        final File outputClassFile = getOutputClassFile(
+                                cu.getQualifiedNames().get(0), outputFolder);
+
+                        System.out.println("Compiling file: " + outputClassFile);
+
+                        ICompilationUnit unit = cu;
+
+                        IASWriter writer;
+                        if (cuType == ICompilationUnit.UnitType.AS_UNIT)
+                        {
+                            writer = JSSharedData.backend.createWriter(project,
+                                    (List<ICompilerProblem>) errors, unit,
+                                    false);
+                        }
+                        else
+                        {
+                            writer = JSSharedData.backend.createMXMLWriter(
+                                    project, (List<ICompilerProblem>) errors,
+                                    unit, false);
+                        }
+                        problems.addAll(errors);
+                        BufferedOutputStream out = new BufferedOutputStream(
+                                new FileOutputStream(outputClassFile));
+                        writer.writeTo(out);
+                        out.flush();
+                        out.close();
+                        writer.close();
+                    }
+                }
+                compilationSuccess = true;
+            }
+        }
+        catch (Exception e)
+        {
+            final ICompilerProblem problem = new InternalCompilerProblem(e);
+            problems.add(problem);
+        }
+
+        return compilationSuccess;
+    }
+
+    /**
+     * Build target artifact.
+     * 
+     * @throws InterruptedException threading error
+     * @throws IOException IO error
+     * @throws ConfigurationException
+     */
+    @Override
+    protected void buildArtifact() throws InterruptedException, IOException,
+            ConfigurationException
+    {
+        jsTarget = buildJSTarget();
+    }
+
+    private IJSApplication buildJSTarget() throws InterruptedException,
+            FileNotFoundException, ConfigurationException
+    {
+        final List<ICompilerProblem> problemsBuildingSWF = new ArrayList<ICompilerProblem>();
+
+        final IJSApplication app = buildApplication(project,
+                config.getMainDefinition(), null, problemsBuildingSWF);
+        problems.addAll(problemsBuildingSWF);
+        if (app == null)
+        {
+            ICompilerProblem problem = new UnableToBuildSWFProblem(
+                    getOutputFilePath());
+            problems.add(problem);
+        }
+
+        return app;
+    }
+
+    /**
+     * Replaces FlexApplicationProject::buildSWF()
+     * 
+     * @param applicationProject
+     * @param rootClassName
+     * @param problems
+     * @return
+     * @throws InterruptedException
+     */
+
+    private IJSApplication buildApplication(CompilerProject applicationProject,
+            String rootClassName, ICompilationUnit mainCU,
+            Collection<ICompilerProblem> problems) throws InterruptedException,
+            ConfigurationException, FileNotFoundException
+    {
+        Collection<ICompilerProblem> fatalProblems = applicationProject.getFatalProblems();
+        if (!fatalProblems.isEmpty())
+        {
+            problems.addAll(fatalProblems);
+            return null;
+        }
+
+        return ((JSTarget) target).build(mainCU, problems);
+    }
+
+    /**
+     * Get the output file path. If {@code -output} is specified, use its value;
+     * otherwise, use the same base name as the target file.
+     * 
+     * @return output file path
+     */
+    private String getOutputFilePath()
+    {
+        if (config.getOutput() == null)
+        {
+            final String extension = "." + JSSharedData.OUTPUT_EXTENSION;
+            return FilenameUtils.removeExtension(config.getTargetFile()).concat(
+                    extension);
+        }
+        else
+        {
+            String outputFolderName = config.getOutput();
+            return outputFolderName;
+        }
+    }
+
+    /**
+     * Get the output class file. This includes the (sub)directory in which the
+     * original class file lives. If the directory structure doesn't exist, it
+     * is created.
+     * 
+     * @author Erik de Bruin
+     * @param qname
+     * @param outputFolder
+     * @return output class file path
+     */
+    private 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 + "." + JSSharedData.OUTPUT_EXTENSION);
+    }
+
+    /**
+     * Mxmlc uses target file as the main compilation unit and derive the output
+     * SWF file name from this file.
+     * 
+     * @return true if successful, false otherwise.
+     * @throws InterruptedException
+     */
+    @Override
+    protected boolean setupTargetFile() throws InterruptedException
+    {
+        config.getTargetFile();
+
+        ITargetSettings settings = getTargetSettings();
+        if (settings != null)
+            project.setTargetSettings(settings);
+        else
+            return false;
+
+        target = JSSharedData.backend.createTarget(project,
+                getTargetSettings(), null);
+
+        return true;
+    }
+
+    private ITargetSettings getTargetSettings()
+    {
+        if (targetSettings == null)
+            targetSettings = projectConfigurator.getTargetSettings(getTargetType());
+
+        if (targetSettings == null)
+            problems.addAll(projectConfigurator.getConfigurationProblems());
+
+        return targetSettings;
+    }
+
+    /**
+     * Validate target file.
+     * 
+     * @throws MustSpecifyTarget
+     * @throws IOError
+     */
+    @Override
+    protected void validateTargetFile() throws ConfigurationException
+    {
+
+    }
+
+    protected String getProgramName()
+    {
+        return "compc";
+    }
+
+    protected boolean isCompc()
+    {
+        return true;
+    }
+
+    @Override
+    protected TargetType getTargetType()
+    {
+        return TargetType.SWC;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f938cb72/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
index d14ccd6..0430905 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -734,7 +734,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider,
     protected boolean configure(final String[] args)
     {
         project.getSourceCompilationUnitFactory().addHandler(asFileHandler);
-        projectConfigurator = createConfigurator();
+        project.configurator = projectConfigurator = createConfigurator();
 
         try
         {

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/f938cb72/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSASDocEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSASDocEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSASDocEmitter.java
new file mode 100644
index 0000000..bdd15a2
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSASDocEmitter.java
@@ -0,0 +1,456 @@
+/*
+ *
+ *  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.codegen.js.flexjs;
+
+import java.io.FilterWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flex.compiler.asdoc.flexjs.ASDocComment;
+import org.apache.flex.compiler.codegen.js.flexjs.IJSFlexJSEmitter;
+import org.apache.flex.compiler.codegen.js.goog.IJSGoogDocEmitter;
+import org.apache.flex.compiler.constants.IASKeywordConstants;
+import org.apache.flex.compiler.constants.IASLanguageConstants;
+import org.apache.flex.compiler.constants.INamespaceConstants;
+import org.apache.flex.compiler.definitions.IAccessorDefinition;
+import org.apache.flex.compiler.definitions.IClassDefinition;
+import org.apache.flex.compiler.definitions.IDefinition;
+import org.apache.flex.compiler.definitions.INamespaceDefinition;
+import org.apache.flex.compiler.definitions.IPackageDefinition;
+import org.apache.flex.compiler.definitions.ITypeDefinition;
+import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.JSSessionModel.ImplicitBindableImplementation;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitter;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+import org.apache.flex.compiler.internal.codegen.js.jx.AccessorEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.AsIsEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.BinaryOperatorEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.BindableEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.ClassEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.DefinePropertyFunctionEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.FieldEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.ForEachEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.FunctionCallEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.IdentifierEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.InterfaceEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.LiteralEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.MemberAccessEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.MethodEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.ObjectDefinePropertyEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.PackageFooterEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.PackageHeaderEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.SelfReferenceEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.SuperCallEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jx.VarDeclarationEmitter;
+import org.apache.flex.compiler.internal.codegen.js.utils.EmitterUtils;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSASDocEmitter;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSEmitter;
+import org.apache.flex.compiler.internal.definitions.AccessorDefinition;
+import org.apache.flex.compiler.internal.definitions.FunctionDefinition;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.projects.FlexProject;
+import org.apache.flex.compiler.internal.tree.as.BinaryOperatorAsNode;
+import org.apache.flex.compiler.internal.tree.as.BlockNode;
+import org.apache.flex.compiler.internal.tree.as.DynamicAccessNode;
+import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
+import org.apache.flex.compiler.internal.tree.as.FunctionNode;
+import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
+import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode;
+import org.apache.flex.compiler.internal.tree.as.MemberAccessExpressionNode;
+import org.apache.flex.compiler.internal.tree.as.NumericLiteralNode;
+import org.apache.flex.compiler.projects.ICompilerProject;
+import org.apache.flex.compiler.tree.ASTNodeID;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IAccessorNode;
+import org.apache.flex.compiler.tree.as.IBinaryOperatorNode;
+import org.apache.flex.compiler.tree.as.IClassNode;
+import org.apache.flex.compiler.tree.as.IContainerNode;
+import org.apache.flex.compiler.tree.as.IDefinitionNode;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
+import org.apache.flex.compiler.tree.as.IFileNode;
+import org.apache.flex.compiler.tree.as.IForLoopNode;
+import org.apache.flex.compiler.tree.as.IFunctionCallNode;
+import org.apache.flex.compiler.tree.as.IFunctionNode;
+import org.apache.flex.compiler.tree.as.IFunctionObjectNode;
+import org.apache.flex.compiler.tree.as.IGetterNode;
+import org.apache.flex.compiler.tree.as.IIdentifierNode;
+import org.apache.flex.compiler.tree.as.IInterfaceNode;
+import org.apache.flex.compiler.tree.as.ILiteralNode;
+import org.apache.flex.compiler.tree.as.IMemberAccessExpressionNode;
+import org.apache.flex.compiler.tree.as.INamespaceDecorationNode;
+import org.apache.flex.compiler.tree.as.INamespaceNode;
+import org.apache.flex.compiler.tree.as.IPackageNode;
+import org.apache.flex.compiler.tree.as.IScopedNode;
+import org.apache.flex.compiler.tree.as.ISetterNode;
+import org.apache.flex.compiler.tree.as.IUnaryOperatorNode;
+import org.apache.flex.compiler.tree.as.IVariableNode;
+import org.apache.flex.compiler.utils.ASNodeUtils;
+
+import com.google.common.base.Joiner;
+import org.apache.flex.compiler.utils.NativeUtils;
+
+/**
+ * Concrete implementation of the 'FlexJS' JavaScript production.
+ *
+ * @author Michael Schmalle
+ * @author Erik de Bruin
+ */
+public class JSFlexJSASDocEmitter extends JSGoogEmitter implements IJSFlexJSEmitter
+{
+
+    @Override
+    public String postProcess(String output)
+    {
+    	return output;
+    }
+
+    public JSFlexJSASDocEmitter(FilterWriter out)
+    {
+        super(out);
+    }
+
+    @Override
+    protected void writeIndent()
+    {
+        write(JSFlexJSEmitterTokens.INDENT);
+    }
+
+    @Override
+    protected String getIndent(int numIndent)
+    {
+        final StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < numIndent; i++)
+            sb.append(JSFlexJSEmitterTokens.INDENT.getToken());
+        return sb.toString();
+    }
+    
+    @Override
+    public void emitNamespace(INamespaceNode node)
+    {
+        ASDocComment asDoc = (ASDocComment) node.getASDocComment();
+        write("<");
+        write(formatQualifiedName(node.getQualifiedName()));
+        write(">");
+        indentPush();
+        if (asDoc != null)
+        	write(asDoc.commentNoEnd());
+        indentPop();
+        write("</");
+        write(formatQualifiedName(node.getQualifiedName()));
+        writeNewline(">");
+    }
+
+
+    @Override
+    public String formatQualifiedName(String name)
+    {
+        return formatQualifiedName(name, false);
+    }
+
+    public MXMLFlexJSASDocEmitter mxmlEmitter = null;
+
+    public String formatQualifiedName(String name, boolean isDoc)
+    {
+    	if (mxmlEmitter != null)
+    		name = mxmlEmitter.formatQualifiedName(name);
+        /*
+        if (name.contains("goog.") || name.startsWith("Vector."))
+            return name;
+        name = name.replaceAll("\\.", "_");
+        */
+    	if (getModel().isInternalClass(name))
+    		return getModel().getInternalClasses().get(name);
+        if (NativeUtils.isJSNative(name)) return name;
+    	if (name.startsWith("window."))
+    		name = name.substring(7);
+    	else if (!isDoc)
+    	{
+    	}
+        return name;
+    }
+
+    public String convertASTypeToJS(String name)
+    {
+        String result = name;
+
+        if (name.equals(""))
+            result = IASLanguageConstants.Object;
+        else if (name.equals(IASLanguageConstants.Class))
+            result = IASLanguageConstants.Object;
+        else if (name.equals(IASLanguageConstants._int)
+                || name.equals(IASLanguageConstants.uint))
+            result = IASLanguageConstants.Number;
+
+        boolean isBuiltinFunction = name.matches("Vector\\.<.*>");
+        if (isBuiltinFunction)
+        {
+        	result = IASLanguageConstants.Array;
+        }
+        return result;
+    }
+
+    //--------------------------------------------------------------------------
+    // Package Level
+    //--------------------------------------------------------------------------
+
+    @Override
+    public void emitPackageHeader(IPackageDefinition definition)
+    {
+    	IPackageNode packageNode = definition.getNode();
+    	IFileNode fileNode = (IFileNode) packageNode.getAncestorOfType(IFileNode.class);
+        int nodeCount = fileNode.getChildCount();
+        for (int i = 0; i < nodeCount; i++)
+        {
+	        IASNode pnode = fileNode.getChild(i);
+
+	        if (pnode instanceof IPackageNode)
+	        {
+	        }
+	        else if (pnode instanceof IClassNode)
+	        {
+	        	getWalker().walk(pnode);
+	        }
+	        else if (pnode instanceof IInterfaceNode)
+	        {
+	        	getWalker().walk(pnode);
+	        }
+            else if (pnode instanceof IFunctionNode)
+            {
+	        	getWalker().walk(pnode);
+            }
+            else if (pnode instanceof INamespaceNode)
+            {
+	        	getWalker().walk(pnode);
+            }
+            else if (pnode instanceof IVariableNode)
+            {
+	        	getWalker().walk(pnode);
+            }
+        }
+    }
+
+    @Override
+    public void emitPackageHeaderContents(IPackageDefinition definition)
+    {
+    }
+
+    @Override
+    public void emitPackageFooter(IPackageDefinition definition)
+    {
+    }
+
+    //--------------------------------------------------------------------------
+    // Class
+    //--------------------------------------------------------------------------
+
+    @Override
+    public void emitClass(IClassNode node)
+    {
+        ASDocComment asDoc = (ASDocComment) node.getASDocComment();
+        write("<");
+        write(formatQualifiedName(node.getQualifiedName()));
+        write(">");
+        indentPush();
+        if (asDoc != null)
+        	write(asDoc.commentNoEnd());
+        final IDefinitionNode[] members = node.getAllMemberNodes();
+        for (IDefinitionNode mnode : members)
+        {
+        	getWalker().walk(mnode);
+        }
+        indentPop();
+        write("</");
+        write(formatQualifiedName(node.getQualifiedName()));
+        write(">");
+    }
+
+    @Override
+    public void emitInterface(IInterfaceNode node)
+    {
+        ASDocComment asDoc = (ASDocComment) node.getASDocComment();
+        write("<");
+        write(formatQualifiedName(node.getQualifiedName()));
+        write(">");
+        indentPush();
+        if (asDoc != null)
+        	write(asDoc.commentNoEnd());
+        final IDefinitionNode[] members = node.getAllMemberDefinitionNodes();
+        for (IDefinitionNode mnode : members)
+        {
+        	getWalker().walk(mnode);
+        }
+        indentPop();
+        write("</");
+        write(formatQualifiedName(node.getQualifiedName()));
+        writeNewline(">");
+    }
+
+    private ArrayList<String> accessors = new ArrayList<String>();
+    
+    @Override
+    public void emitGetAccessor(IGetterNode node)
+    {
+    	if (node.getDefinition().isPrivate()) return;
+
+    	String name = node.getName();
+        if (accessors.contains(name)) return;
+        accessors.add(name);
+        ASDocComment asDoc = (ASDocComment) node.getASDocComment();
+        if (asDoc == null || asDoc.commentNoEnd().contains("@private"))
+        {
+        	IAccessorDefinition def = (IAccessorDefinition)node.getDefinition();
+        	IAccessorDefinition otherDef = (IAccessorDefinition)def.resolveCorrespondingAccessor(getWalker().getProject());
+        	if (otherDef != null)
+        	{
+            	IAccessorNode otherNode = (IAccessorNode)otherDef.getNode();
+            	if (otherNode != null)
+            		asDoc = (ASDocComment) otherNode.getASDocComment();        		
+        	}
+        }
+        write("<");
+        write(formatQualifiedName(node.getQualifiedName()));
+        write(">");
+        indentPush();
+        if (asDoc != null)
+        	write(asDoc.commentNoEnd());
+        indentPop();
+        write("</");
+        write(formatQualifiedName(node.getQualifiedName()));
+        writeNewline(">");
+    }
+
+    @Override
+    public void emitSetAccessor(ISetterNode node)
+    {
+    	if (node.getDefinition().isPrivate()) return;
+
+    	String name = node.getName();
+        if (accessors.contains(name)) return;
+        accessors.add(name);
+        ASDocComment asDoc = (ASDocComment) node.getASDocComment();
+        if (asDoc == null || asDoc.commentNoEnd().contains("@private"))
+        {
+        	IAccessorDefinition def = (IAccessorDefinition)node.getDefinition();
+        	IAccessorDefinition otherDef = (IAccessorDefinition)def.resolveCorrespondingAccessor(getWalker().getProject());
+        	if (otherDef != null)
+        	{
+            	IAccessorNode otherNode = (IAccessorNode)otherDef.getNode();
+            	if (otherNode != null)
+            		asDoc = (ASDocComment) otherNode.getASDocComment();        		
+        	}
+        }
+        write("<");
+        write(formatQualifiedName(node.getQualifiedName()));
+        write(">");
+        indentPush();
+        if (asDoc != null)
+        	write(asDoc.commentNoEnd());
+        indentPop();
+        write("</");
+        write(formatQualifiedName(node.getQualifiedName()));
+        writeNewline(">");
+    }
+    
+    @Override
+    public void emitField(IVariableNode node)
+    {
+    	if (node.getDefinition().isPrivate()) return;
+    	
+        ASDocComment asDoc = (ASDocComment) node.getASDocComment();
+        write("<");
+        write(formatQualifiedName(node.getQualifiedName()));
+        write(">");
+        indentPush();
+        if (asDoc != null)
+        	write(asDoc.commentNoEnd());
+        indentPop();
+        write("</");
+        write(formatQualifiedName(node.getQualifiedName()));
+        writeNewline(">");
+    }
+
+    @Override
+    public void emitVarDeclaration(IVariableNode node)
+    {
+    	if (node.getDefinition().isPrivate()) return;
+
+    	ASDocComment asDoc = (ASDocComment) node.getASDocComment();
+        write("<");
+        write(formatQualifiedName(node.getQualifiedName()));
+        write(">");
+        indentPush();
+        if (asDoc != null)
+        	write(asDoc.commentNoEnd());
+        indentPop();
+        write("</");
+        write(formatQualifiedName(node.getQualifiedName()));
+        writeNewline(">");
+    }
+
+    @Override
+    public void emitAccessors(IAccessorNode node)
+    {
+    	if (node.getDefinition().isPrivate()) return;
+
+    	String name = node.getName();
+        if (accessors.contains(name)) return;
+        accessors.add(name);
+        ASDocComment asDoc = (ASDocComment) node.getASDocComment();
+        if (asDoc == null || asDoc.commentNoEnd().contains("@private"))
+        {
+        	IAccessorDefinition def = (IAccessorDefinition)node.getDefinition();
+        	IAccessorDefinition otherDef = (IAccessorDefinition)def.resolveCorrespondingAccessor(getWalker().getProject());
+        	if (otherDef != null)
+        	{
+            	IAccessorNode otherNode = (IAccessorNode)otherDef.getNode();
+            	if (otherNode != null)
+            		asDoc = (ASDocComment) otherNode.getASDocComment();        		
+        	}
+        }
+        write("<");
+        write(formatQualifiedName(node.getQualifiedName()));
+        write(">");
+        indentPush();
+        if (asDoc != null)
+        	write(asDoc.commentNoEnd());
+        indentPop();
+        write("</");
+        write(formatQualifiedName(node.getQualifiedName()));
+        writeNewline(">");
+    }
+    
+    @Override
+    public void emitMethod(IFunctionNode node)
+    {
+    	if (node.getDefinition().isPrivate()) return;
+
+    	ASDocComment asDoc = (ASDocComment) node.getASDocComment();
+        write("<");
+        write(formatQualifiedName(node.getQualifiedName()));
+        write(">");
+        indentPush();
+        if (asDoc != null)
+        	write(asDoc.commentNoEnd());
+        indentPop();
+        write("</");
+        write(formatQualifiedName(node.getQualifiedName()));
+        writeNewline(">");
+    }
+}