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

neilcsmith 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 c847b1f  [NETBEANS-3989]:Code Modifications related to finalisation of 
TextBlocks in JDK15
     new 33e4d51  Merge pull request #2136 from Mohan-Sarilla/netbeans-3989
c847b1f is described below

commit c847b1fb1c50f44a6b0204149343f87f907cf979
Author: Mohan-Sarilla <sarilla.mohana...@oracle.com>
AuthorDate: Thu May 14 11:15:35 2020 +0530

    [NETBEANS-3989]:Code Modifications related to finalisation of TextBlocks in 
JDK15
---
 .../netbeans/modules/java/hints/jdk/ConvertToTextBlock.java  |  6 +++++-
 .../modules/java/hints/jdk/ConvertToTextBlockTest.java       | 12 ++++--------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git 
a/java/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToTextBlock.java
 
b/java/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToTextBlock.java
index 35f0917..cda4485 100644
--- 
a/java/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToTextBlock.java
+++ 
b/java/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToTextBlock.java
@@ -24,8 +24,10 @@ import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
 import java.util.List;
+import javax.lang.model.SourceVersion;
 import org.netbeans.api.java.queries.CompilerOptionsQuery;
 import org.netbeans.api.java.source.CompilationInfo;
+import org.netbeans.modules.java.hints.errors.Utilities;
 import org.netbeans.spi.editor.hints.ErrorDescription;
 import org.netbeans.spi.editor.hints.Fix;
 import org.netbeans.spi.java.hints.ConstraintVariableType;
@@ -45,10 +47,12 @@ import org.openide.util.NbBundle.Messages;
 })
 public class ConvertToTextBlock {
 
+private static final int TEXT_BLOCK_PREVIEW_JDK_VERSION = 14;
+
     @TriggerTreeKind(Kind.PLUS)
     @Messages("ERR_ConvertToTextBlock=Can be converted to text block")
     public static ErrorDescription computeWarning(HintContext ctx) {
-        if 
(!CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview"))
+        if (Utilities.isJDKVersionLower(TEXT_BLOCK_PREVIEW_JDK_VERSION) && 
!CompilerOptionsQuery.getOptions(ctx.getInfo().getFileObject()).getArguments().contains("--enable-preview"))
             return null;
         if (ctx.getPath().getParentPath() != null && 
getTextOrNull(ctx.getPath().getParentPath()) != null) {
             return null;
diff --git 
a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToTextBlockTest.java
 
b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToTextBlockTest.java
index 91749bd..9289ec2 100644
--- 
a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToTextBlockTest.java
+++ 
b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/jdk/ConvertToTextBlockTest.java
@@ -27,7 +27,7 @@ public class ConvertToTextBlockTest {
     @Test
     public void testFixWorking() throws Exception {
         try {
-            SourceVersion.valueOf("RELEASE_13");
+            SourceVersion.valueOf("RELEASE_15");
         } catch (IllegalArgumentException ex) {
             //OK, skip test
             return ;
@@ -42,7 +42,6 @@ public class ConvertToTextBlockTest {
                        "    }\n" +
                        "}\n")
                 .sourceLevel(SourceVersion.latest().name())
-                .options("--enable-preview")
                 .run(ConvertToTextBlock.class)
                 .findWarning("3:30-3:37:verifier:" + 
Bundle.ERR_ConvertToTextBlock())
                 .applyFix()
@@ -62,7 +61,7 @@ public class ConvertToTextBlockTest {
     @Test
     public void testNewLineAtEnd() throws Exception {
         try {
-            SourceVersion.valueOf("RELEASE_13");
+            SourceVersion.valueOf("RELEASE_15");
         } catch (IllegalArgumentException ex) {
             //OK, skip test
             return ;
@@ -77,7 +76,6 @@ public class ConvertToTextBlockTest {
                        "    }\n" +
                        "}\n")
                 .sourceLevel(SourceVersion.latest().name())
-                .options("--enable-preview")
                 .run(ConvertToTextBlock.class)
                 .findWarning("3:30-3:37:verifier:" + 
Bundle.ERR_ConvertToTextBlock())
                 .applyFix()
@@ -98,7 +96,7 @@ public class ConvertToTextBlockTest {
     @Test
     public void testNewLinesAtEnd() throws Exception {
         try {
-            SourceVersion.valueOf("RELEASE_13");
+            SourceVersion.valueOf("RELEASE_15");
         } catch (IllegalArgumentException ex) {
             //OK, skip test
             return ;
@@ -113,7 +111,6 @@ public class ConvertToTextBlockTest {
                        "    }\n" +
                        "}\n")
                 .sourceLevel(SourceVersion.latest().name())
-                .options("--enable-preview")
                 .run(ConvertToTextBlock.class)
                 .findWarning("3:30-3:37:verifier:" + 
Bundle.ERR_ConvertToTextBlock())
                 .applyFix()
@@ -134,7 +131,7 @@ public class ConvertToTextBlockTest {
     @Test
     public void testOnlyLiterals() throws Exception {
         try {
-            SourceVersion.valueOf("RELEASE_13");
+            SourceVersion.valueOf("RELEASE_15");
         } catch (IllegalArgumentException ex) {
             //OK, skip test
             return ;
@@ -148,7 +145,6 @@ public class ConvertToTextBlockTest {
                        "    private int c() { return 0; }\n" +
                        "}\n")
                 .sourceLevel(SourceVersion.latest().name())
-                .options("--enable-preview")
                 .run(ConvertToTextBlock.class)
                 .assertWarnings();
     }


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

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

Reply via email to