You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2017/06/26 15:34:57 UTC

[09/36] git commit: [flex-falcon] [refs/heads/develop] - allow pruning of Class Selectors

allow pruning of Class Selectors


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

Branch: refs/heads/develop
Commit: 55ca0b2d5c6b4892afba73fcbcba2ef3bac7ce42
Parents: ad8fb20
Author: Alex Harui <ah...@apache.org>
Authored: Mon May 15 15:12:21 2017 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Mon May 15 15:12:21 2017 -0700

----------------------------------------------------------------------
 .../css/semantics/CSSSemanticAnalyzer.java      | 36 +++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/55ca0b2d/compiler/src/main/java/org/apache/flex/compiler/internal/css/semantics/CSSSemanticAnalyzer.java
----------------------------------------------------------------------
diff --git a/compiler/src/main/java/org/apache/flex/compiler/internal/css/semantics/CSSSemanticAnalyzer.java b/compiler/src/main/java/org/apache/flex/compiler/internal/css/semantics/CSSSemanticAnalyzer.java
index e2f244c..d34cdee 100644
--- a/compiler/src/main/java/org/apache/flex/compiler/internal/css/semantics/CSSSemanticAnalyzer.java
+++ b/compiler/src/main/java/org/apache/flex/compiler/internal/css/semantics/CSSSemanticAnalyzer.java
@@ -36,6 +36,7 @@ import org.apache.flex.compiler.css.ICSSProperty;
 import org.apache.flex.compiler.css.ICSSPropertyValue;
 import org.apache.flex.compiler.css.ICSSRule;
 import org.apache.flex.compiler.css.ICSSSelector;
+import org.apache.flex.compiler.css.ICSSSelectorCondition;
 import org.apache.flex.compiler.definitions.IClassDefinition;
 import org.apache.flex.compiler.definitions.IDefinition;
 import org.apache.flex.compiler.definitions.metadata.IMetaTag;
@@ -385,7 +386,11 @@ public class CSSSemanticAnalyzer
             for (final ICSSSelector selector : rule.getSelectorGroup())
             {
                 if (isWildcardSelector(selector))
-                    return true;
+                {
+                	String selName = getOptionalSelectorName(selector);
+                	if (selName == null) return true;
+                    return qnames.contains(selName);
+                }
                 final String qname = resolvedSelectors.get(selector);
                 if (qnames.contains(qname))
                     return true;
@@ -514,6 +519,35 @@ public class CSSSemanticAnalyzer
     }
 
     /**
+     * Check if the selector is a optional class selector.
+     * An optional class selector is a class selector
+     * with the name opt_qname_otherstuff.
+     * 
+     * The output will not contain the selector if the
+     * class identified by qname is not in the output.
+     * 
+     * @param selector CSS selector
+     * @return True if the selector is a "optional" selector.
+     */
+    public static String getOptionalSelectorName(ICSSSelector selector)
+    {
+    	ImmutableList<ICSSSelectorCondition> conditions = selector.getConditions();
+    	if (conditions.size() == 0)
+    		return null;
+        final String elementName = conditions.get(0).getValue();
+        if (elementName == null) return null;
+        if (elementName.startsWith("opt_"))
+        {
+        	int c = elementName.indexOf("_", 4);
+        	if (c >= 0)
+        	{
+        		return elementName.substring(4, c).replace("-", ".");
+        		
+        	}
+        }
+        return null;
+    }
+    /**
      * Build a map from QNames to class definitions.
      * 
      * @param classDefinitions Class definitions.