You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ft...@apache.org on 2015/05/30 17:47:18 UTC

git commit: [flex-falcon] [refs/heads/IDEA-FLEX_JS_COMPILER] - Factorized the duplicated confusing and at time unused fixArg function

Repository: flex-falcon
Updated Branches:
  refs/heads/IDEA-FLEX_JS_COMPILER 673da18b1 -> 0585dd385


Factorized the duplicated confusing and at time unused fixArg function


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

Branch: refs/heads/IDEA-FLEX_JS_COMPILER
Commit: 0585dd3856ab21a6debcbc21ac96c2e3bfaa24ff
Parents: 673da18
Author: Frédéric THOMAS <we...@gmail.com>
Authored: Fri May 29 17:11:14 2015 +0100
Committer: Frédéric THOMAS <we...@gmail.com>
Committed: Fri May 29 17:11:14 2015 +0100

----------------------------------------------------------------------
 .../apache/flex/compiler/clients/MXMLJSC.java   | 103 ++++---------------
 .../apache/flex/compiler/clients/COMPJSC.java   |  39 +------
 .../apache/flex/compiler/clients/MXMLJSC.java   |  52 ++--------
 .../apache/flex/utils/ConfigurationUtil.java    |  31 ++++++
 4 files changed, 61 insertions(+), 164 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0585dd38/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java
index d436a3e..b4f5718 100644
--- a/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler.js/src/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -19,38 +19,23 @@
 
 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.PrintStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.javascript.jscomp.*;
+import com.google.javascript.jscomp.Compiler;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.io.output.CountingOutputStream;
-
 import org.apache.flex.compiler.clients.problems.ProblemPrinter;
 import org.apache.flex.compiler.clients.problems.ProblemQuery;
 import org.apache.flex.compiler.clients.problems.WorkspaceProblemFormatter;
 import org.apache.flex.compiler.common.DependencyType;
 import org.apache.flex.compiler.common.VersionInfo;
-import org.apache.flex.compiler.config.CommandLineConfigurator;
-import org.apache.flex.compiler.config.Configuration;
-import org.apache.flex.compiler.config.ConfigurationBuffer;
-import org.apache.flex.compiler.config.ConfigurationValue;
-import org.apache.flex.compiler.config.Configurator;
-import org.apache.flex.compiler.config.ICompilerSettingsConstants;
-import org.apache.flex.compiler.config.RSLSettings;
+import org.apache.flex.compiler.config.*;
 import org.apache.flex.compiler.config.RSLSettings.RSLAndPolicyFileURLPair;
 import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.exceptions.ConfigurationException;
@@ -58,12 +43,7 @@ import org.apache.flex.compiler.exceptions.ConfigurationException.IOError;
 import org.apache.flex.compiler.exceptions.ConfigurationException.MustSpecifyTarget;
 import org.apache.flex.compiler.exceptions.ConfigurationException.OnlyOneSource;
 import org.apache.flex.compiler.filespecs.IFileSpecification;
-import org.apache.flex.compiler.internal.as.codegen.CodeGeneratorManager;
-import org.apache.flex.compiler.internal.as.codegen.JSGeneratingReducer;
-import org.apache.flex.compiler.internal.as.codegen.JSGenerator;
-import org.apache.flex.compiler.internal.as.codegen.JSSharedData;
-import org.apache.flex.compiler.internal.as.codegen.JSWriter;
-import org.apache.flex.compiler.internal.as.codegen.JSWriter.ClosureProblem;
+import org.apache.flex.compiler.internal.as.codegen.*;
 import org.apache.flex.compiler.internal.config.localization.LocalizationManager;
 import org.apache.flex.compiler.internal.definitions.ClassDefinition;
 import org.apache.flex.compiler.internal.driver.IBackend;
@@ -71,11 +51,7 @@ import org.apache.flex.compiler.internal.driver.JSBackend;
 import org.apache.flex.compiler.internal.driver.JSTarget;
 import org.apache.flex.compiler.internal.graph.GoogDepsWriter;
 import org.apache.flex.compiler.internal.graph.GraphMLWriter;
-import org.apache.flex.compiler.internal.projects.CompilerProject;
-import org.apache.flex.compiler.internal.projects.DefinitionPriority;
-import org.apache.flex.compiler.internal.projects.FlexJSProject;
-import org.apache.flex.compiler.internal.projects.FlexProject;
-import org.apache.flex.compiler.internal.projects.ISourceFileHandler;
+import org.apache.flex.compiler.internal.projects.*;
 import org.apache.flex.compiler.internal.projects.DefinitionPriority.BasePriority;
 import org.apache.flex.compiler.internal.resourcebundles.ResourceBundleUtils;
 import org.apache.flex.compiler.internal.scopes.ASProjectScope;
@@ -83,22 +59,14 @@ import org.apache.flex.compiler.internal.scopes.ASProjectScope.DefinitionPromise
 import org.apache.flex.compiler.internal.targets.LinkageChecker;
 import org.apache.flex.compiler.internal.targets.Target;
 import org.apache.flex.compiler.internal.tree.mxml.MXMLClassDefinitionNode;
-import org.apache.flex.compiler.internal.units.ABCCompilationUnit;
-import org.apache.flex.compiler.internal.units.ResourceModuleCompilationUnit;
-import org.apache.flex.compiler.internal.units.SWCCompilationUnit;
-import org.apache.flex.compiler.internal.units.SourceCompilationUnitFactory;
-import org.apache.flex.compiler.internal.units.StyleModuleCompilationUnit;
+import org.apache.flex.compiler.internal.units.*;
 import org.apache.flex.compiler.internal.workspaces.Workspace;
-import org.apache.flex.compiler.problems.ConfigurationProblem;
-import org.apache.flex.compiler.problems.ICompilerProblem;
-import org.apache.flex.compiler.problems.InternalCompilerProblem;
-import org.apache.flex.compiler.problems.UnableToBuildSWFProblem;
-import org.apache.flex.compiler.problems.UnexpectedExceptionProblem;
+import org.apache.flex.compiler.problems.*;
 import org.apache.flex.compiler.projects.ICompilerProject;
 import org.apache.flex.compiler.targets.ISWFTarget;
+import org.apache.flex.compiler.targets.ITarget.TargetType;
 import org.apache.flex.compiler.targets.ITargetReport;
 import org.apache.flex.compiler.targets.ITargetSettings;
-import org.apache.flex.compiler.targets.ITarget.TargetType;
 import org.apache.flex.compiler.tree.as.IASNode;
 import org.apache.flex.compiler.units.ICompilationUnit;
 import org.apache.flex.compiler.units.ICompilationUnit.UnitType;
@@ -106,24 +74,12 @@ import org.apache.flex.compiler.units.requests.IFileScopeRequestResult;
 import org.apache.flex.swc.ISWC;
 import org.apache.flex.swf.ISWF;
 import org.apache.flex.swf.io.ISWFWriter;
-import org.apache.flex.swf.io.OutputBitStream;
 import org.apache.flex.swf.types.Rect;
-import org.apache.flex.utils.FileUtils;
+import org.apache.flex.utils.ConfigurationUtil;
 import org.apache.flex.utils.FilenameNormalization;
 
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.javascript.jscomp.CommandLineRunner;
-import com.google.javascript.jscomp.CompilationLevel;
-import com.google.javascript.jscomp.Compiler;
-import com.google.javascript.jscomp.CompilerOptions;
-import com.google.javascript.jscomp.JSError;
-import com.google.javascript.jscomp.JSSourceFile;
+import java.io.*;
+import java.util.*;
 
 /**
  * The entry-point class for the FalconJS version of mxmlc.
@@ -189,7 +145,7 @@ public class MXMLJSC
         int exitCode = -1;
         try
         {
-            exitCode = _mainNoExit(fixArgs(args), problems);
+            exitCode = _mainNoExit(ConfigurationUtil.fixArgs(args), problems);
         }
         catch (Exception e)
         {
@@ -1509,27 +1465,6 @@ public class MXMLJSC
         return flexHome;
     }
 
-    // workaround for Falcon bug.
-    // Input files with relative paths confuse the algorithm that extracts the root class name.
-
-    protected static String[] fixArgs(final String[] args)
-    {
-        String[] newArgs = args;
-        if (args.length > 1)
-        {
-            String targetPath = args[args.length - 1];
-            if (targetPath.startsWith("."))
-            {
-                targetPath = FileUtils.getTheRealPathBecauseCanonicalizeDoesNotFixCase(new File(targetPath));
-                newArgs = new String[args.length];
-                for (int i = 0; i < args.length - 1; ++i)
-                    newArgs[i] = args[i];
-                newArgs[args.length - 1] = targetPath;
-            }
-        }
-        return newArgs;
-    }
-
     protected JSCommandLineConfiguration getConfiguration()
     {
         if (config instanceof JSCommandLineConfiguration)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0585dd38/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java b/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
index 694e521..7c205a8 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/COMPJSC.java
@@ -19,17 +19,6 @@
 
 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.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
 import org.apache.commons.io.FilenameUtils;
 import org.apache.flex.compiler.codegen.as.IASWriter;
 import org.apache.flex.compiler.driver.IBackend;
@@ -51,11 +40,11 @@ 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.tools.FlexTool;
-import org.apache.flex.utils.FileUtils;
-
 import sun.reflect.generics.reflectiveObjects.NotImplementedException;
 
+import java.io.*;
+import java.util.*;
+
 
 /**
  * @author Erik de Bruin
@@ -421,26 +410,4 @@ public class COMPJSC extends MXMLJSC
     {
         return TargetType.SWC;
     }
-
-    // Workaround for Falcon bug: input files with relative paths confuse the 
-    // algorithm that extracts the root class name.
-    protected static String[] fixArgs(final String[] args)
-    {
-        String[] newArgs = args;
-        if (args.length > 1)
-        {
-            String targetPath = args[args.length - 1];
-            if (targetPath.startsWith("."))
-            {
-                targetPath = FileUtils
-                        .getTheRealPathBecauseCanonicalizeDoesNotFixCase(new File(
-                                targetPath));
-                newArgs = new String[args.length];
-                for (int i = 0; i < args.length - 1; ++i)
-                    newArgs[i] = args[i];
-                newArgs[args.length - 1] = targetPath;
-            }
-        }
-        return newArgs;
-    }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0585dd38/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
----------------------------------------------------------------------
diff --git a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
index 60f9915..759da96 100644
--- a/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
+++ b/compiler.jx/src/org/apache/flex/compiler/clients/MXMLJSC.java
@@ -19,18 +19,9 @@
 
 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.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.flex.compiler.clients.problems.ProblemPrinter;
 import org.apache.flex.compiler.clients.problems.ProblemQuery;
@@ -68,23 +59,18 @@ import org.apache.flex.compiler.internal.targets.JSTarget;
 import org.apache.flex.compiler.internal.units.ResourceModuleCompilationUnit;
 import org.apache.flex.compiler.internal.units.SourceCompilationUnitFactory;
 import org.apache.flex.compiler.internal.workspaces.Workspace;
-import org.apache.flex.compiler.problems.ConfigurationProblem;
-import org.apache.flex.compiler.problems.ICompilerProblem;
-import org.apache.flex.compiler.problems.InternalCompilerProblem;
-import org.apache.flex.compiler.problems.UnableToBuildSWFProblem;
-import org.apache.flex.compiler.problems.UnexpectedExceptionProblem;
+import org.apache.flex.compiler.problems.*;
 import org.apache.flex.compiler.projects.ICompilerProject;
 import org.apache.flex.compiler.targets.ITarget;
 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.tools.FlexTool;
-import org.apache.flex.utils.FileUtils;
+import org.apache.flex.utils.ConfigurationUtil;
 import org.apache.flex.utils.FilenameNormalization;
 
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
+import java.io.*;
+import java.util.*;
 
 /**
  * @author Erik de Bruin
@@ -257,7 +243,7 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
         int exitCode = -1;
         try
         {
-            exitCode = _mainNoExit(fixArgs(args), problems);
+            exitCode = _mainNoExit(ConfigurationUtil.fixArgs(args), problems);
         }
         catch (Exception e)
         {
@@ -802,26 +788,4 @@ public class MXMLJSC implements JSCompilerEntryPoint, ProblemQueryProvider, Flex
     {
         workspace.close();
     }
-
-    // Workaround for Falcon bug: input files with relative paths confuse the 
-    // algorithm that extracts the root class name.
-    protected static String[] fixArgs(final String[] args)
-    {
-        String[] newArgs = args;
-        if (args.length > 1)
-        {
-            String targetPath = args[args.length - 1];
-            if (targetPath.startsWith("."))
-            {
-                targetPath = FileUtils
-                        .getTheRealPathBecauseCanonicalizeDoesNotFixCase(new File(
-                                targetPath));
-                newArgs = new String[args.length];
-                for (int i = 0; i < args.length - 1; ++i)
-                    newArgs[i] = args[i];
-                newArgs[args.length - 1] = targetPath;
-            }
-        }
-        return newArgs;
-    }
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/0585dd38/compiler/src/org/apache/flex/utils/ConfigurationUtil.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/utils/ConfigurationUtil.java b/compiler/src/org/apache/flex/utils/ConfigurationUtil.java
new file mode 100644
index 0000000..8f443c0
--- /dev/null
+++ b/compiler/src/org/apache/flex/utils/ConfigurationUtil.java
@@ -0,0 +1,31 @@
+package org.apache.flex.utils;
+
+import java.io.File;
+
+/**
+ * @author: Frederic Thomas
+ * Date: 29/05/2015
+ * Time: 17:04
+ */
+public class ConfigurationUtil {
+
+    // workaround for Falcon bug.
+    // Input files with relative paths confuse the algorithm that extracts the root class name.
+    public static String[] fixArgs(final String[] args)
+    {
+        String[] newArgs = args;
+        if (args.length > 1)
+        {
+            String targetPath = args[args.length - 1];
+            if (targetPath.startsWith("."))
+            {
+                targetPath = FileUtils.getTheRealPathBecauseCanonicalizeDoesNotFixCase(new File(targetPath));
+                newArgs = new String[args.length];
+                for (int i = 0; i < args.length - 1; ++i)
+                    newArgs[i] = args[i];
+                newArgs[args.length - 1] = targetPath;
+            }
+        }
+        return newArgs;
+    }
+}