This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit f2de1acef5dfa6ef6a10547cc0d53f4f75a07caa
Author: Josh Tynjala <[email protected]>
AuthorDate: Wed Oct 8 09:43:49 2025 -0700

    CSS: fix 'not' not being allowed as an identifier by moving the check for 
it into CSSTree with a new problem class for unknown pseudo-classes in selectors
    
    This will also make it easier to add new pseudo-classes in the future.
---
 .../org/apache/royale/compiler/internal/css/CSS.g  |  8 ++---
 .../apache/royale/compiler/internal/css/CSSTree.g  | 18 ++++++++--
 .../problems/CSSUnknownPseudoClassProblem.java     | 39 ++++++++++++++++++++++
 compiler/src/test/build.xml                        |  1 +
 4 files changed, 58 insertions(+), 8 deletions(-)

diff --git 
a/compiler/src/main/antlr3/org/apache/royale/compiler/internal/css/CSS.g 
b/compiler/src/main/antlr3/org/apache/royale/compiler/internal/css/CSS.g
index 64f295df8..633d412af 100644
--- a/compiler/src/main/antlr3/org/apache/royale/compiler/internal/css/CSS.g
+++ b/compiler/src/main/antlr3/org/apache/royale/compiler/internal/css/CSS.g
@@ -385,8 +385,7 @@ simpleSelectorFraction
 condition
     :   ( DOT^ ID
         | HASH_WORD 
-        | COLON^ NOT ARGUMENTS 
-        | COLON^ ID 
+        | COLON^ ID ARGUMENTS?
         | DOUBLE_COLON^ ID 
         | attributeSelector
         ) 
@@ -612,15 +611,12 @@ FUNCTIONS : '-moz-linear-gradient'
           | 'saturate'
           | 'sepia'
           ;
-/**
+/*
  * Removed for now this two since conflicts with same keywords in old fucntion
  * This will be fixed later  
  *        | 'grayscale'
  *        | 'opacity'
  */
-NOT
-    :  'not'
-    ;
 
 /** 
  * Matches an alpha filter - alpha(opacity=70)
diff --git 
a/compiler/src/main/antlr3/org/apache/royale/compiler/internal/css/CSSTree.g 
b/compiler/src/main/antlr3/org/apache/royale/compiler/internal/css/CSSTree.g
index 070096355..aeacfb8f9 100644
--- a/compiler/src/main/antlr3/org/apache/royale/compiler/internal/css/CSSTree.g
+++ b/compiler/src/main/antlr3/org/apache/royale/compiler/internal/css/CSSTree.g
@@ -61,6 +61,7 @@ import org.apache.royale.compiler.css.*;
 import org.apache.royale.compiler.problems.CSSParserProblem;
 import org.apache.royale.compiler.problems.ICompilerProblem;
 import org.apache.royale.compiler.problems.CSSStrictFlexSyntaxProblem;
+import org.apache.royale.compiler.problems.CSSUnknownPseudoClassProblem;
 
 }
 
@@ -126,6 +127,15 @@ public void displayStrictFlexSyntaxError(String syntax, 
CommonTree tree)
         tree.getLine(), tree.getCharPositionInLine());
     problems.add(new CSSStrictFlexSyntaxProblem(location, syntax));
 }
+
+public void displayUnknownPseudoClassError(String pseudoClassName, CommonTree 
tree)
+{
+    final ISourceLocation location = new SourceLocation(
+        getSourceName(),
+        -1, -1, // TODO Need start and end info from CSS
+        tree.getLine(), tree.getCharPositionInLine());
+    problems.add(new CSSUnknownPseudoClassProblem(location, pseudoClassName));
+}
 }
 
 stylesheet
@@ -351,12 +361,16 @@ conditionSelector
 }
     :   ^(DOT c=ID)   { type = ConditionType.CLASS; name = $c.text; }  
     |   HASH_WORD   { type = ConditionType.ID; name = 
$HASH_WORD.text.substring(1); }
-    |   ^(COLON NOT arg=ARGUMENTS)
+    |   ^(COLON s=ID arg=ARGUMENTS)
         {
             if (strictFlexCSS)
             {
                 // Flex didn't support the CSS :not() pseudo-class
-                displayStrictFlexSyntaxError($COLON.text + $NOT.text, $NOT);
+                displayStrictFlexSyntaxError($COLON.text + $s.text, $s);
+            }
+            if (!$s.text.equals("not"))
+            {
+                displayUnknownPseudoClassError($s.text, $s);
             }
             type = ConditionType.NOT;
             name = $arg.text;
diff --git 
a/compiler/src/main/java/org/apache/royale/compiler/problems/CSSUnknownPseudoClassProblem.java
 
b/compiler/src/main/java/org/apache/royale/compiler/problems/CSSUnknownPseudoClassProblem.java
new file mode 100644
index 000000000..5da7ac7bb
--- /dev/null
+++ 
b/compiler/src/main/java/org/apache/royale/compiler/problems/CSSUnknownPseudoClassProblem.java
@@ -0,0 +1,39 @@
+/*
+ *
+ *  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.royale.compiler.problems;
+
+import org.apache.royale.compiler.common.ISourceLocation;
+
+/**
+ * CSS defines a set of valid pseudo-classes.
+ */
+public final class CSSUnknownPseudoClassProblem extends CSSProblem
+{
+    public static final String DESCRIPTION =
+        "Unknown pseudo-class '${pseudoClassName}' in CSS selector";
+
+    public CSSUnknownPseudoClassProblem(ISourceLocation location, String 
pseudoClassName)
+    {
+        super(location);
+        this.pseudoClassName = pseudoClassName;
+    }
+    
+    public final String pseudoClassName;
+}
diff --git a/compiler/src/test/build.xml b/compiler/src/test/build.xml
index c5d078e68..f508beb73 100644
--- a/compiler/src/test/build.xml
+++ b/compiler/src/test/build.xml
@@ -318,6 +318,7 @@
             <batchtest todir="${compiler}/target/junit-reports">
                 <fileset dir="${compiler}/target/test-classes">
                     <include name="**/*Tests.class"/>
+                    <!-- <exclude name="as/**"/> -->
                     <exclude name="f/**"/>
                     <exclude name="mxml/tags/**"/>
                     <exclude name="properties/**"/>

Reply via email to