@Override
public Void apply(ParseTree input) {
if (input instanceof TerminalNode) {
TerminalNode terminalNode = (TerminalNode) input;
if (terminalNode.getSymbol().getType() == JavaParser.Identifier) {
IdentifierWithTypeArguments element =
createNode(input, IdentifierWithTypeArguments.class);
element.setIdentifier(getAdapter(IdentifierAdapter.class).adapt(terminalNode));
identifierWithTypeArguments.add(element);
}
} else if (input instanceof TypeArgumentsOrDiamondContext) {
int size = identifierWithTypeArguments.size();
if (size > 0) {
IdentifierWithTypeArguments element = identifierWithTypeArguments.get(size - 1);
setNodeAttributes(element, null, input);
TypeArgumentsOrDiamondContext typeArgumentsOrDiamondContext =
(TypeArgumentsOrDiamondContext) input;
TypeArgumentsContext typeArgumentsContext =
getChild(typeArgumentsOrDiamondContext, TypeArgumentsContext.class);
if (typeArgumentsContext != null) {
element.setTypeArguments(
getAdapter(TypeArgumentsAdapter.class).adapt(typeArgumentsContext));
}
}
} else if (input instanceof NonWildcardTypeArgumentsOrDiamondContext) {
int size = identifierWithTypeArguments.size();
if (size > 0) {
IdentifierWithTypeArguments element = identifierWithTypeArguments.get(size - 1);
setNodeAttributes(element, null, input);
NonWildcardTypeArgumentsContext nonWildcardTypeArgumentsContext =
(NonWildcardTypeArgumentsContext) input;
element.setTypeArguments(getAdapter(NonWildcardTypeArgumentsAdapter.class).adapt(
nonWildcardTypeArgumentsContext));
}
}
return null;
}