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:23 UTC
[31/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/main/java/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
new file mode 100644
index 0000000..0f03323
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/goog/JSGoogConfiguration.java
@@ -0,0 +1,311 @@
+/*
+ *
+ * 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.driver.js.goog;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.flex.compiler.clients.JSConfiguration;
+import org.apache.flex.compiler.clients.MXMLJSC;
+import org.apache.flex.compiler.config.ConfigurationValue;
+import org.apache.flex.compiler.exceptions.ConfigurationException;
+import org.apache.flex.compiler.internal.config.annotations.Config;
+import org.apache.flex.compiler.internal.config.annotations.FlexOnly;
+import org.apache.flex.compiler.internal.config.annotations.InfiniteArguments;
+import org.apache.flex.compiler.internal.config.annotations.Mapping;
+
+/**
+ * The {@link JSGoogConfiguration} class holds all compiler arguments needed for
+ * compiling ActionScript to JavaScript the 'goog' way.
+ * <p>
+ * Specific flags are implemented here for the configuration to be loaded by the
+ * configure() method of {@link MXMLJSC}.
+ * <p>
+ * This class inherits all compiler arguments from the MXMLC compiler.
+ *
+ * @author Erik de Bruin
+ */
+public class JSGoogConfiguration extends JSConfiguration
+{
+ public JSGoogConfiguration()
+ {
+ }
+
+ //
+ // 'closure-lib'
+ //
+
+ protected String closureLib = "";
+
+ public boolean isClosureLibSet() {
+ return !closureLib.isEmpty();
+ }
+
+ public String getClosureLib()
+ {
+ try
+ {
+ if (closureLib.equals(""))
+ {
+ return getAbsolutePathFromPathRelativeToMXMLC(
+ "../../js/lib/google/closure-library");
+ }
+ }
+ catch (Exception e) { /* better to try and fail... */ }
+
+ return closureLib;
+ }
+
+ @Config
+ @Mapping("closure-lib")
+ public void setClosureLib(ConfigurationValue cv, String value)
+ throws ConfigurationException
+ {
+ if (value != null)
+ closureLib = value;
+ }
+
+ //
+ // Override 'compiler.binding-value-change-event-type'
+ //
+
+ private String bindingValueChangeEventType = "valueChange";
+
+ @Override
+ public String getBindingValueChangeEventType()
+ {
+ return bindingValueChangeEventType;
+ }
+
+ @Override
+ @Config(advanced = true)
+ public void setCompilerBindingValueChangeEventType(ConfigurationValue cv, String b)
+ {
+ bindingValueChangeEventType = b;
+ }
+
+ //
+ // Override 'compiler.mxml.children-as-data'
+ //
+
+ private Boolean childrenAsData = true;
+
+ @Override
+ public Boolean getCompilerMxmlChildrenAsData()
+ {
+ return childrenAsData;
+ }
+
+ @Override
+ @Config
+ @Mapping({"compiler", "mxml", "children-as-data"})
+ @FlexOnly
+ public void setCompilerMxmlChildrenAsData(ConfigurationValue cv, Boolean asData) throws ConfigurationException
+ {
+ childrenAsData = asData;
+ }
+
+ //
+ // 'marmotinni'
+ //
+
+ private String marmotinni;
+
+ public String getMarmotinni()
+ {
+ return marmotinni;
+ }
+
+ @Config
+ @Mapping("marmotinni")
+ public void setMarmotinni(ConfigurationValue cv, String value)
+ throws ConfigurationException
+ {
+ marmotinni = value;
+ }
+
+ //
+ // 'sdk-js-lib'
+ //
+
+ protected List<String> sdkJSLib = new ArrayList<String>();
+
+ public List<String> getSDKJSLib()
+ {
+ if (sdkJSLib.size() == 0)
+ {
+ try
+ {
+ String path = getAbsolutePathFromPathRelativeToMXMLC(
+ "../../frameworks/js/FlexJS/src");
+
+ sdkJSLib.add(path);
+ }
+ catch (Exception e) { /* better to try and fail... */ }
+ }
+
+ return sdkJSLib;
+ }
+
+ @Config(allowMultiple = true)
+ @Mapping("sdk-js-lib")
+ @InfiniteArguments
+ public void setSDKJSLib(ConfigurationValue cv, List<String> value)
+ throws ConfigurationException
+ {
+ sdkJSLib.addAll(value);
+ }
+
+ //
+ // 'external-js-lib'
+ //
+
+ private List<String> externalJSLib = new ArrayList<String>();
+
+ public List<String> getExternalJSLib()
+ {
+ return externalJSLib;
+ }
+
+ @Config(allowMultiple = true)
+ @Mapping("external-js-lib")
+ @InfiniteArguments
+ public void setExternalJSLib(ConfigurationValue cv, List<String> value)
+ throws ConfigurationException
+ {
+ externalJSLib.addAll(value);
+ }
+
+ //
+ // 'strict-publish'
+ //
+
+ private boolean strictPublish = true;
+
+ public boolean getStrictPublish()
+ {
+ return strictPublish;
+ }
+
+ @Config
+ @Mapping("strict-publish")
+ public void setStrictPublish(ConfigurationValue cv, boolean value)
+ throws ConfigurationException
+ {
+ strictPublish = value;
+ }
+
+ //
+ // 'keep-asdoc'
+ //
+
+ private boolean keepASDoc = true;
+
+ public boolean getKeepASDoc()
+ {
+ return keepASDoc;
+ }
+
+ @Config
+ @Mapping("keep-asdoc")
+ public void setKeepASDoc(ConfigurationValue cv, boolean value)
+ throws ConfigurationException
+ {
+ keepASDoc = value;
+ }
+
+
+
+ //
+ // 'remove-circulars'
+ //
+
+ private boolean removeCirculars = false;
+
+ public boolean getRemoveCirculars()
+ {
+ return removeCirculars;
+ }
+
+ @Config
+ @Mapping("remove-circulars")
+ public void setRemoveCirculars(ConfigurationValue cv, boolean value)
+ throws ConfigurationException
+ {
+ removeCirculars = value;
+ }
+
+
+
+ protected String getAbsolutePathFromPathRelativeToMXMLC(String relativePath)
+ throws IOException
+ {
+ String mxmlcURL = MXMLJSC.class.getProtectionDomain().getCodeSource()
+ .getLocation().getPath();
+
+ File mxmlc = new File(URLDecoder.decode(mxmlcURL, "utf-8"));
+
+ return new File(mxmlc.getParent() + File.separator + relativePath)
+ .getCanonicalPath();
+ }
+
+ //
+ // 'js-compiler-option'
+ //
+
+ protected List<String> jsCompilerOptions = new ArrayList<String>();
+
+ public List<String> getJSCompilerOptions()
+ {
+ return jsCompilerOptions;
+ }
+
+ @Config(allowMultiple = true)
+ @Mapping("js-compiler-option")
+ @InfiniteArguments
+ public void setJSCompilerOptions(ConfigurationValue cv, List<String> value)
+ throws ConfigurationException
+ {
+ jsCompilerOptions.addAll(value);
+ }
+
+ //
+ // 'js-output-optimization'
+ //
+
+ protected List<String> jsOutputOptimizations = new ArrayList<String>();
+
+ public List<String> getJSOutputOptimizations()
+ {
+ return jsOutputOptimizations;
+ }
+
+ @Config(allowMultiple = true)
+ @Mapping("js-output-optimization")
+ @InfiniteArguments
+ public void setJSOutputOptimizations(ConfigurationValue cv, List<String> value)
+ throws ConfigurationException
+ {
+ jsOutputOptimizations.addAll(value);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/jsc/JSCBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/jsc/JSCBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/jsc/JSCBackend.java
new file mode 100644
index 0000000..10d049f
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/jsc/JSCBackend.java
@@ -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 org.apache.flex.compiler.internal.driver.js.jsc;
+
+import java.util.List;
+
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.jsc.JSCPublisher;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSPublisher;
+import org.apache.flex.compiler.internal.driver.mxml.jsc.MXMLJSCJSBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+
+/**
+ * A concrete implementation of the {@link IBackend} API for the 'jsc' code
+ * production.
+ *
+ * @author Michael Schmalle
+ */
+public class JSCBackend extends MXMLJSCJSBackend
+{
+ @Override
+ public MXMLFlexJSPublisher createPublisher(IASProject project,
+ List<ICompilerProblem> errors, Configuration config)
+ {
+ return new JSCPublisher(config, (FlexJSProject) project);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/node/NodeBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/node/NodeBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/node/NodeBackend.java
new file mode 100644
index 0000000..e4d0503
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/node/NodeBackend.java
@@ -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 org.apache.flex.compiler.internal.driver.js.node;
+
+import java.util.List;
+
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.node.NodePublisher;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSPublisher;
+import org.apache.flex.compiler.internal.driver.js.jsc.JSCBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+
+/**
+ * A concrete implementation of the {@link IBackend} API for the 'node' code
+ * production.
+ *
+ * @author Josh Tynjala
+ */
+public class NodeBackend extends JSCBackend
+{
+ @Override
+ public MXMLFlexJSPublisher createPublisher(IASProject project,
+ List<ICompilerProblem> errors, Configuration config)
+ {
+ return new NodePublisher(config, (FlexJSProject) project);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/JSVF2JSConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/JSVF2JSConfiguration.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/JSVF2JSConfiguration.java
new file mode 100644
index 0000000..ae620f7
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/JSVF2JSConfiguration.java
@@ -0,0 +1,86 @@
+/*
+ *
+ * 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.driver.js.vf2js;
+
+import java.util.List;
+
+import org.apache.flex.compiler.clients.MXMLJSC;
+import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
+
+/**
+ * The {@link JSVF2JSConfiguration} class holds all compiler arguments needed for
+ * compiling ActionScript to JavaScript the 'goog' way.
+ * <p>
+ * Specific flags are implemented here for the configuration to be loaded by the
+ * configure() method of {@link MXMLJSC}.
+ * <p>
+ * This class inherits all compiler arguments from the MXMLC compiler.
+ *
+ * @author Erik de Bruin
+ */
+public class JSVF2JSConfiguration extends JSGoogConfiguration
+{
+ public JSVF2JSConfiguration()
+ {
+ }
+
+ //
+ // 'closure-lib'
+ //
+
+ @Override
+ public String getClosureLib()
+ {
+ try
+ {
+ if (closureLib.equals(""))
+ {
+ closureLib = getAbsolutePathFromPathRelativeToMXMLC(
+ "../lib/google/closure-library");
+ }
+ }
+ catch (Exception e) { /* better to try and fail... */ }
+
+ return closureLib;
+ }
+
+ //
+ // 'sdk-js-lib'
+ //
+
+ @Override
+ public List<String> getSDKJSLib()
+ {
+ if (sdkJSLib.size() == 0)
+ {
+ try
+ {
+ String path = getAbsolutePathFromPathRelativeToMXMLC(
+ "../../../../frameworks/js/vf2js/src");
+
+ sdkJSLib.add(path);
+ }
+ catch (Exception e) { /* better to try and fail... */ }
+ }
+
+ return sdkJSLib;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/VF2JSBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/VF2JSBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/VF2JSBackend.java
new file mode 100644
index 0000000..d0030fe
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/js/vf2js/VF2JSBackend.java
@@ -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 org.apache.flex.compiler.internal.driver.js.vf2js;
+
+import java.io.FilterWriter;
+
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSEmitter;
+import org.apache.flex.compiler.internal.driver.js.goog.GoogBackend;
+import org.apache.flex.compiler.internal.targets.FlexJSTarget;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetSettings;
+
+/**
+ * @author Erik de Bruin
+ */
+public class VF2JSBackend extends GoogBackend
+{
+
+ @Override
+ public IJSEmitter createEmitter(FilterWriter out)
+ {
+ IJSEmitter emitter = new JSVF2JSEmitter(out);
+ emitter.setDocEmitter(createDocEmitter(emitter));
+ return emitter;
+ }
+
+ @Override
+ public JSTarget createTarget(IASProject project, ITargetSettings settings,
+ ITargetProgressMonitor monitor)
+ {
+ return new FlexJSTarget(project, settings, monitor);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/MXMLBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/MXMLBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/MXMLBackend.java
new file mode 100644
index 0000000..a569be1
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/MXMLBackend.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.driver.mxml;
+
+import java.io.FilterWriter;
+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.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLEmitter;
+import org.apache.flex.compiler.internal.driver.js.JSBackend;
+import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
+import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
+import org.apache.flex.compiler.internal.visitor.mxml.MXMLNodeSwitch;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.visitor.IBlockVisitor;
+import org.apache.flex.compiler.visitor.IBlockWalker;
+import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
+
+/**
+ * A concrete implementation of the {@link IBackend} API where the
+ * {@link MXMLBlockWalker} is used to traverse the {@link IMXMLFileNode} AST.
+ *
+ * @author Erik de Bruin
+ */
+public class MXMLBackend extends JSBackend
+{
+
+ @Override
+ public ISourceFileHandler getSourceFileHandlerInstance()
+ {
+ return MXMLSourceFileHandler.INSTANCE;
+ }
+
+ @Override
+ public IMXMLEmitter createMXMLEmitter(FilterWriter out)
+ {
+ return new MXMLEmitter(out);
+ }
+
+ @Override
+ public IMXMLBlockWalker createMXMLWalker(IASProject project,
+ List<ICompilerProblem> errors, IMXMLEmitter mxmlEmitter,
+ IASEmitter asEmitter, IBlockWalker asBlockWalker)
+ {
+ MXMLBlockWalker walker = new MXMLBlockWalker(errors, project,
+ mxmlEmitter, asEmitter, asBlockWalker);
+
+ ASNodeSwitch asStrategy = new ASNodeSwitch(
+ (IBlockVisitor) asBlockWalker);
+ walker.setASStrategy(asStrategy);
+
+ MXMLNodeSwitch strategy = new MXMLNodeSwitch(walker);
+ walker.setMXMLStrategy(strategy);
+
+ return walker;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/MXMLSourceFileHandler.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/MXMLSourceFileHandler.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/MXMLSourceFileHandler.java
new file mode 100644
index 0000000..ef147b2
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/MXMLSourceFileHandler.java
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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.driver.mxml;
+
+import org.apache.flex.compiler.internal.projects.CompilerProject;
+import org.apache.flex.compiler.internal.projects.DefinitionPriority;
+import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
+import org.apache.flex.compiler.internal.units.ASCompilationUnit;
+import org.apache.flex.compiler.internal.units.MXMLCompilationUnit;
+import org.apache.flex.compiler.units.ICompilationUnit;
+
+/**
+ * Implementation of ISourceFileHandler that constructs
+ * {@link ASCompilationUnit}'s. MXMLSourceFileHandler is the SourceFileHandler
+ * that provides JSCompilationUnit for *.mxml files. JSDriver registers
+ * MXMLSourceFileHandler at FlexApplicationProject. This implementation is part
+ * of FalconJS. For more details on FalconJS see
+ * org.apache.flex.compiler.JSDriver
+ */
+public final class MXMLSourceFileHandler implements ISourceFileHandler
+{
+
+ public static final String EXTENSION = "mxml"; //$NON-NLS-1$
+ public static final MXMLSourceFileHandler INSTANCE = new MXMLSourceFileHandler();
+
+ private MXMLSourceFileHandler()
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String[] getExtensions()
+ {
+ return new String[] { EXTENSION };
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ICompilationUnit createCompilationUnit(CompilerProject proj,
+ String path, DefinitionPriority.BasePriority basePriority,
+ int order, String qname, String locale)
+ {
+ return new MXMLCompilationUnit(proj, path, basePriority, order, qname);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean needCompilationUnit(CompilerProject project, String path,
+ String qname, String locale)
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean canCreateInvisibleCompilationUnit()
+ {
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSBackend.java
new file mode 100644
index 0000000..612b089
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSBackend.java
@@ -0,0 +1,131 @@
+/*
+ *
+ * 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.driver.mxml.flexjs;
+
+import java.io.FilterWriter;
+import java.util.List;
+
+import org.apache.flex.compiler.codegen.IDocEmitter;
+import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.codegen.js.IJSWriter;
+import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitter;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLWriter;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSPublisher;
+import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
+import org.apache.flex.compiler.internal.driver.mxml.MXMLBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.targets.FlexJSTarget;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
+import org.apache.flex.compiler.internal.visitor.mxml.MXMLNodeSwitch;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.visitor.IBlockVisitor;
+import org.apache.flex.compiler.visitor.IBlockWalker;
+import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
+
+/**
+ * A concrete implementation of the {@link IBackend} API where the
+ * {@link MXMLBlockWalker} is used to traverse the {@link IMXMLFileNode} AST.
+ *
+ * @author Erik de Bruin
+ */
+public class MXMLFlexJSBackend extends MXMLBackend
+{
+
+ @Override
+ public Configurator createConfigurator()
+ {
+ return new Configurator(JSGoogConfiguration.class);
+ }
+
+ @Override
+ public IMXMLEmitter createMXMLEmitter(FilterWriter out)
+ {
+ return new MXMLFlexJSEmitter(out);
+ }
+
+ @Override
+ public IMXMLBlockWalker createMXMLWalker(IASProject project,
+ List<ICompilerProblem> errors, IMXMLEmitter mxmlEmitter,
+ IASEmitter asEmitter, IBlockWalker asBlockWalker)
+ {
+ MXMLBlockWalker walker = new MXMLFlexJSBlockWalker(errors, project,
+ mxmlEmitter, asEmitter, asBlockWalker);
+
+ ASNodeSwitch asStrategy = new ASNodeSwitch(
+ (IBlockVisitor) asBlockWalker);
+ walker.setASStrategy(asStrategy);
+
+ MXMLNodeSwitch mxmlStrategy = new MXMLNodeSwitch(walker);
+ walker.setMXMLStrategy(mxmlStrategy);
+
+ return walker;
+ }
+
+ @Override
+ public IDocEmitter createDocEmitter(IASEmitter emitter)
+ {
+ return new JSGoogDocEmitter((IJSEmitter) emitter);
+ }
+
+ @Override
+ public IJSEmitter createEmitter(FilterWriter out)
+ {
+ IJSEmitter emitter = new JSFlexJSEmitter(out);
+ emitter.setDocEmitter(createDocEmitter(emitter));
+ return emitter;
+ }
+
+ @Override
+ public IJSWriter createMXMLWriter(IASProject project,
+ List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
+ boolean enableDebug)
+ {
+ return new MXMLWriter(project, problems, compilationUnit, enableDebug);
+ }
+
+ @Override
+ public JSTarget createTarget(IASProject project, ITargetSettings settings,
+ ITargetProgressMonitor monitor)
+ {
+ return new FlexJSTarget(project, settings, monitor);
+ }
+
+ @Override
+ public MXMLFlexJSPublisher createPublisher(IASProject project,
+ List<ICompilerProblem> errors, Configuration config)
+ {
+ return new MXMLFlexJSPublisher(config, (FlexJSProject) project);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSSWCBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSSWCBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSSWCBackend.java
new file mode 100644
index 0000000..45bc336
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSSWCBackend.java
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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.driver.mxml.flexjs;
+
+import java.io.FilterWriter;
+import java.util.List;
+
+import org.apache.flex.compiler.codegen.IDocEmitter;
+import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.codegen.js.IJSWriter;
+import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.flexjs.JSFlexJSEmitter;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitter;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLWriter;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSEmitter;
+import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
+import org.apache.flex.compiler.internal.driver.mxml.MXMLBackend;
+import org.apache.flex.compiler.internal.targets.FlexJSSWCTarget;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
+import org.apache.flex.compiler.internal.visitor.mxml.MXMLNodeSwitch;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.visitor.IBlockVisitor;
+import org.apache.flex.compiler.visitor.IBlockWalker;
+import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
+
+/**
+ * A concrete implementation of the {@link IBackend} API where the
+ * {@link MXMLBlockWalker} is used to traverse the {@link IMXMLFileNode} AST.
+ *
+ * @author Erik de Bruin
+ */
+public class MXMLFlexJSSWCBackend extends MXMLBackend
+{
+
+ @Override
+ public Configurator createConfigurator()
+ {
+ return new Configurator(JSGoogConfiguration.class);
+ }
+
+ @Override
+ public IMXMLEmitter createMXMLEmitter(FilterWriter out)
+ {
+ return new MXMLFlexJSEmitter(out);
+ }
+
+ @Override
+ public IMXMLBlockWalker createMXMLWalker(IASProject project,
+ List<ICompilerProblem> errors, IMXMLEmitter mxmlEmitter,
+ IASEmitter asEmitter, IBlockWalker asBlockWalker)
+ {
+ MXMLBlockWalker walker = new MXMLFlexJSBlockWalker(errors, project,
+ mxmlEmitter, asEmitter, asBlockWalker);
+
+ ASNodeSwitch asStrategy = new ASNodeSwitch(
+ (IBlockVisitor) asBlockWalker);
+ walker.setASStrategy(asStrategy);
+
+ MXMLNodeSwitch mxmlStrategy = new MXMLNodeSwitch(walker);
+ walker.setMXMLStrategy(mxmlStrategy);
+
+ return walker;
+ }
+
+ @Override
+ public IDocEmitter createDocEmitter(IASEmitter emitter)
+ {
+ return new JSGoogDocEmitter((IJSEmitter) emitter);
+ }
+
+ @Override
+ public IJSEmitter createEmitter(FilterWriter out)
+ {
+ IJSEmitter emitter = new JSFlexJSEmitter(out);
+ emitter.setDocEmitter(createDocEmitter(emitter));
+ return emitter;
+ }
+
+ @Override
+ public IJSWriter createMXMLWriter(IASProject project,
+ List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
+ boolean enableDebug)
+ {
+ return new MXMLWriter(project, problems, compilationUnit, enableDebug);
+ }
+
+ @Override
+ public JSTarget createTarget(IASProject project, ITargetSettings settings,
+ ITargetProgressMonitor monitor)
+ {
+ return new FlexJSSWCTarget(project, settings, monitor);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/jsc/MXMLJSCJSBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/jsc/MXMLJSCJSBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/jsc/MXMLJSCJSBackend.java
new file mode 100644
index 0000000..18a0388
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/jsc/MXMLJSCJSBackend.java
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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.driver.mxml.jsc;
+
+import java.io.FilterWriter;
+import java.util.List;
+
+import org.apache.flex.compiler.codegen.IDocEmitter;
+import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.codegen.js.IJSWriter;
+import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jsc.JSCJSEmitter;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLWriter;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.jsc.MXMLJSCJSEmitter;
+import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
+import org.apache.flex.compiler.internal.driver.mxml.flexjs.MXMLFlexJSBackend;
+import org.apache.flex.compiler.internal.targets.FlexJSTarget;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
+import org.apache.flex.compiler.internal.visitor.mxml.MXMLNodeSwitch;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.visitor.IBlockVisitor;
+import org.apache.flex.compiler.visitor.IBlockWalker;
+import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
+
+/**
+ * A concrete implementation of the {@link IBackend} API where the
+ * {@link MXMLBlockWalker} is used to traverse the {@link IMXMLFileNode} AST.
+ *
+ * @author Erik de Bruin
+ */
+public class MXMLJSCJSBackend extends MXMLFlexJSBackend
+{
+
+ @Override
+ public Configurator createConfigurator()
+ {
+ return new Configurator(JSGoogConfiguration.class);
+ }
+
+ @Override
+ public IMXMLEmitter createMXMLEmitter(FilterWriter out)
+ {
+ return new MXMLJSCJSEmitter(out);
+ }
+
+ @Override
+ public IMXMLBlockWalker createMXMLWalker(IASProject project,
+ List<ICompilerProblem> errors, IMXMLEmitter mxmlEmitter,
+ IASEmitter asEmitter, IBlockWalker asBlockWalker)
+ {
+ MXMLBlockWalker walker = new MXMLFlexJSBlockWalker(errors, project,
+ mxmlEmitter, asEmitter, asBlockWalker);
+
+ ASNodeSwitch asStrategy = new ASNodeSwitch(
+ (IBlockVisitor) asBlockWalker);
+ walker.setASStrategy(asStrategy);
+
+ MXMLNodeSwitch mxmlStrategy = new MXMLNodeSwitch(walker);
+ walker.setMXMLStrategy(mxmlStrategy);
+
+ return walker;
+ }
+
+ @Override
+ public IDocEmitter createDocEmitter(IASEmitter emitter)
+ {
+ return new JSGoogDocEmitter((IJSEmitter) emitter);
+ }
+
+ @Override
+ public IJSEmitter createEmitter(FilterWriter out)
+ {
+ IJSEmitter emitter = new JSCJSEmitter(out);
+ emitter.setDocEmitter(createDocEmitter(emitter));
+ return emitter;
+ }
+
+ @Override
+ public IJSWriter createMXMLWriter(IASProject project,
+ List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
+ boolean enableDebug)
+ {
+ return new MXMLWriter(project, problems, compilationUnit, enableDebug);
+ }
+
+ @Override
+ public JSTarget createTarget(IASProject project, ITargetSettings settings,
+ ITargetProgressMonitor monitor)
+ {
+ return new FlexJSTarget(project, settings, monitor);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/jsc/MXMLJSCJSSWCBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/jsc/MXMLJSCJSSWCBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/jsc/MXMLJSCJSSWCBackend.java
new file mode 100644
index 0000000..3657c7e
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/jsc/MXMLJSCJSSWCBackend.java
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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.driver.mxml.jsc;
+
+import java.io.FilterWriter;
+import java.util.List;
+
+import org.apache.flex.compiler.codegen.IDocEmitter;
+import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.codegen.js.IJSWriter;
+import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.jsc.JSCJSEmitter;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLWriter;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.jsc.MXMLJSCJSEmitter;
+import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
+import org.apache.flex.compiler.internal.driver.mxml.MXMLBackend;
+import org.apache.flex.compiler.internal.targets.FlexJSSWCTarget;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
+import org.apache.flex.compiler.internal.visitor.mxml.MXMLNodeSwitch;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.visitor.IBlockVisitor;
+import org.apache.flex.compiler.visitor.IBlockWalker;
+import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
+
+/**
+ * A concrete implementation of the {@link IBackend} API where the
+ * {@link MXMLBlockWalker} is used to traverse the {@link IMXMLFileNode} AST.
+ *
+ * @author Erik de Bruin
+ */
+public class MXMLJSCJSSWCBackend extends MXMLBackend
+{
+
+ @Override
+ public Configurator createConfigurator()
+ {
+ return new Configurator(JSGoogConfiguration.class);
+ }
+
+ @Override
+ public IMXMLEmitter createMXMLEmitter(FilterWriter out)
+ {
+ return new MXMLJSCJSEmitter(out);
+ }
+
+ @Override
+ public IMXMLBlockWalker createMXMLWalker(IASProject project,
+ List<ICompilerProblem> errors, IMXMLEmitter mxmlEmitter,
+ IASEmitter asEmitter, IBlockWalker asBlockWalker)
+ {
+ MXMLBlockWalker walker = new MXMLFlexJSBlockWalker(errors, project,
+ mxmlEmitter, asEmitter, asBlockWalker);
+
+ ASNodeSwitch asStrategy = new ASNodeSwitch(
+ (IBlockVisitor) asBlockWalker);
+ walker.setASStrategy(asStrategy);
+
+ MXMLNodeSwitch mxmlStrategy = new MXMLNodeSwitch(walker);
+ walker.setMXMLStrategy(mxmlStrategy);
+
+ return walker;
+ }
+
+ @Override
+ public IDocEmitter createDocEmitter(IASEmitter emitter)
+ {
+ return new JSGoogDocEmitter((IJSEmitter) emitter);
+ }
+
+ @Override
+ public IJSEmitter createEmitter(FilterWriter out)
+ {
+ IJSEmitter emitter = new JSCJSEmitter(out);
+ emitter.setDocEmitter(createDocEmitter(emitter));
+ return emitter;
+ }
+
+ @Override
+ public IJSWriter createMXMLWriter(IASProject project,
+ List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
+ boolean enableDebug)
+ {
+ return new MXMLWriter(project, problems, compilationUnit, enableDebug);
+ }
+
+ @Override
+ public JSTarget createTarget(IASProject project, ITargetSettings settings,
+ ITargetProgressMonitor monitor)
+ {
+ return new FlexJSSWCTarget(project, settings, monitor);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
new file mode 100644
index 0000000..f69d499
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSBackend.java
@@ -0,0 +1,132 @@
+/*
+ *
+ * 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.driver.mxml.vf2js;
+
+import java.io.FilterWriter;
+import java.util.List;
+
+import org.apache.flex.compiler.codegen.IDocEmitter;
+import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.codegen.js.IJSWriter;
+import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.driver.IPublisher;
+import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSEmitter;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLWriter;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.vf2js.MXMLVF2JSEmitter;
+import org.apache.flex.compiler.internal.codegen.mxml.vf2js.MXMLVF2JSPublisher;
+import org.apache.flex.compiler.internal.driver.js.vf2js.JSVF2JSConfiguration;
+import org.apache.flex.compiler.internal.driver.mxml.MXMLBackend;
+import org.apache.flex.compiler.internal.projects.FlexJSProject;
+import org.apache.flex.compiler.internal.targets.FlexJSTarget;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
+import org.apache.flex.compiler.internal.visitor.mxml.MXMLNodeSwitch;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.visitor.IBlockVisitor;
+import org.apache.flex.compiler.visitor.IBlockWalker;
+import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
+
+/**
+ * A concrete implementation of the {@link IBackend} API where the
+ * {@link MXMLBlockWalker} is used to traverse the {@link IMXMLFileNode} AST.
+ *
+ * @author Erik de Bruin
+ */
+public class MXMLVF2JSBackend extends MXMLBackend
+{
+
+ @Override
+ public Configurator createConfigurator()
+ {
+ return new Configurator(JSVF2JSConfiguration.class);
+ }
+
+ @Override
+ public IMXMLEmitter createMXMLEmitter(FilterWriter out)
+ {
+ return new MXMLVF2JSEmitter(out);
+ }
+
+ @Override
+ public IMXMLBlockWalker createMXMLWalker(IASProject project,
+ List<ICompilerProblem> errors, IMXMLEmitter mxmlEmitter,
+ IASEmitter asEmitter, IBlockWalker asBlockWalker)
+ {
+ MXMLBlockWalker walker = new MXMLFlexJSBlockWalker(errors, project,
+ mxmlEmitter, asEmitter, asBlockWalker);
+
+ ASNodeSwitch asStrategy = new ASNodeSwitch(
+ (IBlockVisitor) asBlockWalker);
+ walker.setASStrategy(asStrategy);
+
+ MXMLNodeSwitch mxmlStrategy = new MXMLNodeSwitch(walker);
+ walker.setMXMLStrategy(mxmlStrategy);
+
+ return walker;
+ }
+
+ @Override
+ public IDocEmitter createDocEmitter(IASEmitter emitter)
+ {
+ return new JSVF2JSDocEmitter((IJSEmitter) emitter);
+ }
+
+ @Override
+ public IJSEmitter createEmitter(FilterWriter out)
+ {
+ IJSEmitter emitter = new JSVF2JSEmitter(out);
+ emitter.setDocEmitter(createDocEmitter(emitter));
+ return emitter;
+ }
+
+ @Override
+ public IJSWriter createMXMLWriter(IASProject project,
+ List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
+ boolean enableDebug)
+ {
+ return new MXMLWriter(project, problems, compilationUnit, enableDebug);
+ }
+
+ @Override
+ public JSTarget createTarget(IASProject project, ITargetSettings settings,
+ ITargetProgressMonitor monitor)
+ {
+ return new FlexJSTarget(project, settings, monitor);
+ }
+
+ @Override
+ public IPublisher createPublisher(IASProject project,
+ List<ICompilerProblem> errors, Configuration config)
+ {
+ return new MXMLVF2JSPublisher(config, (FlexJSProject) project);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSSWCBackend.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSSWCBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSSWCBackend.java
new file mode 100644
index 0000000..f9390fc
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/vf2js/MXMLVF2JSSWCBackend.java
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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.driver.mxml.vf2js;
+
+import java.io.FilterWriter;
+import java.util.List;
+
+import org.apache.flex.compiler.codegen.IDocEmitter;
+import org.apache.flex.compiler.codegen.as.IASEmitter;
+import org.apache.flex.compiler.codegen.js.IJSEmitter;
+import org.apache.flex.compiler.codegen.js.IJSWriter;
+import org.apache.flex.compiler.codegen.mxml.IMXMLEmitter;
+import org.apache.flex.compiler.config.Configurator;
+import org.apache.flex.compiler.driver.IBackend;
+import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSDocEmitter;
+import org.apache.flex.compiler.internal.codegen.js.vf2js.JSVF2JSEmitter;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.MXMLWriter;
+import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSBlockWalker;
+import org.apache.flex.compiler.internal.codegen.mxml.vf2js.MXMLVF2JSEmitter;
+import org.apache.flex.compiler.internal.driver.js.vf2js.JSVF2JSConfiguration;
+import org.apache.flex.compiler.internal.driver.mxml.MXMLBackend;
+import org.apache.flex.compiler.internal.targets.FlexJSSWCTarget;
+import org.apache.flex.compiler.internal.targets.JSTarget;
+import org.apache.flex.compiler.internal.visitor.as.ASNodeSwitch;
+import org.apache.flex.compiler.internal.visitor.mxml.MXMLNodeSwitch;
+import org.apache.flex.compiler.problems.ICompilerProblem;
+import org.apache.flex.compiler.projects.IASProject;
+import org.apache.flex.compiler.targets.ITargetProgressMonitor;
+import org.apache.flex.compiler.targets.ITargetSettings;
+import org.apache.flex.compiler.tree.mxml.IMXMLFileNode;
+import org.apache.flex.compiler.units.ICompilationUnit;
+import org.apache.flex.compiler.visitor.IBlockVisitor;
+import org.apache.flex.compiler.visitor.IBlockWalker;
+import org.apache.flex.compiler.visitor.mxml.IMXMLBlockWalker;
+
+/**
+ * A concrete implementation of the {@link IBackend} API where the
+ * {@link MXMLBlockWalker} is used to traverse the {@link IMXMLFileNode} AST.
+ *
+ * @author Erik de Bruin
+ */
+public class MXMLVF2JSSWCBackend extends MXMLBackend
+{
+
+ @Override
+ public Configurator createConfigurator()
+ {
+ return new Configurator(JSVF2JSConfiguration.class);
+ }
+
+ @Override
+ public IMXMLEmitter createMXMLEmitter(FilterWriter out)
+ {
+ return new MXMLVF2JSEmitter(out);
+ }
+
+ @Override
+ public IMXMLBlockWalker createMXMLWalker(IASProject project,
+ List<ICompilerProblem> errors, IMXMLEmitter mxmlEmitter,
+ IASEmitter asEmitter, IBlockWalker asBlockWalker)
+ {
+ MXMLBlockWalker walker = new MXMLFlexJSBlockWalker(errors, project,
+ mxmlEmitter, asEmitter, asBlockWalker);
+
+ ASNodeSwitch asStrategy = new ASNodeSwitch(
+ (IBlockVisitor) asBlockWalker);
+ walker.setASStrategy(asStrategy);
+
+ MXMLNodeSwitch mxmlStrategy = new MXMLNodeSwitch(walker);
+ walker.setMXMLStrategy(mxmlStrategy);
+
+ return walker;
+ }
+
+ @Override
+ public IDocEmitter createDocEmitter(IASEmitter emitter)
+ {
+ return new JSVF2JSDocEmitter((IJSEmitter) emitter);
+ }
+
+ @Override
+ public IJSEmitter createEmitter(FilterWriter out)
+ {
+ IJSEmitter emitter = new JSVF2JSEmitter(out);
+ emitter.setDocEmitter(createDocEmitter(emitter));
+ return emitter;
+ }
+
+ @Override
+ public IJSWriter createMXMLWriter(IASProject project,
+ List<ICompilerProblem> problems, ICompilationUnit compilationUnit,
+ boolean enableDebug)
+ {
+ return new MXMLWriter(project, problems, compilationUnit, enableDebug);
+ }
+
+ @Override
+ public JSTarget createTarget(IASProject project, ITargetSettings settings,
+ ITargetProgressMonitor monitor)
+ {
+ return new FlexJSSWCTarget(project, settings, monitor);
+ }
+}
http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/c3dce49f/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
new file mode 100644
index 0000000..e0173d2
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/graph/GoogDepsWriter.java
@@ -0,0 +1,682 @@
+/*
+ *
+ * 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.graph;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
+import java.util.Set;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.flex.compiler.clients.problems.ProblemQuery;
+import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
+import org.apache.flex.compiler.internal.driver.js.goog.JSGoogConfiguration;
+import org.apache.flex.compiler.problems.FileNotFoundProblem;
+import org.apache.flex.swc.ISWC;
+import org.apache.flex.swc.ISWCFileEntry;
+
+import com.google.common.io.Files;
+
+public class GoogDepsWriter {
+
+ public GoogDepsWriter(File outputFolder, String mainClassName, JSGoogConfiguration config, List<ISWC> swcs)
+ {
+ this.outputFolderPath = outputFolder.getAbsolutePath();
+ this.mainName = mainClassName;
+ removeCirculars = config.getRemoveCirculars();
+ otherPaths = config.getSDKJSLib();
+ otherPaths.add(new File(outputFolder.getParent(), "flexjs/FlexJS/src").getPath());
+ this.swcs = swcs;
+ for (ISWC swc : swcs)
+ {
+ System.out.println("using SWC: " + swc.getSWCFile().getAbsolutePath());
+ }
+ }
+
+ private ProblemQuery problems;
+ private String outputFolderPath;
+ private String mainName;
+ private List<String> otherPaths;
+ private List<ISWC> swcs;
+ private boolean removeCirculars = false;
+ private boolean problemsFound = false;
+ private ArrayList<GoogDep> dps;
+
+ private HashMap<String,GoogDep> depMap = new HashMap<String,GoogDep>();
+ private HashMap<String, String> requireMap = new HashMap<String, String>();
+
+ public ArrayList<String> getListOfFiles(ProblemQuery problems) throws InterruptedException
+ {
+ problemsFound = false;
+ this.problems = problems;
+
+ if (dps == null)
+ {
+ buildDB();
+ dps = sort(mainName);
+ }
+ ArrayList<String> files = new ArrayList<String>();
+ for (GoogDep gd : dps)
+ {
+ files.add(gd.filePath);
+ }
+ return files;
+ }
+
+ public boolean generateDeps(ProblemQuery problems, StringBuilder depsFileData) throws InterruptedException, FileNotFoundException
+ {
+ problemsFound = false;
+ this.problems = problems;
+ if (dps == null)
+ {
+ buildDB();
+ dps = sort(mainName);
+ }
+ String outString = "// generated by FalconJX" + "\n";
+ int n = dps.size();
+ for (int i = n - 1; i >= 0; i--)
+ {
+ GoogDep gd = dps.get(i);
+ if (!isGoogClass(gd.className))
+ {
+ String s = "goog.addDependency('";
+ s += relativePath(gd.filePath);
+ s += "', ['";
+ s += gd.className;
+ s += "'], [";
+ s += getDependencies(gd.deps);
+ s += "]);\n";
+ outString += s;
+ }
+ }
+ depsFileData.append(outString);
+ return !problemsFound;
+ }
+
+ private boolean isGoogClass(String className)
+ {
+ return className.startsWith("goog.");
+ }
+
+ private void buildDB()
+ {
+ addDeps(mainName);
+ }
+
+ public ArrayList<String> filePathsInOrder = new ArrayList<String>();
+
+ public ArrayList<String> additionalHTML = new ArrayList<String>();
+
+ private HashMap<String, GoogDep> visited = new HashMap<String, GoogDep>();
+
+ private ArrayList<GoogDep> sort(String rootClassName)
+ {
+ ArrayList<GoogDep> arr = new ArrayList<GoogDep>();
+ GoogDep current = depMap.get(rootClassName);
+ sortFunction(current, arr);
+ return arr;
+ }
+
+ private void sortFunction(GoogDep current, ArrayList<GoogDep> arr)
+ {
+ visited.put(current.className, current);
+
+ filePathsInOrder.add(current.filePath);
+ if (removeCirculars)
+ removeCirculars(current);
+ System.out.println("Dependencies calculated for '" + current.filePath + "'");
+
+ ArrayList<String> deps = current.deps;
+ for (String className : deps)
+ {
+ if (!visited.containsKey(className) && !isGoogClass(className))
+ {
+ GoogDep gd = depMap.get(className);
+ sortFunction(gd, arr);
+ }
+ }
+ arr.add(current);
+ }
+
+ private void addDeps(String className)
+ {
+ if (depMap.containsKey(className) || isGoogClass(className))
+ return;
+
+ // build goog dependency list
+ GoogDep gd = new GoogDep();
+ gd.className = className;
+ gd.filePath = getFilePath(className);
+ if(gd.filePath.isEmpty()) {
+ // TODO Send a ICompilerProblem instead.
+ throw new RuntimeException("Unable to find JavaScript filePath for class: " + className);
+ }
+ depMap.put(gd.className, gd);
+ List<String> fileLines;
+ try {
+ fileLines = Files.readLines(new File(gd.filePath), Charset.defaultCharset());
+ FileInfo fi = getFileInfo(fileLines, className);
+ gd.fileInfo = fi;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ ArrayList<String> deps = getDirectDependencies(gd.filePath);
+
+ gd.deps = new ArrayList<String>();
+ for (String dep : deps)
+ {
+ if (gd.fileInfo.impls != null && gd.fileInfo.impls.contains(dep))
+ {
+ if (!requireMap.containsKey(dep))
+ {
+ // we are first class that needs this dependency
+ // at prototype initialization time
+ requireMap.put(dep, className);
+ }
+ }
+ else if (depMap.containsKey(dep) && !isGoogClass(dep))
+ {
+ continue;
+ }
+ gd.deps.add(dep);
+ }
+ for (String dep : deps)
+ {
+ addDeps(dep);
+ }
+ }
+
+ void removeCirculars(GoogDep gd)
+ {
+ String className = gd.className;
+
+ // remove requires that would cause circularity
+ try
+ {
+ List<String> fileLines = Files.readLines(new File(gd.filePath), Charset.defaultCharset());
+ ArrayList<String> finalLines = new ArrayList<String>();
+
+ FileInfo fi = gd.fileInfo;
+ int suppressCount = 0;
+ int i = 0;
+ for (String line : fileLines)
+ {
+ if (i < fi.constructorLine)
+ {
+ int c = line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+ if (c > -1)
+ {
+ int c2 = line.indexOf(")");
+ String s = line.substring(c + 14, c2 - 1);
+ if (gd.fileInfo.impls == null || !gd.fileInfo.impls.contains(s))
+ {
+ if (requireMap.containsKey(s) && requireMap.get(s) != className)
+ {
+ // don't add the require if some class needs it at static initialization
+ // time and that class is not this class
+ suppressCount++;
+ System.out.println(gd.filePath + " removing circular (static): " + s);
+ continue;
+ }
+ else if (!gd.deps.contains(s))
+ {
+ // someone require'd this class
+ suppressCount++;
+ System.out.println(gd.filePath + " removing circular: " + s);
+ continue;
+ }
+ }
+ }
+ }
+ finalLines.add(line);
+ i++;
+ }
+ if (suppressCount > 0)
+ {
+ if (fi.suppressLine > 0)
+ {
+ if (fi.suppressLine < fi.constructorLine)
+ {
+ String line = finalLines.get(fi.suppressLine);
+ int c = line.indexOf("@suppress {");
+ if (c > -1)
+ {
+ if (!line.contains("missingRequire"))
+ {
+ line = line.substring(0, c) + "@suppress {missingRequire|" + line.substring(c + 11);
+ finalLines.remove(fi.suppressLine);
+ finalLines.add(fi.suppressLine, line);
+ }
+ }
+ else
+ System.out.println("Confused by @suppress in " + className);
+ }
+ else
+ {
+ // the @suppress was for the constructor or some other thing so add a top-level
+ // @suppress
+ if (fi.fileoverviewLine > -1)
+ {
+ // there is already a fileOverview but no @suppress
+ finalLines.add(fi.fileoverviewLine + 1, " * @suppress {missingRequire}");
+ }
+ else if (fi.googProvideLine > -1)
+ {
+ finalLines.add(fi.googProvideLine, " */");
+ finalLines.add(fi.googProvideLine, " * @suppress {missingRequire}");
+ finalLines.add(fi.googProvideLine, " * @fileoverview");
+ finalLines.add(fi.googProvideLine, "/**");
+ }
+ else
+ {
+ System.out.println("Confused by @suppress in " + className);
+ }
+ }
+ }
+ else
+ {
+ if (fi.fileoverviewLine > -1)
+ {
+ // there is already a fileoverview but no @suppress
+ finalLines.add(fi.fileoverviewLine + 1, " * @suppress {missingRequire}");
+ }
+ else if (fi.googProvideLine > -1)
+ {
+ finalLines.add(fi.googProvideLine, " */");
+ finalLines.add(fi.googProvideLine, " * @suppress {missingRequire}");
+ finalLines.add(fi.googProvideLine, " * @fileoverview");
+ finalLines.add(fi.googProvideLine, "/**");
+ }
+ else
+ {
+ System.out.println("Confused by @suppress in " + className);
+ }
+ }
+ }
+ File file = new File(gd.filePath);
+ PrintWriter out = new PrintWriter(new FileWriter(file));
+ for (String s : finalLines)
+ {
+ out.println(s);
+ }
+ out.close();
+
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ FileInfo getFileInfo(List<String> lines, String className)
+ {
+ FileInfo fi = new FileInfo();
+
+ int n = lines.size();
+ fi.constructorLine = n;
+ fi.suppressLine = -1;
+ fi.fileoverviewLine = -1;
+ fi.googProvideLine = -1;
+ for (int i = 0; i < n; i++)
+ {
+ String line = lines.get(i);
+ int c2;
+ int c = line.indexOf("goog.inherits");
+ if (c > -1)
+ {
+ String inheritLine = "";
+ while (true)
+ {
+ inheritLine += line;
+ c2 = line.indexOf(")");
+ if (c2 > -1)
+ break;
+ else
+ {
+ i++;
+ line = lines.get(i);
+ }
+ }
+ c = inheritLine.indexOf(",");
+ c2 = inheritLine.indexOf(")");
+ fi.inherits = inheritLine.substring(c + 1, c2).trim();
+ return fi;
+ }
+ else
+ {
+ c = line.indexOf("@constructor");
+ if (c > -1)
+ fi.constructorLine = i;
+ else
+ {
+ c = line.indexOf("@interface");
+ if (c > -1)
+ fi.constructorLine = i;
+ else
+ {
+ c = line.indexOf("@suppress");
+ if (c > -1)
+ fi.suppressLine = i;
+ else
+ {
+ c = line.indexOf("@fileoverview");
+ if (c > -1)
+ fi.fileoverviewLine = i;
+ else
+ {
+ c = line.indexOf("goog.provide");
+ if (c > -1)
+ fi.googProvideLine = i;
+ else
+ {
+ c = line.indexOf("@implements");
+ if (c > -1)
+ {
+ if (fi.impls == null)
+ fi.impls = new ArrayList<String>();
+ c2 = line.indexOf("}", c);
+ String impl = line.substring(c + 13, c2);
+ fi.impls.add(impl);
+ }
+ else
+ {
+ c = line.indexOf("@extends");
+ if (c > -1)
+ {
+ if (fi.impls == null)
+ fi.impls = new ArrayList<String>();
+ c2 = line.indexOf("}", c);
+ String impl = line.substring(c + 10, c2);
+ fi.impls.add(impl);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return fi;
+ }
+
+ String getFilePath(String className)
+ {
+ String fn;
+ File destFile;
+ File f;
+
+ String classPath = className.replace(".", File.separator);
+ // special case app names with underscores, but hope that
+ // no other class names have underscores in them
+ if (className.equals(mainName))
+ classPath = className;
+
+ fn = outputFolderPath + File.separator + classPath + ".js";
+ f = new File(fn);
+ if (f.exists())
+ {
+ return fn;
+ }
+
+ for (String otherPath : otherPaths)
+ {
+ fn = otherPath + File.separator + classPath + ".js";
+ f = new File(fn);
+ if (f.exists())
+ {
+ fn = outputFolderPath + File.separator + classPath + ".js";
+ destFile = new File(fn);
+ // copy source to output
+ try {
+ FileUtils.copyFile(f, destFile);
+
+ // (erikdebruin) copy class assets files
+ if (className.contains("org.apache.flex"))
+ {
+ File assetsDir = new File(f.getParentFile(), "assets");
+ if (assetsDir.exists())
+ {
+ String nameOfClass = className.substring(className.lastIndexOf('_') + 1);
+
+ File[] assetsList = assetsDir.listFiles();
+ assert assetsList != null;
+ for (File assetFile : assetsList) {
+ String assetFileName = assetFile.getName();
+
+ if (assetFile.isFile() && assetFileName.indexOf(nameOfClass) == 0) {
+ String pathOfClass;
+ pathOfClass = className.substring(0, className.lastIndexOf('_'));
+ pathOfClass = pathOfClass.replace(".", File.separator);
+
+ destFile = new File(outputFolderPath +
+ File.separator + pathOfClass +
+ File.separator + "assets" +
+ File.separator + assetFileName);
+ FileUtils.copyFile(assetFile, destFile);
+
+ destFile = new File(outputFolderPath.replace("js-debug", "js-release") +
+ File.separator + pathOfClass +
+ File.separator + "assets" +
+ File.separator + assetFileName);
+ FileUtils.copyFile(assetFile, destFile);
+
+ System.out.println("Copied assets of the '" + nameOfClass + "' class");
+ }
+ }
+ }
+ }
+ } catch (IOException e) {
+ System.out.println("Error copying file for class: " + className);
+ }
+ return fn;
+ }
+ }
+
+ String fwdClassPath = className.replace(".", "/");
+ String bckClassPath = className.replace(".", "\\");
+ for (ISWC swc : swcs)
+ {
+ ISWCFileEntry fileEntry = swc.getFile("js/src/" + fwdClassPath + ".js");
+ if (fileEntry == null)
+ fileEntry = swc.getFile("js/out/" + fwdClassPath + ".js");
+ if (fileEntry == null)
+ fileEntry = swc.getFile("js/src/" + bckClassPath + ".js");
+ if (fileEntry == null)
+ fileEntry = swc.getFile("js/out/" + bckClassPath + ".js");
+ if (fileEntry == null)
+ fileEntry = swc.getFile("js\\src\\" + bckClassPath + ".js");
+ if (fileEntry == null)
+ fileEntry = swc.getFile("js\\out\\" + bckClassPath + ".js");
+ if (fileEntry != null)
+ {
+ fn = outputFolderPath + File.separator + classPath + ".js";
+ destFile = new File(fn);
+ // copy source to output
+ try {
+ InputStream inStream = fileEntry.createInputStream();
+ OutputStream outStream = FileUtils.openOutputStream(destFile);
+ byte[] b = new byte[1024 * 1024];
+ int bytes_read;
+ while ((bytes_read = inStream.read(b)) != -1)
+ {
+ outStream.write(b, 0, bytes_read);
+ }
+ outStream.flush();
+ outStream.close();
+ inStream.close();
+
+ // (erikdebruin) copy class assets files
+ if (className.contains("org.apache.flex"))
+ {
+ Map<String, ISWCFileEntry> includedfiles = swc.getFiles();
+ Set<String> includedList = includedfiles.keySet();
+ for (String included : includedList)
+ {
+ if (included.contains(".png") ||
+ included.contains(".gif") ||
+ included.contains(".jpg") ||
+ included.contains(".json"))
+ {
+ fileEntry = includedfiles.get(included);
+ String assetName = outputFolderPath + File.separator + included;
+ File assetFile = new File(assetName);
+ inStream = fileEntry.createInputStream();
+ outStream = FileUtils.openOutputStream(assetFile);
+ b = new byte[inStream.available()];
+ inStream.read(b);
+ outStream.write(b);
+ inStream.close();
+ outStream.flush();
+ outStream.close();
+ System.out.println("Copied asset " + assetName);
+ }
+ }
+ }
+ } catch (IOException e) {
+ System.out.println("Error copying file for class: " + className);
+ }
+ return fn;
+ }
+ }
+
+ System.out.println("Could not find file for class: " + className);
+ problems.add(new FileNotFoundProblem(className));
+ problemsFound = true;
+ return "";
+ }
+
+ private ArrayList<String> getDirectDependencies(String fn)
+ {
+ ArrayList<String> deps = new ArrayList<String>();
+
+ FileInputStream fis;
+ try {
+ fis = new FileInputStream(fn);
+ Scanner scanner = new Scanner(fis, "UTF-8");
+ boolean inInjectHTML = false;
+ while (scanner.hasNextLine())
+ {
+ String s = scanner.nextLine();
+ if (s.contains("goog.inherits"))
+ break;
+ if (inInjectHTML)
+ {
+ int c = s.indexOf("</inject_html>");
+ if (c > -1)
+ {
+ inInjectHTML = false;
+ continue;
+ }
+ }
+ if (inInjectHTML)
+ {
+ s = s.trim();
+ if (s.startsWith("*"))
+ s = s.substring(1);
+ additionalHTML.add(s);
+ continue;
+ }
+ int c = s.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+ if (c > -1)
+ {
+ int c2 = s.indexOf(")");
+ s = s.substring(c + 14, c2 - 1);
+ deps.add(s);
+ }
+ c = s.indexOf("<inject_html>");
+ if (c > -1)
+ {
+ inInjectHTML = true;
+ }
+ }
+ scanner.close();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ return deps;
+ }
+
+ private String getDependencies(ArrayList<String> deps)
+ {
+ String s = "";
+ for (String dep : deps)
+ {
+ if (s.length() > 0)
+ {
+ s += ", ";
+ }
+ s += "'" + dep + "'";
+ }
+ return s;
+ }
+
+ String relativePath(String path)
+ {
+ if (path.indexOf(outputFolderPath) == 0)
+ {
+ path = path.replace(outputFolderPath, "../../..");
+ }
+ else
+ {
+ for (String otherPath : otherPaths)
+ {
+ if (path.indexOf(otherPath) == 0)
+ {
+ path = path.replace(otherPath, "../../..");
+
+ }
+ }
+ }
+ // paths are actually URIs and always have forward slashes
+ path = path.replace('\\', '/');
+ return path;
+ }
+ private class GoogDep
+ {
+ public String filePath;
+ public String className;
+ public ArrayList<String> deps;
+ public FileInfo fileInfo;
+
+ }
+
+ @SuppressWarnings( "unused" )
+ private class FileInfo
+ {
+ public String inherits;
+ public ArrayList<String> impls;
+ public int constructorLine;
+ public int suppressLine;
+ public int fileoverviewLine;
+ public int googProvideLine;
+ }
+}