matthiasblaesing commented on code in PR #8605:
URL: https://github.com/apache/netbeans/pull/8605#discussion_r2404550198
##########
java/java.hints/src/org/netbeans/modules/java/hints/errors/CreateElement.java:
##########
@@ -101,6 +101,17 @@ public final class CreateElement implements
ErrorRule<Void> {
private static final int PRIO_TESTSOURCEGROUP = 500;
private static final int PRIO_MAINSOURCEGROUP = 1000;
private static final int PRIO_INNER = 2000;
+
+ /**
+ * Helps to prevent issue 8594, trying to create a method when return type
is not given
+ * by using var as the placeholder for the type at the call site.
+ * @param type the TypeMirror that specifies the type info
+ * @return true if fit for create method, false otherwise
+ */
+ private static boolean hasKnownReturnType(TypeMirror type) {
+ if (type==null) return true; // for constructors
+ return type.getKind() != TypeKind.NONE; // none is insufficient info
+ }
Review Comment:
I suggest slightly altered wording and fixing the missing braces for the if
construct
```suggestion
/**
* Helps to prevent github issue 8594, trying to create a method when
return
* type can't be determined because var is used as placeholder for the
type
* at the call
* site.
* @param type the TypeMirror that specifies the type info
* @return true if fit for create method, false otherwise
*/
private static boolean hasKnownReturnType(TypeMirror type) {
// for constructors
if (type == null) {
return true;
}
return type.getKind() != TypeKind.NONE; // none is insufficient info
}
```
##########
java/java.hints/test/unit/src/org/netbeans/modules/java/hints/errors/CreateElementTest.java:
##########
@@ -441,6 +441,21 @@ public void test194625() throws Exception {
"CreateConstructorFix:(java.lang.String
string):org.netbeans.test.java.hints.CreateConstructor"
)));
}
+
+ // the test should show that no fix is suggested for a method call where
the return type is using the var.
+
Review Comment:
Please remove unnessary whitespace lines (446, 448, 454) and indent line 456
one level (see methods above)
--
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.
To unsubscribe, e-mail: [email protected]
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