Esempio n. 1
0
  @Override
  public boolean checkSemantics(
      CompilationUnit compilationUnit,
      IType declaringType,
      IMethod declaringMethod,
      IVariable leftHandValue,
      IVariableType context) {
    if (!super.checkSemantics(compilationUnit, declaringType, declaringMethod, null, null))
      return false;

    declaringMethod.openLocalScope();

    if (declarator != null)
      declarator.checkSemantics(compilationUnit, declaringType, declaringMethod, null, null);

    IType exceptionType = Primary.resolveType(compilationUnit, Primary.Exception);

    if (exceptionType != null) {
      IVariableType variableType = declarator.getVariableType();

      ITypeCast typeCast = variableType.getCastTo(exceptionType);

      if (typeCast == null || typeCast.getOperator() != null)
        setError(
            declarator.getPosition(),
            "Type mismatch: cannot convert from "
                + variableType.getSignature()
                + " to "
                + exceptionType.getUserName());
    }

    if (statement != null)
      statement.checkSemantics(compilationUnit, declaringType, declaringMethod, null, null);

    declaringMethod.closeLocalScope();

    return true;
  }