Skip to content

Commit

Permalink
add test for typeArguments of the method invocation in jdt
Browse files Browse the repository at this point in the history
  • Loading branch information
pouryafard75 committed Jan 19, 2024
1 parent dc2dd65 commit 42ff5c9
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,26 @@ public void testIds() throws IOException {
assertEquals(ct.getRoot().getChild("0.3").getMetadata("id"), "Method foo( int String)");
assertEquals(ct.getRoot().getChild("0.4").getMetadata("id"), "Method bar()");
}

@Test
public void testGenericFunctionWithTypeParameter() throws IOException {
String input = "class testStructure { void foo() { Collections.<String>emptyList(); } }";
TreeContext ct = new JdtTreeGenerator().generateFrom().string(input);
String expected = "CompilationUnit [0,71]\n"
+ " TypeDeclaration [0,71]\n"
+ " TYPE_DECLARATION_KIND: class [0,5]\n"
+ " SimpleName: testStructure [6,19]\n"
+ " MethodDeclaration [22,69]\n"
+ " PrimitiveType: void [22,26]\n"
+ " SimpleName: foo [27,30]\n"
+ " Block [33,69]\n"
+ " ExpressionStatement [35,67]\n"
+ " MethodInvocation [35,66]\n"
+ " METHOD_INVOCATION_RECEIVER [35,46]\n"
+ " SimpleName: Collections [35,46]\n"
+ " SimpleType [48,54]\n"
+ " SimpleName: String [48,54]\n"
+ " SimpleName: emptyList [55,64]";
assertEquals(expected, ct.getRoot().toTreeString());
}
}

0 comments on commit 42ff5c9

Please sign in to comment.