jherkel commented on code in PR #9764:
URL: https://github.com/apache/netbeans/pull/9764#discussion_r4422012407
##########
java/java.hints/src/org/netbeans/modules/java/hints/encapsulation/ReturnEncapsulation.java:
##########
@@ -214,13 +217,30 @@ private static ErrorDescription create(final HintContext
ctx,
TreePath decl = ctx.getInfo().getTrees().getPath(exprElement);
if (decl != null && decl.getLeaf().getKind() == Kind.VARIABLE &&
((VariableTree) decl.getLeaf()).getInitializer() != null) {
- TreePath init = new TreePath(decl, ((VariableTree)
decl.getLeaf()).getInitializer());
+ ExpressionTree etInit = ((VariableTree)
decl.getLeaf()).getInitializer();
+ TreePath init = new TreePath(decl,etInit);
for (String p : UNMODIFIABLE) {
if (MatcherUtilities.matches(ctx, init, p)) {
return null;
}
}
+ // check arrays with zero length or empty initializer i.e new
int[0] or new int[] {}
+ if (etInit.getKind() == Tree.Kind.NEW_ARRAY) {
+ NewArrayTree newArray = (NewArrayTree) etInit;
+ List<? extends ExpressionTree> dimensions =
newArray.getDimensions();
+ if (dimensions != null &&
+ !dimensions.isEmpty() &&
+ dimensions.get(0).getKind() == Tree.Kind.INT_LITERAL &&
+
Integer.valueOf(0).equals(((LiteralTree)dimensions.get(0)).getValue())) {
+ return null;
Review Comment:
done
--
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