lahodaj commented on a change in pull request #2222:
URL: https://github.com/apache/netbeans/pull/2222#discussion_r458638606
##########
File path:
java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
##########
@@ -3930,6 +4136,8 @@ public boolean accept(Element e, TypeMirror t) {
}
};
for (TypeElement e :
controller.getElementUtilities().getGlobalTypes(acceptor)) {
+ if (e.getQualifiedName().toString().equals(JAVA_LANG_RECORD) &&
env.getController().getSourceVersion().compareTo(SOURCE_VERSION_RELEASE_14) <
0)
Review comment:
Sorry, but I am not sure we should filter out j.l.Record here. We are
not filtering any other element AFAIK, so why Record?
##########
File path:
java/java.completion/test/unit/data/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/1.8/typesRecordLocalMembersAndVars.pass
##########
@@ -0,0 +1,111 @@
+boolean
+byte
+char
+double
+final
+float
+int
+long
+short
+X
+Y
+AbstractMethodError
+Appendable
+ArithmeticException
+ArrayIndexOutOfBoundsException
+ArrayStoreException
+AssertionError
+AutoCloseable
+Boolean
+BootstrapMethodError
+Byte
+CharSequence
+Character
+Class
+ClassCastException
+ClassCircularityError
+ClassFormatError
+ClassLoader
+ClassNotFoundException
+ClassValue
+CloneNotSupportedException
+Cloneable
+Comparable
+Compiler
+Deprecated
+Double
+Enum
+EnumConstantNotPresentException
+Error
+Exception
+ExceptionInInitializerError
+Float
+FunctionalInterface
+IllegalAccessError
+IllegalAccessException
+IllegalArgumentException
+IllegalMonitorStateException
+IllegalStateException
+IllegalThreadStateException
+IncompatibleClassChangeError
+IndexOutOfBoundsException
+InheritableThreadLocal
+InstantiationError
+InstantiationException
+Integer
+InternalError
+InterruptedException
+Iterable
+LinkageError
+Long
+Math
+NegativeArraySizeException
+NoClassDefFoundError
+NoSuchFieldError
+NoSuchFieldException
+NoSuchMethodError
+NoSuchMethodException
+NullPointerException
+Number
+NumberFormatException
+Object
+OutOfMemoryError
+Override
+Package
+Process
+ProcessBuilder
+Readable
+Record
Review comment:
I am unsure about the "Record" here. This should be the golden file when
the runtime platform is JDK 8. JDK 8 does not have j.l.Record, right?
(I would also suggest to minimize the number of golden outputs, if/as
feasible.)
##########
File path:
java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
##########
@@ -3008,10 +3027,194 @@ private void insideBreakOrContinue(Env env) throws
IOException {
}
}
}
+
+ private void addClassTypes(final Env env, DeclaredType baseType) throws
IOException{
Review comment:
The baseType parameter is unused. Suggest to either pass it to addTypes,
or drop it.
##########
File path:
java/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
##########
@@ -3008,10 +3027,194 @@ private void insideBreakOrContinue(Env env) throws
IOException {
}
}
}
+
+ private void addClassTypes(final Env env, DeclaredType baseType) throws
IOException{
+ EnumSet<ElementKind> classKinds = EnumSet.of(CLASS, INTERFACE, ENUM,
ANNOTATION_TYPE, TYPE_PARAMETER);
+ if (isRecordSupported(env, null)) {
+ classKinds.add(TreeShims.getRecordKind());
+ }
+ addTypes(env, classKinds, null);
+ }
+
+ private boolean isRecordSupported(final Env env, String prefix) {
Review comment:
I think this method's name and content do not really match - it is not
only "isRecordSupported", but also "and is the prefix a prefix of 'record''. I
would suggest to drop the second concern from this method. Many callers don't
need the prefix check. I counted just two callers that really need to check the
prefix (for many, the prefix check happens automatically later), and I think it
would be cleaner for them to call the prefix check explicitly.
Also, for discussion - should there be a preview enablement test here as
well?
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
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