From 692362f692c841c4686c4c9d7ff0b6e0ff648101 Mon Sep 17 00:00:00 2001 From: ty-bnn Date: Fri, 20 Dec 2024 22:51:27 +0900 Subject: [PATCH] Extend argument expressions in MethodInvocation --- .../eclipse/jdt/core/dom/ASTConverter.java | 6 ++-- .../jdt/core/dom/MethodInvocation.java | 30 +++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java index a0d2a4a5f38..1a2aa051a78 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTConverter.java @@ -2585,7 +2585,9 @@ public Expression convert(MessageSend expression) { if (this.resolveBindings) { recordNodes(expri, arguments[i]); } - methodInvocation.arguments().add(expri); + var elts = expri.elements(); + resetElementsParent(elts); + methodInvocation.argumentElements().addAll(elts); } } Expression qualifier = null; @@ -2934,7 +2936,7 @@ public Expression convert(org.eclipse.jdt.internal.compiler.ast.QualifiedAllocat final ClassInstanceCreation classInstanceCreation = new ClassInstanceCreation(this.ast); if (allocation.enclosingInstance != null) { Expression2 exp = convert(allocation.enclosingInstance); - resetElementsParent(classInstanceCreation.elements()); + resetElementsParent(exp.elements()); classInstanceCreation.elements().addAll(exp.elements()); } switch(this.ast.apiLevel) { diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodInvocation.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodInvocation.java index e2b4990d2b5..95fa9e8419d 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodInvocation.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodInvocation.java @@ -67,6 +67,12 @@ public class MethodInvocation extends Expression { public static final ChildListPropertyDescriptor ARGUMENTS_PROPERTY = new ChildListPropertyDescriptor(MethodInvocation.class, "arguments", Expression.class, CYCLE_RISK); //$NON-NLS-1$ + /** + * @since 3.39 + */ + public static final ChildListPropertyDescriptor ARGUMENT_ELEMENTS_PROPERTY = + new ChildListPropertyDescriptor(MethodInvocation.class, "argumentElements", ASTNode.class, NO_CYCLE_RISK); //$NON-NLS-1$ + /** * A list of property descriptors (element type: * {@link StructuralPropertyDescriptor}), @@ -97,6 +103,7 @@ public class MethodInvocation extends Expression { addProperty(TYPE_ARGUMENTS_PROPERTY, properyList); addProperty(NAME_PROPERTY, properyList); addProperty(ARGUMENTS_PROPERTY, properyList); + addProperty(ARGUMENT_ELEMENTS_PROPERTY, properyList); PROPERTY_DESCRIPTORS_3_0 = reapPropertyList(properyList); } @@ -147,10 +154,16 @@ public static List propertyDescriptors(int apiLevel) { /** * The list of argument expressions (element type: * {@link Expression}). Defaults to an empty list. + * @deprecated */ private final ASTNode.NodeList arguments = new ASTNode.NodeList(ARGUMENTS_PROPERTY); + /** + * @since 3.39 + */ + private ASTNode.NodeList argumentElements = new ASTNode.NodeList(ARGUMENT_ELEMENTS_PROPERTY); + /** * Creates a new AST node for a method invocation expression owned by the * given AST. By default, no expression, no type arguments, @@ -195,6 +208,9 @@ final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == TYPE_ARGUMENTS_PROPERTY) { return typeArguments(); } + if (property == ARGUMENT_ELEMENTS_PROPERTY) { + return argumentElements(); + } // allow default implementation to flag the error return super.internalGetChildListProperty(property); } @@ -213,7 +229,7 @@ ASTNode clone0(AST target) { if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); } - result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); + result.argumentElements().addAll(ASTNode.copySubtrees(target, argumentElements())); return result; } @@ -233,7 +249,7 @@ void accept0(ASTVisitor visitor) { acceptChildren(visitor, this.typeArguments); } acceptChild(visitor, getName()); - acceptChildren(visitor, this.arguments); + acceptChildren(visitor, this.argumentElements); } visitor.endVisit(this); } @@ -354,11 +370,19 @@ public void setName(SimpleName name) { * * @return the live list of argument expressions * (element type: {@link Expression}) + * @deprecated */ public List arguments() { return this.arguments; } + /** + * @since 3.39 + */ + public List argumentElements() { + return this.argumentElements; + } + /** * Resolves and returns the binding for the method invoked by this * expression. @@ -388,7 +412,7 @@ int treeSize() { + (this.elements == null ? 0 : this.elements.listSize()) + (this.typeArguments == null ? 0 : this.typeArguments.listSize()) + (this.methodName == null ? 0 : getName().treeSize()) - + (this.arguments == null ? 0 : this.arguments.listSize()); + + (this.arguments == null ? 0 : this.argumentElements.listSize()); } }