Package com.bacoder.parser.java.JavaParser

Examples of com.bacoder.parser.java.JavaParser.TypeContext


  @Override
  public FieldDeclaration adapt(FieldDeclarationContext context) {
    FieldDeclaration fieldDeclaration = createNode(context);

    TypeContext typeContext = getChild(context, TypeContext.class);
    if (typeContext != null) {
      fieldDeclaration.setType(getAdapter(TypeAdapter.class).adapt(typeContext));
    }

    VariableDeclaratorsContext variableDeclaratorsContext =
View Full Code Here


      } else {
        ForEachControl forEachControl =
            createNode(enhancedForControlContext, ForEachControl.class);
        setModifiers(enhancedForControlContext, forEachControl);

        TypeContext typeContext = getChild(enhancedForControlContext, TypeContext.class);
        if (typeContext != null) {
          forEachControl.setType(getAdapter(TypeAdapter.class).adapt(typeContext));
        }

        TerminalNode identifierNode =
View Full Code Here

    if (context.getChildCount() > 0
        && context.getChild(0) instanceof TerminalNode
        && ((TerminalNode) context.getChild(0)).getSymbol().getType() == JavaParser.LPAREN) {
      TypeCast typeCast = createNode(context, TypeCast.class);

      TypeContext typeContext = getChild(context, TypeContext.class);
      if (typeContext != null) {
        typeCast.setType(getAdapter(TypeAdapter.class).adapt(typeContext));
      }

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

      return typeCast;
    }

    if (context.getChildCount() == 2
        && context.getChild(1) instanceof TerminalNode
        && POSTFIX_OPERATOR_MAP.containsKey(
            ((TerminalNode) context.getChild(1)).getSymbol().getType())) {
      PostfixExpression postfixExpression = createNode(context, PostfixExpression.class);

      postfixExpression.setOperator(
          POSTFIX_OPERATOR_MAP.get(((TerminalNode) context.getChild(1)).getSymbol().getType()));

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

      return postfixExpression;
    }

    if (context.getChildCount() == 2
        && context.getChild(0) instanceof TerminalNode
        && PREFIX_OPERATOR_MAP.containsKey(
            ((TerminalNode) context.getChild(0)).getSymbol().getType())) {
      PrefixExpression prefixExpression = createNode(context, PrefixExpression.class);

      prefixExpression.setOperator(
          PREFIX_OPERATOR_MAP.get(((TerminalNode) context.getChild(0)).getSymbol().getType()));

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

      return prefixExpression;
    }

    if (context.getChildCount() > 2
        && context.getChild(1) instanceof TerminalNode
        && INFIX_OPERATOR_MAP.containsKey(
            ((TerminalNode) context.getChild(1)).getSymbol().getType())
        && context.getChild(0) instanceof ExpressionContext
        && context.getChild(context.getChildCount() - 1) instanceof ExpressionContext) {
      InfixExpression.Operator operator = null;
      if (context.getChildCount() == 3) {
        operator =
            INFIX_OPERATOR_MAP.get(((TerminalNode) context.getChild(1)).getSymbol().getType());
      } else if (context.getChildCount() == 4
          && isTerminalNode(context, 1, JavaParser.LT)
          && isTerminalNode(context, 2, JavaParser.LT)) {
        operator = InfixExpression.Operator.LEFT_SHIFT;
      } else if (context.getChildCount() == 4
          && isTerminalNode(context, 1, JavaParser.GT)
          && isTerminalNode(context, 2, JavaParser.GT)) {
        operator = InfixExpression.Operator.SIGNED_RIGHT_SHIFT;
      } else if (context.getChildCount() == 5
          && isTerminalNode(context, 1, JavaParser.GT)
          && isTerminalNode(context, 2, JavaParser.GT)
          && isTerminalNode(context, 3, JavaParser.GT)) {
        operator = InfixExpression.Operator.UNSIGNED_RIGHT_SHIFT;
      }

      if (operator != null) {
        InfixExpression infixExpression = createNode(context, InfixExpression.class);
        infixExpression.setLeftHandSide(
            getAdapter(ExpressionAdapter.class).adapt((ExpressionContext) context.getChild(0)));
        infixExpression.setOperator(operator);
        infixExpression.setRightHandSide(
            getAdapter(ExpressionAdapter.class).adapt(
                (ExpressionContext) context.getChild(context.getChildCount() - 1)));
        return infixExpression;
      }
    }

    if (hasTerminalNode(context, JavaParser.INSTANCEOF)) {
      InstanceOf instanceOf = createNode(context, InstanceOf.class);

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

      TypeContext typeContext = getChild(context, TypeContext.class);
      if (typeContext != null) {
        instanceOf.setType(getAdapter(TypeAdapter.class).adapt(typeContext));
      }

      return instanceOf;
View Full Code Here

  @Override
  public ConstDeclaration adapt(ConstDeclarationContext context) {
    final ConstDeclaration constDeclaration = createNode(context);

    final TypeContext typeContext = getChild(context, TypeContext.class);
    if (typeContext != null) {
      constDeclaration.setType(getAdapter(TypeAdapter.class).adapt(typeContext));
    }

    constDeclaration.setVariableDeclarations(transform(context, ConstantDeclaratorContext.class,
View Full Code Here

    super(adapters);
  }

  @Override
  public TypeArgument adapt(TypeArgumentContext context) {
    TypeContext typeContext = getChild(context, TypeContext.class);
    if (typeContext == null) {
      WildcardTypeArgument wildcardTypeArgument = createNode(context, WildcardTypeArgument.class);
      return wildcardTypeArgument;
    } else {
      Type type = getAdapter(TypeAdapter.class).adapt(typeContext);
View Full Code Here

  @Override
  public ClassMethodDeclaration adapt(MethodDeclarationContext context) {
    ClassMethodDeclaration methodDeclaration = createNode(context);

    TypeContext typeContext = getChild(context, TypeContext.class);
    if (typeContext != null) {
      methodDeclaration.setReturnType(getAdapter(TypeAdapter.class).adapt(typeContext));
    } else {
      TerminalNode voidNode = getTerminalNode(context, JavaParser.VOID);
      if (voidNode != null) {
View Full Code Here

  public D adapt(C context) {
    D formalParameter = createNode(context);

    setVariableModifiers(context, formalParameter);

    TypeContext typeContext = getChild(context, TypeContext.class);
    if (typeContext != null) {
      formalParameter.setType(getAdapter(TypeAdapter.class).adapt(typeContext));
    }

    VariableDeclaratorIdContext variableDeclaratorIdContext =
View Full Code Here

  @Override
  public InterfaceMethodDeclaration adapt(InterfaceMethodDeclarationContext context) {
    InterfaceMethodDeclaration interfaceDeclaration = createNode(context);

    TypeContext typeContext = getChild(context, TypeContext.class);
    if (typeContext != null) {
      interfaceDeclaration.setReturnType(getAdapter(TypeAdapter.class).adapt(typeContext));
    } else {
      TerminalNode voidNode = getTerminalNode(context, JavaParser.VOID);
      if (voidNode != null) {
View Full Code Here

    AnnotationMemberDeclaration annotationMemberDeclaration = null;

    AnnotationTypeElementRestContext annotationTypeElementRestContext = getChild(
        context, AnnotationTypeElementRestContext.class);
    if (annotationTypeElementRestContext != null) {
      TypeContext typeContext = getChild(annotationTypeElementRestContext,
          TypeContext.class);
      if (typeContext != null) {
        Type type = getAdapter(TypeAdapter.class).adapt(typeContext);

        AnnotationMethodOrConstantRestContext annotationMethodOrConstantRestContext = getChild(
View Full Code Here

  public LocalVariableDeclaration adapt(LocalVariableDeclarationContext context) {
    LocalVariableDeclaration localVariableDeclaration = createNode(context);

    setModifiers(context, localVariableDeclaration);

    TypeContext typeContext = getChild(context, TypeContext.class);
    if (typeContext != null) {
      localVariableDeclaration.setType(getAdapter(TypeAdapter.class).adapt(typeContext));
    }

    VariableDeclaratorsContext variableDeclaratorsContext =
View Full Code Here

TOP

Related Classes of com.bacoder.parser.java.JavaParser.TypeContext

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.