You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2020/01/16 13:35:44 UTC

[GitHub] [netbeans] singh-akhilesh opened a new pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

singh-akhilesh opened a new pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877
 
 
   Jira ref : https://issues.apache.org/jira/browse/NETBEANS-3604

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r367894265
 
 

 ##########
 File path: java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/SemanticHighlighterBase.java
 ##########
 @@ -573,6 +582,27 @@ private void addModifiers(Element decl, Collection<ColoringAttributes> c) {
             return null;
         }
 
+        private boolean isRecordComponent(ElementKind kind) {
+            return "RECORD_COMPONENT".equals(kind.name());
+        }
+
+        private Element toRecordComponent(Element el) {
 
 Review comment:
   Can TreeShims.toRecordComponent be used here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r368236494
 
 

 ##########
 File path: java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/SemanticHighlighterBase.java
 ##########
 @@ -573,6 +582,27 @@ private void addModifiers(Element decl, Collection<ColoringAttributes> c) {
             return null;
         }
 
+        private boolean isRecordComponent(ElementKind kind) {
+            return "RECORD_COMPONENT".equals(kind.name());
+        }
+
+        private Element toRecordComponent(Element el) {
 
 Review comment:
   Comment addressed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r368236839
 
 

 ##########
 File path: java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/Utilities.java
 ##########
 @@ -557,7 +557,7 @@ private static int findBodyStartImpl(CompilationInfo info, Tree cltree, Compilat
     
     public static int findBodyStart(final CompilationInfo info, final Tree cltree, final CompilationUnitTree cu, final SourcePositions positions, final Document doc) {
         Kind kind = cltree.getKind();
-        if (!TreeUtilities.CLASS_TREE_KINDS.contains(kind) && kind != Kind.METHOD)
+        if (!TreeUtilities.CLASS_TREE_KINDS.contains(kind) && kind != Kind.METHOD && !cltree.getKind().toString().equals("RECORD"))
 
 Review comment:
   Tree.Kind.RECORD is a final Enumset, So adding RECORD here as a preview feature would result a compilation failure for the versions below 14. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r368236351
 
 

 ##########
 File path: java/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/DetectorTest.java
 ##########
 @@ -508,6 +508,62 @@ public void testIncDecReading230408() throws Exception {
         performTest("IncDecReading230408");
     }
 
+    public void testRecord1() throws Exception {
+        //TODO: check records are available, skip if they are not.
 
 Review comment:
   Comment addressed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r368236469
 
 

 ##########
 File path: java/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java
 ##########
 @@ -986,6 +1020,14 @@ public Void visitTypeParameter(TypeParameterElement e, Boolean highlightName) {
             return null;
         }
         
+        @Override
+        public Void visitUnknown(Element e, Boolean p) {
+            if (TreeShims.isRecordComponent(e)) {
+                return visitVariable((VariableElement) e, p);
+            }
+            return super.visitUnknown(e, p); //To change body of generated methods, choose Tools | Templates.
 
 Review comment:
   Comment addressed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r367893354
 
 

 ##########
 File path: java/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
 ##########
 @@ -1282,4 +1297,223 @@ private static boolean hasPatterns() {
             return false;
         }
     }
+    
+    public void testRecords1() throws Exception {
+//        try {
 
 Review comment:
   This should be (presumably?) uncomentted. (Dtto the other occurrences below.)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r368236362
 
 

 ##########
 File path: java/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/TestBase.java
 ##########
 @@ -35,6 +35,7 @@
 import java.util.Collection;
 import java.util.Comparator;
 import java.util.EnumSet;
+import java.util.Iterator;
 
 Review comment:
   Comment addressed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r367892316
 
 

 ##########
 File path: java/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java
 ##########
 @@ -381,6 +385,35 @@ public static Context resolveContext(CompilationInfo controller, Document doc, i
                             el = e;
                         }
                     }
+                    if (el != null && el.getKind() == ElementKind.METHOD) {
+                        for (Element peer : el.getEnclosingElement().getEnclosedElements()) {
+                            if (peer.getKind().name().contains("RECORD_COMPONENT")) {
+                                try {
+                                    Class<?> recordComponent = Class.forName("javax.lang.model.element.RecordComponentElement", true, VariableTree.class.getClassLoader());
+                                    Method getAccessor = recordComponent.getDeclaredMethod("getAccessor");
+                                    Method getRecordComponents = TypeElement.class.getDeclaredMethod("getRecordComponents");
 
 Review comment:
   I wonder if the reflection should be separated into TreeShims. But this can wait.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r367893063
 
 

 ##########
 File path: java/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java
 ##########
 @@ -986,6 +1020,14 @@ public Void visitTypeParameter(TypeParameterElement e, Boolean highlightName) {
             return null;
         }
         
+        @Override
+        public Void visitUnknown(Element e, Boolean p) {
+            if (TreeShims.isRecordComponent(e)) {
+                return visitVariable((VariableElement) e, p);
+            }
+            return super.visitUnknown(e, p); //To change body of generated methods, choose Tools | Templates.
 
 Review comment:
   Ideally comments like "//To change..." should be deleted.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r368236480
 
 

 ##########
 File path: java/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
 ##########
 @@ -1282,4 +1297,223 @@ private static boolean hasPatterns() {
             return false;
         }
     }
+    
+    public void testRecords1() throws Exception {
+//        try {
 
 Review comment:
   Comment addressed.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
singh-akhilesh commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r368236457
 
 

 ##########
 File path: java/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java
 ##########
 @@ -381,6 +385,35 @@ public static Context resolveContext(CompilationInfo controller, Document doc, i
                             el = e;
                         }
                     }
+                    if (el != null && el.getKind() == ElementKind.METHOD) {
+                        for (Element peer : el.getEnclosingElement().getEnclosedElements()) {
+                            if (peer.getKind().name().contains("RECORD_COMPONENT")) {
+                                try {
+                                    Class<?> recordComponent = Class.forName("javax.lang.model.element.RecordComponentElement", true, VariableTree.class.getClassLoader());
+                                    Method getAccessor = recordComponent.getDeclaredMethod("getAccessor");
+                                    Method getRecordComponents = TypeElement.class.getDeclaredMethod("getRecordComponents");
 
 Review comment:
   It would be good if we wait and fix this at later stage.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] jlahoda merged pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
jlahoda merged pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r367891142
 
 

 ##########
 File path: java/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/Utilities.java
 ##########
 @@ -557,7 +557,7 @@ private static int findBodyStartImpl(CompilationInfo info, Tree cltree, Compilat
     
     public static int findBodyStart(final CompilationInfo info, final Tree cltree, final CompilationUnitTree cu, final SourcePositions positions, final Document doc) {
         Kind kind = cltree.getKind();
-        if (!TreeUtilities.CLASS_TREE_KINDS.contains(kind) && kind != Kind.METHOD)
+        if (!TreeUtilities.CLASS_TREE_KINDS.contains(kind) && kind != Kind.METHOD && !cltree.getKind().toString().equals("RECORD"))
 
 Review comment:
   Unless this was tried already, and rejected for some reason, I would recommend to add Tree.Kind.RECORD into TreeUtilities.CLASS_TREE_KINDS. The purpose of that constant is to keep all kinds that map to ClassTree.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r367891641
 
 

 ##########
 File path: java/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/DetectorTest.java
 ##########
 @@ -508,6 +508,62 @@ public void testIncDecReading230408() throws Exception {
         performTest("IncDecReading230408");
     }
 
+    public void testRecord1() throws Exception {
+        //TODO: check records are available, skip if they are not.
 
 Review comment:
   There should be a SourceVersion check, or something along those lines, and the test case should be skipped if the current javac does not support records. Otherwise, the test will fail when running e.g. with nb-javac without records. (Dtto the other occurrence below.)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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


[GitHub] [netbeans] lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"

Posted by GitBox <gi...@apache.org>.
lahodaj commented on a change in pull request #1877: [NETBEANS-3604]Supports for Records (JEP 359) in JDK-14"
URL: https://github.com/apache/netbeans/pull/1877#discussion_r367891807
 
 

 ##########
 File path: java/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/TestBase.java
 ##########
 @@ -35,6 +35,7 @@
 import java.util.Collection;
 import java.util.Comparator;
 import java.util.EnumSet;
+import java.util.Iterator;
 
 Review comment:
   Ideally, unnecessary changes should be undone.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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

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