Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IMethod


  IType type = resolveTypeByLocation(declaringTypePackageName, declaringTypeName,
      NameLookup.ACCEPT_ALL,
      selectorStart, selectorEnd);

  if(type != null) {
    IMethod method = null;

    String name = new String(selector);
    IMethod[] methods = null;

    try {
      methods = type.getMethods();
      done : for (int i = 0; i < methods.length; i++) {
        ISourceRange range = methods[i].getNameRange();
        if(range.getOffset() >= selectorStart
            && range.getOffset() + range.getLength() <= selectorEnd
            && methods[i].getElementName().equals(name)) {
          method = methods[i];
          break done;
        }
      }
    } catch (JavaModelException e) {
      //nothing to do
    }

    if(method == null) {
      addElement(type);
      if(SelectionEngine.DEBUG){
        System.out.print("SELECTION - accept type("); //$NON-NLS-1$
        System.out.print(type.toString());
        System.out.println(")"); //$NON-NLS-1$
      }
    } else {
      ITypeParameter typeParameter = method.getTypeParameter(new String(typeParameterName));
      if(typeParameter == null) {
        addElement(method);
        if(SelectionEngine.DEBUG){
          System.out.print("SELECTION - accept method("); //$NON-NLS-1$
          System.out.print(method.toString());
          System.out.println(")"); //$NON-NLS-1$
        }
      } else {
        addElement(typeParameter);
        if(SelectionEngine.DEBUG){
View Full Code Here


  }

  private static boolean typeHasShouldMethod(IType type) throws JavaModelException {
    IMethod[] methods = type.getMethods();
    for (int i = 0; i < methods.length; i++) {
      IMethod method = methods[i];
      if (method.getElementName().startsWith("should")
          && isPublicVoid(method)) {
        return true;
      }
    }
    return false;
View Full Code Here

   * @param testVisibility If true the result is tested on visibility. Null is returned if the method is not visible.
   * @return the declaring method, or <code>null</code>
   * @throws JavaModelException
   */
  public IMethod findDeclaringMethod(IMethod overriding, boolean testVisibility) throws JavaModelException {
    IMethod result= null;
    IMethod overridden= findOverriddenMethod(overriding, testVisibility);
    while (overridden != null) {
      result= overridden;
      overridden= findOverriddenMethod(result, testVisibility);
    }
    return result;
View Full Code Here

    }

    IType type= overriding.getDeclaringType();
    IType superClass= fHierarchy.getSuperclass(type);
    if (superClass != null) {
      IMethod res= findOverriddenMethodInHierarchy(superClass, overriding);
      if (res != null && !Flags.isPrivate(res.getFlags())) {
        if (!testVisibility || isVisibleInHierarchy(res, type.getPackageFragment())) {
          return res;
        }
      }
    }
    if (!overriding.isConstructor()) {
      IType[] interfaces= fHierarchy.getSuperInterfaces(type);
      for (int i= 0; i < interfaces.length; i++) {
        IMethod res= findOverriddenMethodInHierarchy(interfaces[i], overriding);
        if (res != null) {
          return res; // methods from interfaces are always public and therefore visible
        }
      }
    }
View Full Code Here

   * @param overriding The overriding method
   * @return The first overridden method or <code>null</code> if no method is overridden
   * @throws JavaModelException
   */
  public IMethod findOverriddenMethodInHierarchy(IType type, IMethod overriding) throws JavaModelException {
    IMethod method= findOverriddenMethodInType(type, overriding);
    if (method != null) {
      return method;
    }
    IType superClass= fHierarchy.getSuperclass(type);
    if (superClass != null) {
      IMethod res=  findOverriddenMethodInHierarchy(superClass, overriding);
      if (res != null) {
        return res;
      }
    }
    if (!overriding.isConstructor()) {
      IType[] superInterfaces= fHierarchy.getSuperInterfaces(type);
      for (int i= 0; i < superInterfaces.length; i++) {
        IMethod res= findOverriddenMethodInHierarchy(superInterfaces[i], overriding);
        if (res != null) {
          return res;
        }
      }
    }
View Full Code Here

    filterGetMethods(getMethods, readable, types);
    filterIsMethods(isMethods, readable, types);

    // iterate set* methods, checking overlap w/ readable
    Iterator it = setMethods.iterator();
    IMethod temp = null;
    String name = ""; //$NON-NLS-1$
    String type = ""; //$NON-NLS-1$
    String[] encodedParams = null;
    String returnType = ""; //$NON-NLS-1$
    String param0 = ""; //$NON-NLS-1$

    while (it.hasNext()) {
      temp = (IMethod) it.next();
      name = createPropertyNameFromMethod(temp);
      // invalid naming convention
      if (name == null)
        continue;

      returnType = getDecodedTypeName(temp.getReturnType());
      // setter should have no return type
      if (!returnType.equals("void")) //$NON-NLS-1$
        continue;

      // need to get type from parameter
      encodedParams = temp.getParameterTypes();
      if (encodedParams != null && encodedParams.length > 0) {
        if (encodedParams.length > 1) {
          // multiple params
          param0 = getDecodedTypeName(encodedParams[0]);
          if (!param0.equals("int")) //$NON-NLS-1$
            // not a valid indexed property
            continue;
         
          type = getDecodedTypeName(encodedParams[1]);
        }
        else {
          // one param, regular setter
          if (isArray(encodedParams[0]))
            type = getDecodedTypeName(encodedParams[0]);
        }
      }

      if (readable.contains(name)) {
        // writable and readable
        if (!fRepeatMethods.contains(name)) {
          descriptors.add(new JavaPropertyDescriptor(name, (String) types.get(name), true, true));
          readable.remove(name);
          fRepeatMethods.add(name);
        }
      }
      else {
        // wasn't readable, just writable
        String[] params = temp.getParameterTypes();
        // can't be setProperty if no parameters
        if (!(params.length > 0))
          continue;
        if (!fRepeatMethods.contains(name)) {
          type = getDecodedTypeName(params[0]);
View Full Code Here

      }
    }
  }

  private void filterGetMethods(List getMethods, List readable, HashMap types) throws JavaModelException {
    IMethod temp;
    String name;
    String encodedReturnType;
    String returnType;
    Iterator it = getMethods.iterator();
    String[] encodedParams;
    String paramType;
    // iterate get* methods
    while (it.hasNext()) {
      temp = (IMethod) it.next();
      name = createPropertyNameFromMethod(temp);
      // invalid bean naming convention
      if (name == null)
        continue;

      encodedReturnType = temp.getReturnType();
      returnType = getDecodedTypeName(encodedReturnType);

      //  can't get be a getProperty if returns void
      if (returnType.equals("void")) //$NON-NLS-1$
        continue;

      // check params in case it's indexed propety
      encodedParams = temp.getParameterTypes();
      if (encodedParams != null && encodedParams.length == 1) {
        paramType = getDecodedTypeName(encodedParams[0]);
        // syntax is > Type getter(int);
        if (!paramType.equals("int")) { //$NON-NLS-1$
          //it's not an indexed property
View Full Code Here

    }

  }

  private void filterIsMethods(List isMethodResults, List readable, HashMap types) throws JavaModelException {
    IMethod temp;
    String name;
    String encodedReturnType;
    String returnType;
    String[] encodedParams;
    String paramType;
    // iterate is* methods
    Iterator it = isMethodResults.iterator();
    while (it.hasNext()) {
      temp = (IMethod) it.next();
      name = createPropertyNameFromMethod(temp);
      // invalid bean naming convention
      if (name == null)
        continue;
      encodedReturnType = temp.getReturnType();
      returnType = getDecodedTypeName(encodedReturnType);

      // isProperty only valid for boolean
      if (!returnType.equals("boolean")) //$NON-NLS-1$
        continue;

      // check params in case it's indexed propety
      encodedParams = temp.getParameterTypes();
      if (encodedParams != null && encodedParams.length == 1) {
        paramType = getDecodedTypeName(encodedParams[0]);
        // syntax is > Type getter(int);
        if (!paramType.equals("int")) { //$NON-NLS-1$
          //it's not a valid indexed property
View Full Code Here

    };
  }

 
  protected void handleOpen(Object object) {
    IMethod result = null;
    result = findMethod(object);
    if (result != null) {
      try {

        IEditorPart openInEditor = EditorUtility.openInEditor(result);
View Full Code Here

  long t0;

  private IMethod findMethod(Object object) {
    long l0 = System.currentTimeMillis();
    try {
      IMethod iMethod = mn.get(object);
      if (iMethod != null) {
        return iMethod;
      }
      IProject prj = ((IFileEditorInput) getEditorInput()).getFile()
          .getProject();
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.IMethod

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.