diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DOMToModelPopulator.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DOMToModelPopulator.java index 0173d318a87..a06851b1022 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DOMToModelPopulator.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/DOMToModelPopulator.java @@ -139,6 +139,12 @@ private static void addAsChild(JavaElementInfo parentInfo, IJavaElement childEle openable.addChild(childElement); return; } + if (parentInfo instanceof SourceMethodWithChildrenInfo method) { + IJavaElement[] newElements = Arrays.copyOf(method.children, method.children.length + 1); + newElements[newElements.length - 1] = childElement; + method.children = newElements; + return; + } } @Override @@ -385,7 +391,7 @@ public boolean visit(MethodDeclaration method) { .toArray(String[]::new)); this.elements.push(newElement); addAsChild(this.infos.peek(), newElement); - SourceMethodInfo info = new SourceMethodInfo(); + SourceMethodInfo info = new SourceMethodWithChildrenInfo(new IJavaElement[0]); info.setArgumentNames(((List)method.parameters()).stream().map(param -> param.getName().toString().toCharArray()).toArray(char[][]::new)); info.arguments = ((List)method.parameters()).stream() .map(this::toLocalVariable)