Skip to content

Commit

Permalink
Add TAG_NAME for optionalTagNames
Browse files Browse the repository at this point in the history
  • Loading branch information
pouryafard75 committed Aug 29, 2024
1 parent 87f031e commit ba22155
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class JdtVisitor extends AbstractJdtVisitor {
private static final Type ASSIGNMENT_OPERATOR = type("ASSIGNMENT_OPERATOR");
private static final Type PREFIX_EXPRESSION_OPERATOR = type("PREFIX_EXPRESSION_OPERATOR");
private static final Type POSTFIX_EXPRESSION_OPERATOR = type("POSTFIX_EXPRESSION_OPERATOR");
private static final Type TAG_NAME = type("TAG_NAME");

private static final Type ARRAY_INITIALIZER = nodeAsSymbol(ASTNode.ARRAY_INITIALIZER);
private static final Type SIMPLE_NAME = nodeAsSymbol(ASTNode.SIMPLE_NAME);
Expand Down Expand Up @@ -111,6 +112,10 @@ public boolean visit(TypeDeclaration d) {

@Override
public boolean visit(TagElement e) {
if (e.getTagName() != null && !e.getTagName().isEmpty()) {
push(e, TAG_NAME, e.getTagName(), e.getStartPosition(), e.getTagName().length());
popNode();
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,19 @@ public void testGenericFunctionWithTypeParameter() throws IOException {
+ " SimpleName: emptyList [55,64]";
assertEquals(expected, ct.getRoot().toTreeString());
}

@Test
public void testTagElement() throws IOException {
String input = "/** @author john */ class C {}";
TreeContext ct = new JdtTreeGenerator().generateFrom().string(input);
String expected = "CompilationUnit [0,30]\n"
+ " TypeDeclaration [0,30]\n"
+ " Javadoc [0,19]\n"
+ " TagElement [4,17]\n"
+ " TAG_NAME: @author [4,11]\n"
+ " TextElement: john [11,17]\n"
+ " TYPE_DECLARATION_KIND: class [20,25]\n"
+ " SimpleName: C [26,27]";
assertEquals(expected, ct.getRoot().toTreeString());
}
}

0 comments on commit ba22155

Please sign in to comment.