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

mbien 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 4e899fe  Add sourceVersion(int) to rule file utils and deprecate enum 
variant.
     new 0ffa067  Merge pull request #3395 from mbien/sourceversion
4e899fe is described below

commit 4e899fe16c3ffe15f4b1164c1df9e9af8a49ac1c
Author: Michael Bien <[email protected]>
AuthorDate: Sat Jan 1 16:16:22 2022 +0100

    Add sourceVersion(int) to rule file utils and deprecate enum variant.
    
     - version enums cause issues if the enum value can not be resolved
     - using an int as feature version allows using newer hint files on
       older JDKs
     - added LE variant
---
 .../conditionapi/DefaultRuleUtilities.java         | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git 
a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/DefaultRuleUtilities.java
 
b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/DefaultRuleUtilities.java
index 9de9e84..0749db5 100644
--- 
a/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/DefaultRuleUtilities.java
+++ 
b/java/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/DefaultRuleUtilities.java
@@ -46,10 +46,32 @@ public final class DefaultRuleUtilities {
         return matcher.referencedIn(variable, in);
     }
 
+    /**
+     * @deprecated Use {@link #sourceVersionGE(int)} instead.
+     */
+    @Deprecated
     public boolean sourceVersionGE(SourceVersion source) {
         return context.sourceVersion().compareTo(source) >= 0;
     }
 
+    /**
+     * Returns true if the provided feature version is less or equals the
+     * source version of the inspected file.
+     * @see Runtime.Version#feature()
+     */
+    public boolean sourceVersionLE(int feature) {
+        return context.sourceVersion().ordinal() <= feature;
+    }
+
+    /**
+     * Returns true if the provided feature version is greater or equals the
+     * source version of the inspected file.
+     * @see Runtime.Version#feature()
+     */
+    public boolean sourceVersionGE(int feature) {
+        return context.sourceVersion().ordinal() >= feature;
+    }
+
     public boolean hasModifier(Variable variable, Modifier modifier) {
         return context.modifiers(variable).contains(modifier);
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

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

Reply via email to