flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [32/50] git commit: [flex-falcon] [refs/heads/master] - compiler-jx: moved conversion of node module names with dashes to camel case from ExternCConfiguration into a utility class so that it may be used elsewhere
Date Mon, 26 Jun 2017 15:45:12 GMT
compiler-jx: moved conversion of node module names with dashes to camel case from ExternCConfiguration
into a utility class so that it may be used elsewhere


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

Branch: refs/heads/master
Commit: 693af591303e6b514d4eee042fb76abed6487fda
Parents: 80990a8
Author: Josh Tynjala <joshtynjala@apache.org>
Authored: Fri May 26 14:58:56 2017 -0700
Committer: Josh Tynjala <joshtynjala@apache.org>
Committed: Fri May 26 14:58:56 2017 -0700

----------------------------------------------------------------------
 .../compiler/clients/ExternCConfiguration.java  | 11 +-----
 .../apache/flex/compiler/utils/NodeJSUtils.java | 41 ++++++++++++++++++++
 2 files changed, 43 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/693af591/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
index d3118e9..67bc814 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/clients/ExternCConfiguration.java
@@ -38,6 +38,7 @@ import org.apache.flex.compiler.internal.config.annotations.Arguments;
 import org.apache.flex.compiler.internal.config.annotations.Config;
 import org.apache.flex.compiler.internal.config.annotations.InfiniteArguments;
 import org.apache.flex.compiler.internal.config.annotations.Mapping;
+import org.apache.flex.compiler.utils.NodeJSUtils;
 import org.apache.flex.utils.FilenameNormalization;
 
 public class ExternCConfiguration extends Configuration
@@ -324,15 +325,7 @@ public class ExternCConfiguration extends Configuration
         for (String module : namedModules)
         {
             //convert to camel case
-            String camelCaseModule = module;
-            int moduleIndex = camelCaseModule.indexOf("-");
-            while (moduleIndex != -1 && moduleIndex < camelCaseModule.length()
- 1)
-            {
-                camelCaseModule = camelCaseModule.substring(0, moduleIndex)
-                        + camelCaseModule.substring(moduleIndex + 1, moduleIndex + 2).toUpperCase()
-                        + camelCaseModule.substring(moduleIndex + 2);
-                moduleIndex = camelCaseModule.indexOf("-");
-            }
+            String camelCaseModule = NodeJSUtils.convertFromDashesToCamelCase(module);
             if(basePackageName.length() == 0)
             {
                 if (classReference.getBaseName().equals(camelCaseModule))

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/693af591/compiler-jx/src/main/java/org/apache/flex/compiler/utils/NodeJSUtils.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/utils/NodeJSUtils.java b/compiler-jx/src/main/java/org/apache/flex/compiler/utils/NodeJSUtils.java
new file mode 100644
index 0000000..608b3ac
--- /dev/null
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/utils/NodeJSUtils.java
@@ -0,0 +1,41 @@
+/*
+ *
+ *  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.utils;
+
+public class NodeJSUtils
+{
+    /**
+     * Converts the name of a node module with dashes into a version in camel
+     * case so that it can be a valid identifier.
+     */
+    public static String convertFromDashesToCamelCase(String moduleNameWithDashes)
+    {
+        String camelCaseModule = moduleNameWithDashes;
+        int moduleIndex = camelCaseModule.indexOf("-");
+        while (moduleIndex != -1 && moduleIndex < camelCaseModule.length() - 1)
+        {
+            camelCaseModule = camelCaseModule.substring(0, moduleIndex)
+                    + camelCaseModule.substring(moduleIndex + 1, moduleIndex + 2).toUpperCase()
+                    + camelCaseModule.substring(moduleIndex + 2);
+            moduleIndex = camelCaseModule.indexOf("-");
+        }
+        return camelCaseModule;
+    }
+}


Mime
View raw message