Package com.bacoder.parser.java.api

Examples of com.bacoder.parser.java.api.ScopedExpression


      invocation = createNode(context, SuperInvocation.class);
    } else if (expression instanceof Identifier) {
      MethodInvocation methodInvocation = createNode(context, MethodInvocation.class);
      methodInvocation.setName((Identifier) expression);
    } else if (expression instanceof ScopedExpression) {
      ScopedExpression scopedExpression = (ScopedExpression) expression;
      if (scopedExpression.getExpression() instanceof ThisExpression) {
        invocation = createNode(context, ThisInvocation.class);
        invocation.setScope(scopedExpression.getScope());
      } else if (scopedExpression.getExpression() instanceof SuperExpression) {
        invocation = createNode(context, SuperInvocation.class);
        invocation.setScope(scopedExpression.getScope());
      } else if (scopedExpression.getExpression() instanceof Identifier) {
        MethodInvocation methodInvocation = createNode(context, MethodInvocation.class);
        methodInvocation.setScope(scopedExpression.getScope());
        methodInvocation.setName((Identifier) scopedExpression.getExpression());
        invocation = methodInvocation;
      }
    }

    if (invocation == null) {
      GeneralInvocation generalInvocation = createNode(context, GeneralInvocation.class);
      if (expression instanceof ScopedExpression) {
        ScopedExpression scopedExpression = (ScopedExpression) expression;
        generalInvocation.setScope(scopedExpression.getScope());
        generalInvocation.setExpression(scopedExpression.getExpression());
        invocation = generalInvocation;
      } else {
        generalInvocation.setExpression(expression);
      }
      invocation = generalInvocation;
View Full Code Here


    return invocation;
  }

  protected ScopedExpression processScopedExpression(ExpressionContext context) {
    ScopedExpression scopedExpression = createNode(context, ScopedExpression.class);

    ExpressionContext expressionContext = getChild(context, ExpressionContext.class);
    if (expressionContext != null) {
      scopedExpression.setScope(getAdapter(ExpressionAdapter.class).adapt(expressionContext));
    }

    TerminalNode identifierNode = getTerminalNode(context, JavaParser.Identifier);
    if (identifierNode != null) {
      scopedExpression.setExpression(getAdapter(IdentifierAdapter.class).adapt(identifierNode));
      return scopedExpression;
    }

    TerminalNode thisNode = getTerminalNode(context, JavaParser.THIS);
    if (thisNode != null) {
      scopedExpression.setExpression(createNode(thisNode, ThisExpression.class));
      return scopedExpression;
    }

    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);
      }

      ExplicitGenericInvocationSuffixContext explicitGenericInvocationSuffixContext =
          getChild(explicitGenericInvocationContext, ExplicitGenericInvocationSuffixContext.class);
      if (explicitGenericInvocationSuffixContext != null) {
        scopedExpression.setExpression((ExpressionInScope)
            getAdapter(ExplicitGenericInvocationSuffixAdapter.class).adapt(
                explicitGenericInvocationSuffixContext, typeList));
      }

      return scopedExpression;
View Full Code Here

TOP

Related Classes of com.bacoder.parser.java.api.ScopedExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.