Examples of DefinitelyNotEnumerizableException


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

    }

    final IMethod top = Util.getTopMostSourceMethod(meth, this.monitor);

    if (top == null)
      throw new DefinitelyNotEnumerizableException(Messages.ASTNodeProcessor_SourceNotPresent,
          ctorCall);
    else
      this.findFormalsForVariable(top, paramNumber);
  }
View Full Code Here

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

    final IMethod meth = (IMethod) ctorCall.resolveConstructorBinding()
        .getJavaElement();
    final IMethod top = Util.getTopMostSourceMethod(meth, this.monitor);

    if (top == null)
      throw new DefinitelyNotEnumerizableException(Messages.ASTNodeProcessor_SourceNotPresent,
          ctorCall);
    else
      this.findFormalsForVariable(top, getParamNumber(ctorCall
          .arguments(), this.name));
  }
View Full Code Here

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

    final IMethod meth = (IMethod) mi.resolveMethodBinding()
        .getJavaElement();
    final IMethod top = Util.getTopMostSourceMethod(meth, this.monitor);

    if (top == null)
      throw new DefinitelyNotEnumerizableException(Messages.ASTNodeProcessor_SourceNotPresent,
          mi);
    else
      this.findFormalsForVariable(top, getParamNumber(mi.arguments(),
          this.name));
  }
View Full Code Here

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

    final IMethod meth = (IMethod) ctorCall.resolveConstructorBinding()
        .getJavaElement();
    final IMethod top = Util.getTopMostSourceMethod(meth, this.monitor);

    if (top == null)
      throw new DefinitelyNotEnumerizableException(Messages.ASTNodeProcessor_SourceNotPresent,
          ctorCall);
    else
      this.findFormalsForVariable(top, getParamNumber(ctorCall
          .arguments(), this.name));
  }
View Full Code Here

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

    final IMethod meth = (IMethod) smi.resolveMethodBinding()
        .getJavaElement();
    final IMethod top = Util.getTopMostSourceMethod(meth, this.monitor);

    if (top == null)
      throw new DefinitelyNotEnumerizableException(Messages.ASTNodeProcessor_SourceNotPresent,
          smi);
    else
      this.findFormalsForVariable(top, getParamNumber(smi.arguments(),
          this.name));
  }
View Full Code Here

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

          .hasNext();) {
        final Expression dimension = (Expression) it.next();
        // if coming up from the index.
        if (containedIn(dimension, this.name)) {
          legal = false;
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_IllegalNodeContext, node);
        }
      }

      if (legal)
        this.process(node.getParent());

      break;
    }

    case ASTNode.ARRAY_ACCESS: {
      final ArrayAccess access = (ArrayAccess) node;
      // if coming up from the index.
      if (containedIn(access.getIndex(), this.name))
        throw new DefinitelyNotEnumerizableException(
            Messages.ASTNodeProcessor_IllegalNodeContext, node);
      else
        this.process(node.getParent());
      break;
    }

    case ASTNode.ASSIGNMENT: {
      final Assignment assignment = (Assignment) node;
      if (assignment.getOperator() == Assignment.Operator.ASSIGN) {
        this.processExpression(assignment.getLeftHandSide());
        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;
    }

    case ASTNode.SWITCH_STATEMENT: {
      final SwitchStatement sw = (SwitchStatement) node;
      this.processExpression(sw.getExpression());
      for (final Iterator it = sw.statements().iterator(); it.hasNext();) {
        final Object obj = it.next();
        if (obj instanceof SwitchCase) {
          final SwitchCase sc = (SwitchCase) obj;
          this.processExpression(sc.getExpression());
        }
      }
      break;
    }

    case ASTNode.SWITCH_CASE: {
      final SwitchCase sc = (SwitchCase) node;
      this.processExpression(sc.getExpression());
      this.process(sc.getParent());
      break;
    }

    case ASTNode.RETURN_STATEMENT: {
      final ReturnStatement rs = (ReturnStatement) node;

      // process what is being returned.
      this.processExpression(rs.getExpression());

      // Get the corresponding method declaration.
      final MethodDeclaration methDecl = Util.getMethodDeclaration(rs);

      // Get the corresponding method.
      final IMethod meth = (IMethod) methDecl.resolveBinding()
          .getJavaElement();

      // Get the top most method
      final IMethod top = Util.getTopMostSourceMethod(meth, this.monitor);

      if (top == null)
        throw new DefinitelyNotEnumerizableException(
            Messages.ASTNodeProcessor_SourceNotPresent, node);
      else {
        // Find the topmost method.
        if (top.isReadOnly())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);

        this.found.add(top);
      }
      break;
    }

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

    case ASTNode.METHOD_DECLARATION: {
      final ASTVisitor visitor = new ASTVisitor() {
        public boolean visit(ReturnStatement node) {
          try {
            ASTNodeProcessor.this.processExpression(node
                .getExpression());
          } catch (JavaModelException E) {
            throw new RuntimeException(E);
          }
          return true;
        }
      };

      node.accept(visitor);
      break;
    }

    case ASTNode.CLASS_INSTANCE_CREATION: {
      final ClassInstanceCreation ctorCall = (ClassInstanceCreation) node;
      // if coming up from a argument.
      if (containedIn(ctorCall.arguments(), this.name))
        // if we don't have the source, no can do.
        if (!ctorCall.getType().resolveBinding().isFromSource())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        else
          // go find the formals.
          this.findFormalsForVariable(ctorCall);
      break;
    }

    case ASTNode.CONSTRUCTOR_INVOCATION: {
      final ConstructorInvocation ctorCall = (ConstructorInvocation) node;
      // if coming up from a argument.
      if (containedIn(ctorCall.arguments(), this.name))
        // if we don't have the source, no can do.
        if (!ctorCall.resolveConstructorBinding().getDeclaringClass()
            .isFromSource())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        else
          // go find the formals.
          this.findFormalsForVariable(ctorCall);
      break;
    }

    case ASTNode.SUPER_CONSTRUCTOR_INVOCATION: {
      final SuperConstructorInvocation ctorCall = (SuperConstructorInvocation) node;
      // if coming up from a argument.
      if (containedIn(ctorCall.arguments(), this.name))
        // if we don't have the source, no can do.
        if (!ctorCall.resolveConstructorBinding().getDeclaringClass()
            .isFromSource())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        else
          // go find the formals.
          this.findFormalsForVariable(ctorCall);
      break;
    }

    case ASTNode.SUPER_METHOD_INVOCATION: {
      final SuperMethodInvocation smi = (SuperMethodInvocation) node;
      // if coming up from a argument.
      if (containedIn(smi.arguments(), this.name))
        // if we don't have the source, no can do.
        if (!smi.resolveMethodBinding().getDeclaringClass()
            .isFromSource())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        else
          // go find the formals.
          this.findFormalsForVariable(smi);
      break;
    }

    case ASTNode.METHOD_INVOCATION: {
      final MethodInvocation mi = (MethodInvocation) node;

      // if coming up from a argument.
      if (containedIn(mi.arguments(), this.name)) {
        // if we don't have the source, no can do.
        if (!mi.resolveMethodBinding().getDeclaringClass()
            .isFromSource())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        else
          // go find the formals.
          this.findFormalsForVariable(mi);
      } else
        this.process(node.getParent());

      break;
    }

    case ASTNode.PARENTHESIZED_EXPRESSION: {
      this.process(node.getParent());
      break;
    }

    case ASTNode.SINGLE_VARIABLE_DECLARATION: {
      // its a formal parameter.
      final SingleVariableDeclaration svd = (SingleVariableDeclaration) node;
      // take care of local usage.
      final IJavaElement elem = svd.resolveBinding().getJavaElement();

      if (elem.isReadOnly() || svd.getName().resolveBoxing())
        throw new DefinitelyNotEnumerizableException(
            Messages.ASTNodeProcessor_SourceNotPresent, node);
      if (svd.resolveBinding().getType().isEqualTo(
          node.getAST().resolveWellKnownType("java.lang.Object"))) //$NON-NLS-1$
        throw new NonEnumerizableASTException(Messages.ASTNodeProcessor_IllegalArrayUpcast,
            svd);

      this.found.add(elem);

      // take care of remote usage.
      // go find variables on the corresponding calls.
      this.findVariablesForFormal(svd);
      break;
    }

    case ASTNode.EXPRESSION_STATEMENT: {
      // dead expression, it's valid just goes no where.
      break;
    }

    case ASTNode.CAST_EXPRESSION: {
      final CastExpression cast = (CastExpression) node;
      throw new NonEnumerizableCastExpression(Messages.ASTNodeProcessor_IllegalNodeContext,
          node, cast.getExpression().resolveTypeBinding(), cast
              .getType().resolveBinding());
    }

    case ASTNode.ENUM_CONSTANT_DECLARATION:
    case ASTNode.IF_STATEMENT:
    case ASTNode.BOOLEAN_LITERAL:
    case ASTNode.NUMBER_LITERAL:
    case ASTNode.CHARACTER_LITERAL:
    case ASTNode.POSTFIX_EXPRESSION:
    case ASTNode.PREFIX_EXPRESSION: {
      throw new DefinitelyNotEnumerizableException(
          Messages.ASTNodeProcessor_IllegalNodeContext, node);
    }

    default: {
      throw new NonEnumerizableASTException(Messages.ASTNodeProcessor_IllegalNodeContext, node);
View Full Code Here

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

    case ASTNode.SIMPLE_NAME:
    case ASTNode.QUALIFIED_NAME: {
      final Name name = (Name) node;

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

    case ASTNode.ARRAY_ACCESS: {
      final ArrayAccess access = (ArrayAccess) node;
      this.processExpression(access.getArray());
      break;
    }

    case ASTNode.ARRAY_CREATION: {
      final ArrayCreation creation = (ArrayCreation) node;
      this.processExpression(creation.getInitializer());
      break;
    }

    case ASTNode.ARRAY_INITIALIZER: {
      final ArrayInitializer init = (ArrayInitializer) node;
      for (final Iterator it = init.expressions().iterator(); it
          .hasNext();) {
        final Expression exp = (Expression) it.next();
        this.processExpression(exp);
      }
      break;
    }

    case ASTNode.ASSIGNMENT: {
      final Assignment assignment = (Assignment) node;
      if (assignment.getOperator() == Assignment.Operator.ASSIGN) {
        this.processExpression(assignment.getLeftHandSide());
        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;
    }

    case ASTNode.METHOD_INVOCATION: {
      final MethodInvocation m = (MethodInvocation) node;
      final IMethod meth = (IMethod) m.resolveMethodBinding()
          .getJavaElement();
      final IMethod top = Util.getTopMostSourceMethod(meth, this.monitor);

      if (top == null)
        throw new DefinitelyNotEnumerizableException(
            Messages.ASTNodeProcessor_SourceNotPresent, node);
      else {
        if (top.isReadOnly())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        this.found.add(top);
      }
      break;
    }

    case ASTNode.PARENTHESIZED_EXPRESSION: {
      final ParenthesizedExpression pe = (ParenthesizedExpression) node;
      this.processExpression(pe.getExpression());
      break;
    }

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

    case ASTNode.SUPER_METHOD_INVOCATION: {
      final SuperMethodInvocation sm = (SuperMethodInvocation) node;
      final IMethod meth = (IMethod) sm.resolveMethodBinding()
          .getJavaElement();
      final IMethod top = Util.getTopMostSourceMethod(meth, this.monitor);

      if (top == null)
        throw new DefinitelyNotEnumerizableException(
            Messages.ASTNodeProcessor_SourceNotPresent, node);
      else {
        if (top.isReadOnly())
          throw new DefinitelyNotEnumerizableException(
              Messages.ASTNodeProcessor_SourceNotPresent, node);
        this.found.add(top);
      }
      break;
    }

    case ASTNode.VARIABLE_DECLARATION_EXPRESSION: {
      final VariableDeclarationExpression varDec = (VariableDeclarationExpression) node;
      for (final Iterator it = varDec.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);
      }
      break;
    }

    case ASTNode.CAST_EXPRESSION: {
      final CastExpression cast = (CastExpression) node;
      throw new NonEnumerizableCastExpression(Messages.ASTNodeProcessor_IllegalNodeContext,
          node, cast.getExpression().resolveTypeBinding(), cast
              .getType().resolveBinding());
    }

    case ASTNode.ENUM_CONSTANT_DECLARATION:
    case ASTNode.IF_STATEMENT:
    case ASTNode.BOOLEAN_LITERAL:
    case ASTNode.NUMBER_LITERAL:
    case ASTNode.CHARACTER_LITERAL:
    case ASTNode.POSTFIX_EXPRESSION:
    case ASTNode.PREFIX_EXPRESSION: {
      throw new DefinitelyNotEnumerizableException(
          Messages.ASTNodeProcessor_IllegalNodeContext, node);
    }

    default: {
      throw new NonEnumerizableASTException(Messages.ASTNodeProcessor_IllegalExpression, node);
View Full Code Here

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

      final SingleVariableDeclaration svd = (SingleVariableDeclaration) node
          .parameters().get(this.paramNumber);

      final IJavaElement elem = svd.resolveBinding().getJavaElement();
      if (elem.isReadOnly() || svd.getName().resolveBoxing())
        throw new DefinitelyNotEnumerizableException(
            Messages.ASTNodeProcessor_SourceNotPresent, svd);
      if (svd.resolveBinding().getType().isEqualTo(
          node.getAST().resolveWellKnownType("java.lang.Object"))) //$NON-NLS-1$
        throw new NonEnumerizableASTException(Messages.ASTNodeProcessor_IllegalArrayUpcast,
            svd);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.