/** * Finds a method in a type. * This searches for a method with the same name and signature. Parameter types are only * compared by the simple name, no resolving for the fully qualified type name is done * @param method * @param type * @return The first found method or null, if nothing found * @throws JavaModelException */ public static IMethod findSimilarMethod(IMethod method, IType type) throws JavaModelException { return findSimilarMethod(method, type.getMethods()); }
private IMethod[] getTypeMethods(IType type, Set handleIds) throws JavaModelException { ArrayList newMethods = new ArrayList(); IMethod[] typeMethods; typeMethods = type.getMethods(); for (int index = 0; index < typeMethods.length; index++) if (!handleIds.contains(typeMethods[index].getHandleIdentifier())) newMethods.add(typeMethods[index]); IMethod[] methods = new IMethod[newMethods.size()]; newMethods.toArray(methods); return methods; }
for (ICompilationUnit unit : mypackage.getCompilationUnits()) { IType[] types = unit.getTypes(); for (int i = 0; i < types.length; i++) { IType type = types[i]; IMethod[] methods = type.getMethods();
private static boolean isTaggingInterface(TType interf) { if (interf instanceof HierarchyType) { try { return ((HierarchyType) interf).getJavaElementType().getMethods().length == 0; } catch (JavaModelException e) { // assume it's not } } return false; }
for (ICompilationUnit unit : mypackage.getCompilationUnits()) { IType primary = unit.findPrimaryType(); IMethod[] methods = primary.getMethods(); int i = 1; for (IMethod method : methods) { if (method.isConstructor()) { continue; } makeChangetoMethods(status, method,"changedMethodVersion_" + i); ++i; } }
private static boolean isTaggingInterface(TType interf) { if (interf instanceof HierarchyType) { try { return ((HierarchyType) interf).getJavaElementType().getMethods().length == 0; } catch (JavaModelException e) { // assume it's not } } return false; }
public static IMethod[] getAllConstructors(IType type) throws JavaModelException { if (JavaModelUtil.isInterfaceOrAnnotation(type)) return new IMethod[0]; List result= new ArrayList(); IMethod[] methods= type.getMethods(); for (int i= 0; i < methods.length; i++) { IMethod iMethod= methods[i]; if (iMethod.isConstructor()) result.add(iMethod); } return (IMethod[]) result.toArray(new IMethod[result.size()]); }
public static IMethod[] getAllConstructors(IType type) throws JavaModelException { if (JavaModelUtil.isInterfaceOrAnnotation(type)) return new IMethod[0]; List<IMethod> result= new ArrayList<>(); IMethod[] methods= type.getMethods(); for (int i= 0; i < methods.length; i++) { IMethod iMethod= methods[i]; if (iMethod.isConstructor()) result.add(iMethod); } return result.toArray(new IMethod[result.size()]); }
private void addCompatibleMethods(IMethod filterMethod, IType typeToFindIn, List children) throws JavaModelException { boolean filterMethodOverrides= initializeMethodOverrideTester(filterMethod, typeToFindIn); IMethod[] methods= typeToFindIn.getMethods(); for (int i= 0; i < methods.length; i++) { IMethod curr= methods[i]; if (isCompatibleMethod(filterMethod, curr, filterMethodOverrides) && !children.contains(curr)) { children.add(curr); } } }
private boolean classesDeclareOverridingNativeMethod(IType[] classes) throws CoreException { for (int i= 0; i < classes.length; i++){ IMethod[] methods= classes[i].getMethods(); for (int j= 0; j < methods.length; j++){ if ((!methods[j].equals(getMethod())) && (JdtFlags.isNative(methods[j])) && (null != Checks.findSimilarMethod(getMethod(), new IMethod[]{methods[j]}))) return true; } } return false; }
private boolean classesDeclareOverridingNativeMethod(IType[] classes) throws CoreException { for (int i= 0; i < classes.length; i++){ IMethod[] methods= classes[i].getMethods(); for (int j= 0; j < methods.length; j++){ if ((!methods[j].equals(getMethod())) && (JdtFlags.isNative(methods[j])) && (null != Checks.findSimilarMethod(getMethod(), new IMethod[]{methods[j]}))) return true; } } return false; }
private boolean classesDeclareOverridingNativeMethod(IType[] classes) throws CoreException { for (int i= 0; i < classes.length; i++){ IMethod[] methods= classes[i].getMethods(); for (int j= 0; j < methods.length; j++){ if ((!methods[j].equals(getMethod())) && (JdtFlags.isNative(methods[j])) && (null != Checks.findSimilarMethod(getMethod(), new IMethod[]{methods[j]}))) return true; } } return false; }
private RefactoringStatus checkForMethodsWithConstructorNames() throws CoreException { IMethod[] methods = fType.getMethods(); for (int i = 0; i < methods.length; i++) { if (methods[i].isConstructor()) { continue; } RefactoringStatus check = Checks.checkIfConstructorName(methods[i], methods[i].getElementName(), getNewElementName()); if (check != null) { return check; } } return null; }
/** * Finds a method in a type. * Searches for a method with the same name and the same parameter count. * Parameter types are <b>not</b> compared. * @param method * @param type * @return The first found method or null, if nothing found * @throws JavaModelException */ public static IMethod findMethod(IMethod method, IType type) throws JavaModelException { return findMethod(method.getElementName(), method.getParameterTypes().length, method.isConstructor(), type.getMethods()); }
/** * Finds a method in a type. * Searches for a method with the same name and the same parameter count. * Parameter types are <b>not</b> compared. * @param method * @param type * @return The first found method or null, if nothing found * @throws JavaModelException */ public static IMethod findMethod(IMethod method, IType type) throws JavaModelException { return findMethod(method.getElementName(), method.getParameterTypes().length, method.isConstructor(), type.getMethods()); }
/** * Finds a method in a type. * Searches for a method with the same name and the same parameter count. * Parameter types are <b>not</b> compared. * @param method * @param type * @return The first found method or null, if nothing found * @throws JavaModelException */ public static IMethod findMethod(IMethod method, IType type) throws JavaModelException { return findMethod(method.getElementName(), method.getParameterTypes().length, method.isConstructor(), type.getMethods()); }
private static Integer[] createOffsetArray(IType[] types) throws JavaModelException { List result= new ArrayList(); for (int i= 0; i < types.length; i++) { IType iType= types[i]; addOffset(result, iType.getNameRange().getOffset()); addOffset(result, iType.getSourceRange().getOffset() + iType.getSourceRange().getLength()); addMemberOffsetList(result, iType.getMethods()); addMemberOffsetList(result, iType.getFields()); addMemberOffsetList(result, iType.getInitializers()); } return (Integer[]) result.toArray(new Integer[result.size()]); }
private static Integer[] createOffsetArray(IType[] types) throws JavaModelException { List<Integer> result= new ArrayList<>(); for (int i= 0; i < types.length; i++) { IType iType= types[i]; addOffset(result, iType.getNameRange().getOffset()); addOffset(result, iType.getSourceRange().getOffset() + iType.getSourceRange().getLength()); addMemberOffsetList(result, iType.getMethods()); addMemberOffsetList(result, iType.getFields()); addMemberOffsetList(result, iType.getInitializers()); } return result.toArray(new Integer[result.size()]); }
public static RefactoringStatus checkForMainAndNativeMethods(IType type) throws JavaModelException { RefactoringStatus result= new RefactoringStatus(); result.merge(checkForMainAndNativeMethods(type.getMethods())); result.merge(checkForMainAndNativeMethods(type.getTypes())); return result; }
public static RefactoringStatus checkForMainAndNativeMethods(IType type) throws JavaModelException { RefactoringStatus result= new RefactoringStatus(); result.merge(checkForMainAndNativeMethods(type.getMethods())); result.merge(checkForMainAndNativeMethods(type.getTypes())); return result; }