TerminalNode newNode = getTerminalNode(context, JavaParser.NEW);
if (newNode != null) {
ClassInstantiation newInvocation = createNode(newNode, context, ClassInstantiation.class);
NonWildcardTypeArgumentsContext nonWildcardTypeArgumentsContext =
getChild(context, NonWildcardTypeArgumentsContext.class);
if (nonWildcardTypeArgumentsContext != null) {
newInvocation.setTypeArguments(getAdapter(NonWildcardTypeArgumentsAdapter.class).adapt(
nonWildcardTypeArgumentsContext));
}
InnerCreatorContext innerCreatorContext = getChild(context, InnerCreatorContext.class);
if (innerCreatorContext != null) {
TerminalNode typeIdentifierNode =
getTerminalNode(innerCreatorContext, JavaParser.Identifier);
NonWildcardTypeArgumentsOrDiamondContext nonWildcardTypeArgumentsOrDiamondContext =
getChild(innerCreatorContext, NonWildcardTypeArgumentsOrDiamondContext.class);
TypeWithArguments typeWithArguments =
createNode(typeIdentifierNode,
nonWildcardTypeArgumentsOrDiamondContext == null
? typeIdentifierNode
: nonWildcardTypeArgumentsOrDiamondContext,
TypeWithArguments.class);
typeWithArguments.setIdentifiersWithTypeArguments(
convertIdentifiersWithTypeArguments(innerCreatorContext));
newInvocation.setType(typeWithArguments);
ClassCreatorRestContext classCreatorRestContext =
getChild(innerCreatorContext, ClassCreatorRestContext.class);
if (classCreatorRestContext != null) {
ArgumentsContext arguments = getChild(classCreatorRestContext, ArgumentsContext.class);
if (arguments != null) {
newInvocation.setArguments(getAdapter(ArgumentsAdapter.class).adapt(arguments));
}
ClassBodyContext classBodyContext =
getChild(classCreatorRestContext, ClassBodyContext.class);
if (classBodyContext != null) {
newInvocation.setMemberDeclarations(
getAdapter(ClassBodyAdapter.class).adapt(classBodyContext));
}
}
}
scopedExpression.setExpression(newInvocation);
return scopedExpression;
}
TerminalNode superNode = getTerminalNode(context, JavaParser.SUPER);
if (superNode != null) {
SuperInvocation superInvocation = createNode(superNode, context, SuperInvocation.class);
SuperSuffixContext superSuffixContext = getChild(context, SuperSuffixContext.class);
if (superSuffixContext != null) {
superInvocation =
getAdapter(SuperSuffixAdapter.class).adapt(superSuffixContext, superInvocation);
}
scopedExpression.setExpression(superInvocation);
return scopedExpression;
}
ExplicitGenericInvocationContext explicitGenericInvocationContext =
getChild(context, ExplicitGenericInvocationContext.class);
if (explicitGenericInvocationContext != null) {
List<Type> typeList = Collections.emptyList();
NonWildcardTypeArgumentsContext nonWildcardTypeArgumentsContext =
getChild(explicitGenericInvocationContext, NonWildcardTypeArgumentsContext.class);
if (nonWildcardTypeArgumentsContext != null) {
typeList = getAdapter(NonWildcardTypeArgumentsAdapter.class).adapt(
nonWildcardTypeArgumentsContext);
}