Skip to content

Commit

Permalink
Keep track of types declared local to a method
Browse files Browse the repository at this point in the history
- Fixes ASTModelBridgeTests.testFindElement05
- Fixes ASTModelBridgeTests.testLocalType
- Fixes ASTModelBridgeTests.testLocalType2

Signed-off-by: David Thompson <[email protected]>
  • Loading branch information
datho7561 authored and mickaelistria committed Feb 12, 2024
1 parent 7be64d9 commit ff9884e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<SingleVariableDeclaration>)method.parameters()).stream().map(param -> param.getName().toString().toCharArray()).toArray(char[][]::new));
info.arguments = ((List<SingleVariableDeclaration>)method.parameters()).stream()
.map(this::toLocalVariable)
Expand Down

0 comments on commit ff9884e

Please sign in to comment.