You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ma...@apache.org on 2021/01/05 18:06:36 UTC

[netbeans] branch master updated: [NETBEANS-5214] Fix handling of global values

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

matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 1198c66  [NETBEANS-5214] Fix handling of global values
     new bb97001  Merge pull request #2639 from matthiasblaesing/netbeans-5214
1198c66 is described below

commit 1198c6642612764150ad3d0911bf8f437eef6601
Author: Matthias Bläsing <mb...@doppel-helix.eu>
AuthorDate: Mon Jan 4 20:58:49 2021 +0100

    [NETBEANS-5214] Fix handling of global values
    
    When checking the global values, the input state needs to be reset after
    the possible values are checked. Before this change the right grammar
    element was found, but then could not be processed, because the state
    of the input was already changed by the checking.
---
 .../modules/css/lib/api/properties/GrammarResolver.java       |  2 +-
 .../modules/css/lib/api/properties/GrammarResolverTest.java   | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/GrammarResolver.java b/ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/GrammarResolver.java
index df83498..5e1e898 100644
--- a/ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/GrammarResolver.java
+++ b/ide/css.lib/src/org/netbeans/modules/css/lib/api/properties/GrammarResolver.java
@@ -287,12 +287,12 @@ public class GrammarResolver {
                     InputState beforeState = createInputState();
                     List<ValueGrammarElement> matching = new ArrayList<>(globalValues.length);
                     for(ValueGrammarElement vge: globalValues) {
-                        backupInputState(beforeState);
                         if(processValue(vge)) {
                             matching.add(vge);
                         } else {
                             valueNotAccepted(vge);
                         }
+                        backupInputState(beforeState);
                     }
                     if(! matching.isEmpty()) {
                         boolean matched = processValue(matching.get(0));
diff --git a/ide/css.lib/test/unit/src/org/netbeans/modules/css/lib/api/properties/GrammarResolverTest.java b/ide/css.lib/test/unit/src/org/netbeans/modules/css/lib/api/properties/GrammarResolverTest.java
index 28151e7..0ad38e5 100644
--- a/ide/css.lib/test/unit/src/org/netbeans/modules/css/lib/api/properties/GrammarResolverTest.java
+++ b/ide/css.lib/test/unit/src/org/netbeans/modules/css/lib/api/properties/GrammarResolverTest.java
@@ -852,4 +852,15 @@ public class GrammarResolverTest extends CssTestBase {
     }
     
 
+    public void testGlobalValuesAreResolved() {
+        String grammar = "a";
+
+        // Baseline matching - validate, that grammar works
+        assertResolve(grammar, "a");
+
+        // Verify that the global values unset, inherit and initial are matched
+        assertResolve(grammar, "unset");
+        assertResolve(grammar, "inherit");
+        assertResolve(grammar, "initial");
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists