Package no.hal.jex

Examples of no.hal.jex.JavaMethod


    return super.getImage(object);
  }

  @Override
  public String getImageName(Object object) {
    JavaMethod javaMethod = (JavaMethod)object;
    return JDT_UI_IMAGE_PREFIX + "meth" + getAccessModifierString(javaMethod, -1, null).substring(0, 3) + "_obj.gif";
  }
View Full Code Here


      } catch (ClassNotFoundException e) {
      }
    } else if (jexElement instanceof JavaPack) {
      return Package.getPackage(((JavaPack) jexElement).getName());
    } else if (jexElement instanceof JavaMethod) {
      JavaMethod jexMethod = (JavaMethod) jexElement;
      Class<?> javaClass = (Class<?>) getReflectiveElement(jexMethod.getOwner());
      if (javaClass != null) {
        if (javaClass.getSimpleName().equals(jexMethod.getSimpleName())) {
          Constructor<?>[] javaConstructors = javaClass.getConstructors();
          for (int i = 0; i < javaConstructors.length; i++) {
            Constructor<?> cons = javaConstructors[i];
            if (ReflectiveRequirementChecker.validateTypes(null, jexMethod.getParameters(), null, cons.getGenericParameterTypes()) == Boolean.TRUE) {
              return cons;
            }
          }
        } else {
          Method method = findMethod(javaClass, jexMethod);
View Full Code Here

      if (! isClassKind(((JavaClass) jexMember).getClassKind(), (Class<?>) javaElement)) {
        typesResult = Boolean.FALSE;
      }
      typesResult = satisfiedAnd(typesResult, validateSuperclasses(((JavaClass) jexMember), ((Class<?>) javaElement)));
    } else if (jexMember instanceof JavaMethod) {
      JavaMethod jexMethod = (JavaMethod) jexMember;
      Type javaReturnType = null, javaParameterTypes[] = null, javaExceptionTypes[] = null;
      if (javaElement instanceof Method) {
        Method javaMethod = (Method) javaElement;
        javaReturnType = javaMethod.getReturnType();
        javaParameterTypes = javaMethod.getGenericParameterTypes();
        javaExceptionTypes = javaMethod.getExceptionTypes();
      } else if (javaElement instanceof Constructor<?>) {
        Constructor<?> javaConstructor = (Constructor<?>) javaElement;
        javaReturnType = null;
        javaParameterTypes = javaConstructor.getGenericParameterTypes();
        javaExceptionTypes = javaConstructor.getExceptionTypes();
      }
      Boolean result = validateTypes(jexMethod.getReturnType(), jexMethod.getParameters(), javaReturnType, javaParameterTypes);
      if (result != Boolean.TRUE) {
        typesResult = result;
      } else {
        typesResult = validateTypes(jexMethod.getThrowables(), javaExceptionTypes, false);
      }
    } else if (jexMember instanceof JavaField && javaElement instanceof Field) {
      typesResult = Boolean.valueOf(testTypeString(((JavaField) jexMember).getType(), ((Field) javaElement).getType()));
    }
    return typesResult;
View Full Code Here

            if (! isMethodTester(method)) {
              continue;
            }
            methodClass = JexPackage.eINSTANCE.getJavaMethodTester();
          }
          JavaMethod newMethod = (JavaMethod)ensureJexMember(methodClass, method, javaClass.getMembers());
          // clear type if method is a constructor
          if (newMethod.getSimpleName().equals(javaClass.getSimpleName())) {
            newMethod.setReturnType(null);
          }
          if (newMethod instanceof JavaMethodTester && parent instanceof JavaClassTester) {
            for (Member member : ((JavaClassTester) parent).getTestedElements()) {
              Member testedMethod = findTestedMethod(newMethod.getSimpleName(), ((JavaClass) member).getMembers());
              if (testedMethod != null) {
                ((JavaMethodTester) newMethod).getTestedElements().add(testedMethod);
              }
            }
          }
View Full Code Here

      jexClass.getSuperclasses().addAll(Arrays.asList(jdtType.getSuperInterfaceNames()));
    } else if (jexMember instanceof JavaMethod) {
      if (! (jdtMember instanceof IMethod)) {
        throw new IllegalArgumentException("Cannot init JavaMethod from " + jdtMember);
      }
      JavaMethod javaMethod = (JavaMethod) jexMember;
      javaMethod.getParameters().clear();
      IMethod method = (IMethod)jdtMember;
      String[] types = method.getParameterTypes();
      for (int i = 0; i < types.length; i++) {
        javaMethod.getParameters().add(Signature.toString(types[i]));
      }
      javaMethod.setReturnType(Signature.toString(method.getReturnType()));
      javaMethod.getThrowables().addAll(Arrays.asList(method.getExceptionTypes()));
    } else if (jexMember instanceof JavaField) {
      if (! (jdtMember instanceof IField)) {
        throw new IllegalArgumentException("Cannot init JavaField from " + jdtMember);
      }
      JavaField javaField = (JavaField) jexMember;
View Full Code Here

      if (! isClassKind(((JavaClass) jexMember).getClassKind(), (IType) jdtElement)) {
        typesResult = Boolean.FALSE;
      }
      typesResult = satisfiedAnd(typesResult, validateSuperclasses(((JavaClass) jexMember), ((IType) jdtElement)));
    } else if (jexMember instanceof JavaMethod && jdtElement instanceof IMethod) {
      JavaMethod jexMethod = (JavaMethod) jexMember;
      IMethod jdtMethod = (IMethod) jdtElement;
      Boolean result = validateTypes(jexMethod.getReturnType(), jexMethod.getParameters(), jdtMethod);
      if (result != Boolean.TRUE) {
        typesResult = result;
      } else {
        try {
          typesResult = validateTypes(jexMethod.getThrowables(), jdtMethod.getExceptionTypes(), false);
        } catch (JavaModelException e) {
          typesResult = null;
        }
      }
    } else if (jexMember instanceof JavaField && jdtElement instanceof IField) {
View Full Code Here

      try {
        return project.findElement(new Path((((JavaPack) jexElement).getName()).replace('.', Path.SEPARATOR)));
      } catch (JavaModelException e) {
      }
    } else if (jexElement instanceof JavaMethod) {
      JavaMethod jexMethod = (JavaMethod) jexElement;
      IJavaElement jdtClass = findJdtElement(jexMethod.getOwner(), project);
      if (! (jdtClass instanceof IParent)) {
        return null;
      }
      List<IMember> jdtMembers = JdtHelper.findJavaMembers((IParent) jdtClass, jexMethod.getSimpleName(), IJavaElement.METHOD, IMethod.class);
      if (jdtMembers != null) {
        for (IMember jdtMember : jdtMembers) {
          if (jdtMember instanceof IMethod && JdtRequirementChecker.validateTypes(jexMethod.getReturnType(), jexMethod.getParameters(), (IMethod) jdtMember) == Boolean.TRUE) {
            return (IMethod) jdtMember;
          }
        }
      }
    } else if (jexElement instanceof JavaField) {
View Full Code Here

      // check type and name
      if (! (javaMember instanceof JavaMethod && name.equals(javaMember.getName()))) {
        continue;
      }
      // check parameter types
      JavaMethod javaMethod = (JavaMethod) javaMember;
      if (parameterTypes.length != javaMethod.getParameters().size()) {
        continue;
      }
      for (int i = 0; i < parameterTypes.length; i++) {
        if (! parameterTypes[i].equals(javaMethod.getParameters().get(i))) {
          continue outer;
        }
      }
      // found method with desired signature
      return javaMethod;
    }
    // no method with desired signature found
    JavaMethod javaMethod = JexFactory.eINSTANCE.createJavaMethod();
    javaMethod.setName(name);
    javaMethod.setReturnType(returnType);
    addAll(javaMethod.getParameters(), parameterTypes);
    if (exceptionTypes != null) {
      addAll(javaMethod.getThrowables(), exceptionTypes);
    }
    javaMembers.add(javaMethod);
    return javaMethod;
  }
View Full Code Here

          continue;
        }
        if (testedElementName != methodParent.getName() && returnType == null) {
          returnType = "void";
        }
        JavaMethod javaMethod = (JavaMethod) ensureJavaMethod(testedElementName, returnType, params, exceptions, methodParent.getMembers());
        testedElement = javaMethod;
      } else {
        JavaField javaField = (JavaField) ensureJavaElement(testedElementName, methodParent.getMembers(), JexPackage.eINSTANCE.getJavaField());
        javaField.setType(returnType);
        testedElement = javaField;
View Full Code Here

  @Override
  public boolean overrides(Member other) {
    if (! (other instanceof JavaMethod && super.overrides(other))) {
      return false;
    }
    JavaMethod otherMethod = (JavaMethod)other;
    List<String> params = getParameters(), otherParams = otherMethod.getParameters();
    if (params.size() != otherParams.size()) {
      return false;
    }
    for (int i = 0; i < params.size(); i++) {
      if (! params.get(i).equals(otherParams.get(i))) {
View Full Code Here

TOP

Related Classes of no.hal.jex.JavaMethod

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.