incubator-flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gordonsm...@apache.org
Subject svn commit: r1407665 - /incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/css/CSSDocument.java
Date Fri, 09 Nov 2012 22:02:55 GMT
Author: gordonsmith
Date: Fri Nov  9 22:02:54 2012
New Revision: 1407665

URL: http://svn.apache.org/viewvc?rev=1407665&view=rev
Log:
Falcon: Fixed Java exception in CSSDocument when two @namespace directives have the same prefix.
(FLEX-33241)

Modified:
    incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/css/CSSDocument.java

Modified: incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/css/CSSDocument.java
URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/css/CSSDocument.java?rev=1407665&r1=1407664&r2=1407665&view=diff
==============================================================================
--- incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/css/CSSDocument.java
(original)
+++ incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/css/CSSDocument.java
Fri Nov  9 22:02:54 2012
@@ -20,7 +20,9 @@
 package org.apache.flex.compiler.internal.css;
 
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.antlr.runtime.CharStream;
 import org.antlr.runtime.CommonTokenStream;
@@ -38,11 +40,9 @@ import org.apache.flex.compiler.internal
 import org.apache.flex.compiler.internal.css.CSSTree;
 import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.compiler.problems.UnexpectedExceptionProblem;
-import com.google.common.base.Function;
 import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
 
 /**
  * Implementation of a CSS model.
@@ -96,25 +96,6 @@ public class CSSDocument extends CSSNode
     }
 
     /**
-     * A function that computes the key of a {@code ICSSNamespaceDefinition} for
-     * the lookup table of namespaces. The key of each namespace definition is
-     * its prefix name. The default namespace prefix is an empty string.
-     */
-    private static final Function<CSSNamespaceDefinition, String> KEY_GENERATOR =
-            new Function<CSSNamespaceDefinition, String>()
-    {
-        @Override
-        public String apply(CSSNamespaceDefinition ns)
-        {
-            final String prefix = ns.getPrefix();
-            if (prefix == null)
-                return DEFAULT_NAMESPACE_SHORT_NAME;
-            else
-                return prefix;
-        }
-    };
-
-    /**
      * Create a root CSS definition.
      * 
      * @param rules CSS rules
@@ -137,7 +118,15 @@ public class CSSDocument extends CSSNode
         this.rules = new ImmutableList.Builder<ICSSRule>().addAll(rules).build();
         this.namespaces = new ImmutableList.Builder<ICSSNamespaceDefinition>().addAll(namespaces).build();
         this.fontFaces = new ImmutableList.Builder<ICSSFontFace>().addAll(fontFaces).build();
-        this.namespacesLookup = Maps.uniqueIndex(namespaces, KEY_GENERATOR);
+        
+        Map<String, CSSNamespaceDefinition> namespaceMap = new HashMap<String, CSSNamespaceDefinition>();
+        for (CSSNamespaceDefinition namespace : namespaces)
+        {
+            final String prefix = namespace.getPrefix();
+            final String key = prefix != null ? prefix : DEFAULT_NAMESPACE_SHORT_NAME;
+            namespaceMap.put(key, namespace);
+        }
+        this.namespacesLookup = ImmutableMap.copyOf(namespaceMap);
 
         // setup tree
         children.add(new CSSTypedNode(CSSModelTreeType.NAMESPACE_LIST, this.namespaces));



Mime
View raw message