Package edu.ohio_state.khatchad.refactoring.exceptions

Examples of edu.ohio_state.khatchad.refactoring.exceptions.DefinitelyNotEnumerizableOperationException


        this.processExpression(assignment.getRightHandSide());
      }

      else if (!Util.isSuspiciousAssignmentOperator(assignment
          .getOperator()))
        throw new DefinitelyNotEnumerizableOperationException(
            Messages.ASTNodeProcessor_IllegalAssignmentExpression, assignment
                .getOperator(), node);
      else
        throw new NonEnumerizableASTException(
            Messages.ASTNodeProcessor_IllegalAssignmentExpression, node);
      break;
    }

    case ASTNode.VARIABLE_DECLARATION_STATEMENT: {
      final VariableDeclarationStatement vds = (VariableDeclarationStatement) node;
      for (final Iterator it = vds.fragments().iterator(); it.hasNext();) {
        final VariableDeclarationFragment vdf = (VariableDeclarationFragment) it
            .next();
        final IJavaElement elem = vdf.resolveBinding().getJavaElement();
        if (elem.isReadOnly() || vdf.getName().resolveBoxing())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, vdf);
        if (vdf.resolveBinding().getType().isEqualTo(
            node.getAST().resolveWellKnownType("java.lang.Object"))) //$NON-NLS-1$
          throw new NonEnumerizableASTException(
              Messages.ASTNodeProcessor_IllegalArrayUpcast, vdf);
        this.found.add(elem);
        this.processExpression(vdf.getInitializer());
      }
      break;
    }

    case ASTNode.VARIABLE_DECLARATION_FRAGMENT: {
      final VariableDeclarationFragment vdf = (VariableDeclarationFragment) node;
      final IJavaElement elem = vdf.resolveBinding().getJavaElement();
      if (!this.constFields.contains(elem)) {
        if (elem == null || vdf == null || vdf.getName() == null)
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        if (elem.isReadOnly() || vdf.getName().resolveBoxing())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        if (vdf.resolveBinding().getType().isEqualTo(
            node.getAST().resolveWellKnownType("java.lang.Object"))) //$NON-NLS-1$
          throw new NonEnumerizableASTException(
              Messages.ASTNodeProcessor_IllegalArrayUpcast, vdf);
        this.found.add(elem);
        this.processExpression(vdf.getInitializer());
      }
      break;
    }

    case ASTNode.FIELD_DECLARATION: {
      final FieldDeclaration fd = (FieldDeclaration) node;
      for (final Iterator it = fd.fragments().iterator(); it.hasNext();) {
        final VariableDeclarationFragment vdf = (VariableDeclarationFragment) it
            .next();
        final IJavaElement elem = vdf.resolveBinding().getJavaElement();
        if (!this.constFields.contains(elem)) {
          if (elem.isReadOnly() || vdf.getName().resolveBoxing())
            throw new DefinitelyNotEnumerizableException(
                Messages.ASTNodeProcessor_SourceNotPresent, vdf);
          if (vdf.resolveBinding().getType().isEqualTo(
              node.getAST().resolveWellKnownType(
                  "java.lang.Object"))) //$NON-NLS-1$
            throw new NonEnumerizableASTException(
                Messages.ASTNodeProcessor_IllegalArrayUpcast, vdf);
          this.found.add(elem);
          this.processExpression(vdf.getInitializer());
        }
      }
      break;
    }

    case ASTNode.INFIX_EXPRESSION: {
      final InfixExpression iexp = (InfixExpression) node;
      final InfixExpression.Operator op = iexp.getOperator();
      if (Util.isLegalInfixOperator(op)) {
        if (Util.inNeedOfTransformation(op)) {
          final ISourceRange range = new SourceRange(iexp
              .getStartPosition(), iexp.getLength());
          this.legalEncounteredInfixExpressionSourceLocations
              .add(range);
        }
        this.processExpression(iexp.getLeftOperand());
        this.processExpression(iexp.getRightOperand());
      }

      else if (!Util.isSuspiciousInfixOperator(op))
        throw new DefinitelyNotEnumerizableOperationException(
            Messages.ASTNodeProcessor_IllegalInfixExpression, op, node);
      else
        throw new NonEnumerizableOperationException(
            Messages.ASTNodeProcessor_IllegalInfixExpression, op, node);
      break;
View Full Code Here


        this.processExpression(assignment.getRightHandSide());
      }

      else if (!Util.isSuspiciousAssignmentOperator(assignment
          .getOperator()))
        throw new DefinitelyNotEnumerizableOperationException(
            Messages.ASTNodeProcessor_IllegalAssignmentExpression, assignment
                .getOperator(), node);
      else
        throw new NonEnumerizableOperationException(
            Messages.ASTNodeProcessor_IllegalAssignmentExpression, assignment
                .getOperator(), node);
      break;
    }

    case ASTNode.CONDITIONAL_EXPRESSION: {
      final ConditionalExpression ce = (ConditionalExpression) node;
      this.processExpression(ce.getThenExpression());
      this.processExpression(ce.getElseExpression());
      break;
    }

    case ASTNode.FIELD_ACCESS: {
      final FieldAccess fieldAccess = (FieldAccess) node;

      if (fieldAccess.resolveFieldBinding().getJavaElement() == null)
        throw new DefinitelyNotEnumerizableException(
            Messages.ASTNodeProcessor_NonEnumerizableTypeEncountered, node);
      else {
        final IJavaElement elem = fieldAccess.resolveFieldBinding()
            .getJavaElement();
        if (elem.isReadOnly() || fieldAccess.resolveBoxing())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        if (fieldAccess.resolveTypeBinding().isEqualTo(
            node.getAST().resolveWellKnownType("java.lang.Object"))) //$NON-NLS-1$
          throw new NonEnumerizableASTException(
              Messages.ASTNodeProcessor_IllegalArrayUpcast, fieldAccess);
        this.found.add(elem);
      }
      break;
    }

    case ASTNode.INFIX_EXPRESSION: {
      final InfixExpression ie = (InfixExpression) node;
      final InfixExpression.Operator op = ie.getOperator();
      if (Util.isLegalInfixOperator(op)) {
        if (Util.inNeedOfTransformation(op)) {
          final ISourceRange range = new SourceRange(ie
              .getStartPosition(), ie.getLength());
          this.legalEncounteredInfixExpressionSourceLocations
              .add(range);
        }
        this.processExpression(ie.getLeftOperand());
        this.processExpression(ie.getRightOperand());
      }

      else if (!Util.isSuspiciousInfixOperator(op))
        throw new DefinitelyNotEnumerizableOperationException(
            Messages.ASTNodeProcessor_IllegalInfixExpression, op, node);
      else
        throw new NonEnumerizableOperationException(
            Messages.ASTNodeProcessor_IllegalInfixExpression, op, node);
      break;
View Full Code Here

TOP

Related Classes of edu.ohio_state.khatchad.refactoring.exceptions.DefinitelyNotEnumerizableOperationException

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.