dbalek commented on code in PR #9831:
URL: https://github.com/apache/netbeans/pull/9831#discussion_r4798081309


##########
java/java.completion/src/org/netbeans/modules/java/completion/BaseTask.java:
##########
@@ -599,29 +599,14 @@ public Tree.Kind getKind() {
             String initText = controller.getText().substring(initPos, 
upToOffset ? offset : (int) sourcePositions.getEndPosition(tree));
             if (initText.length() > 0) {
                 final SourcePositions[] sp = new SourcePositions[1];
-                final ExpressionTree init = 
tu.parseVariableInitializer(initText, sp);
-                final ExpressionStatementTree fake = new 
ExpressionStatementTree() {
-                    @Override
-                    public Object accept(TreeVisitor v, Object p) {
-                        return v.visitExpressionStatement(this, p);
-                    }
-
-                    @Override
-                    public ExpressionTree getExpression() {
-                        return init;
-                    }
-
-                    @Override
-                    public Tree.Kind getKind() {
-                        return Tree.Kind.EXPRESSION_STATEMENT;
-                    }
-                };
-                sourcePositions = new SourcePositionsImpl(fake, 
sourcePositions, sp[0], initPos, upToOffset ? offset : -1);
-                path = tu.pathFor(new TreePath(pPath, fake), offset, 
sourcePositions);
-                if (upToOffset && sp[0].getEndPosition(init) + initPos > 
offset) {
-                    scope = tu.reattributeTreeTo(init, scope, path.getLeaf());
+                final AssignmentTree assign = (AssignmentTree) 
tu.parseExpression(((VariableTree) parent).getName() + " = " + initText, sp);

Review Comment:
   Replacing `parseVariableInitializer` with `parseExpression` breaks code 
completion inside array init:
   ```
   String[] arr = { "Ahoj".sub|string(1) };
   ```



-- 
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

Reply via email to