CloneSet49


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
87201.000class_body_declarations[8]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
187471
plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/InlineMethodRefactoring.java
287457
plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ReplaceInvocationsRefactoring.java
Clone Instance
1
Line Count
87
Source Line
471
Source File
plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/InlineMethodRefactoring.java

        private IFile getFile(ICompilationUnit unit) {
                unit = unit.getPrimary();
                IResource resource = unit.getResource();
                if (resource != null && resource.getType() == IResource.FILE)
                        return (IFile) resource;
                return null;
        }

        private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException {
                pm.beginTask("", 9); //$NON-NLS-1$
                pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden);
                MethodDeclaration decl = fSourceProvider.getDeclaration();
                IMethod method = (IMethod) decl.resolveBinding().getJavaElement();
                if (method == null || Flags.isPrivate(method.getFlags())) {
                        pm.worked(8);
                        return;
                }
                IType type = method.getDeclaringType();
                ITypeHierarchy hierarchy = type.newTypeHierarchy(new SubProgressMonitor(pm, 6));
                checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1));
                checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1));
                checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1));
                pm.setTaskName(""); //$NON-NLS-1$
        }

        private void checkSubTypes(RefactoringStatus result, IMethod method, IType[] types, IProgressMonitor pm) {
                checkTypes(
                        result, method, types, 
                        RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden_error, 
                        pm);
        }

        private void checkSuperClasses(RefactoringStatus result, IMethod method, IType[] types, IProgressMonitor pm) {
                checkTypes(
                        result, method, types, 
                        RefactoringCoreMessages.InlineMethodRefactoring_checking_overrides_error, 
                        pm);
        }

        private void checkSuperInterfaces(RefactoringStatus result, IMethod method, IType[] types, IProgressMonitor pm) {
                checkTypes(
                        result, method, types, 
                        RefactoringCoreMessages.InlineMethodRefactoring_checking_implements_error, 
                        pm);
        }

        private void checkTypes(RefactoringStatus result, IMethod method, IType[] types, String key, IProgressMonitor pm) {
                pm.beginTask("", types.length); //$NON-NLS-1$
                for (int i = 0; i < types.length; i++) {
                        pm.worked(1);
                        IMethod[] overridden = types[i].findMethods(method);
                        if (overridden != null && overridden.length > 0) {
                                result.addError(
                                        Messages.format(key, types[i].getElementName()), 
                                        JavaStatusContext.create(overridden[0]));
                        }
                }
        }

        private ASTNode[] removeNestedCalls(RefactoringStatus status, ICompilationUnit unit, ASTNode[] invocations) {
                if (invocations.length <= 1)
                        return invocations;
                ASTNode[] parents = new ASTNode[invocations.length];
                for (int i = 0; i < invocations.length; i++) {
                        parents[i] = invocations[i].getParent();
                }
                for (int i = 0; i < invocations.length; i++) {
                        removeNestedCalls(status, unit, parents, invocations, i);
                }
                List result = new ArrayList();
                for (int i = 0; i < invocations.length; i++) {
                        if (invocations[i] != null)
                                result.add(invocations[i]);
                }
                return (ASTNode[]) result.toArray(new ASTNode[result.size()]);
        }

        private void removeNestedCalls(RefactoringStatus status, ICompilationUnit unit, ASTNode[] parents, ASTNode[] invocations, int index) {
                ASTNode invocation = invocations[index];
                for (int i = 0; i < parents.length; i++) {
                        ASTNode parent = parents[i];
                        while (parent != null) {
                                if (parent == invocation) {
                                        status.addError(RefactoringCoreMessages.InlineMethodRefactoring_nestedInvocation, 
                                                JavaStatusContext.create(unit, parent));
                                        invocations[index] = null;
                                }
                                parent = parent.getParent();
                        }
                }
        }


Clone Instance
2
Line Count
87
Source Line
457
Source File
plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/ReplaceInvocationsRefactoring.java

        private IFile getFile(ICompilationUnit unit) {
                unit = unit.getPrimary();
                IResource resource = unit.getResource();
                if (resource != null && resource.getType() == IResource.FILE)
                        return (IFile) resource;
                return null;
        }

        private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException {
                pm.beginTask("", 9); //$NON-NLS-1$
                pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden);
                MethodDeclaration decl = fSourceProvider.getDeclaration();
                IMethod method = (IMethod) decl.resolveBinding().getJavaElement();
                if (method == null || Flags.isPrivate(method.getFlags())) {
                        pm.worked(8);
                        return;
                }
                IType type = method.getDeclaringType();
                ITypeHierarchy hierarchy = type.newTypeHierarchy(new SubProgressMonitor(pm, 6));
                checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1));
                checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1));
                checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1));
                pm.setTaskName(""); //$NON-NLS-1$
        }

        private void checkSubTypes(RefactoringStatus result, IMethod method, IType[] types, IProgressMonitor pm) {
                checkTypes(
                        result, method, types, 
                        RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden_error, 
                        pm);
        }

        private void checkSuperClasses(RefactoringStatus result, IMethod method, IType[] types, IProgressMonitor pm) {
                checkTypes(
                        result, method, types, 
                        RefactoringCoreMessages.InlineMethodRefactoring_checking_overrides_error, 
                        pm);
        }

        private void checkSuperInterfaces(RefactoringStatus result, IMethod method, IType[] types, IProgressMonitor pm) {
                checkTypes(
                        result, method, types, 
                        RefactoringCoreMessages.InlineMethodRefactoring_checking_implements_error, 
                        pm);
        }

        private void checkTypes(RefactoringStatus result, IMethod method, IType[] types, String key, IProgressMonitor pm) {
                pm.beginTask("", types.length); //$NON-NLS-1$
                for (int i = 0; i < types.length; i++) {
                        pm.worked(1);
                        IMethod[] overridden = types[i].findMethods(method);
                        if (overridden != null && overridden.length > 0) {
                                result.addError(
                                        Messages.format(key, types[i].getElementName()), 
                                        JavaStatusContext.create(overridden[0]));
                        }
                }
        }

        private ASTNode[] removeNestedCalls(RefactoringStatus status, ICompilationUnit unit, ASTNode[] invocations) {
                if (invocations.length <= 1)
                        return invocations;
                ASTNode[] parents = new ASTNode[invocations.length];
                for (int i = 0; i < invocations.length; i++) {
                        parents[i] = invocations[i].getParent();
                }
                for (int i = 0; i < invocations.length; i++) {
                        removeNestedCalls(status, unit, parents, invocations, i);
                }
                List result = new ArrayList();
                for (int i = 0; i < invocations.length; i++) {
                        if (invocations[i] != null)
                                result.add(invocations[i]);
                }
                return (ASTNode[]) result.toArray(new ASTNode[result.size()]);
        }

        private void removeNestedCalls(RefactoringStatus status, ICompilationUnit unit, ASTNode[] parents, ASTNode[] invocations, int index) {
                ASTNode invocation = invocations[index];
                for (int i = 0; i < parents.length; i++) {
                        ASTNode parent = parents[i];
                        while (parent != null) {
                                if (parent == invocation) {
                                        status.addError(RefactoringCoreMessages.InlineMethodRefactoring_nestedInvocation, 
                                                JavaStatusContext.create(unit, parent));
                                        invocations[index] = null;
                                }
                                parent = parent.getParent();
                        }
                }
        }


Clone AbstractionParameter Count: 0Parameter Bindings

private IFile getFile(ICompilationUnit unit) {
  unit = unit.getPrimary();
  IResource resource = unit.getResource();
  if (resource != null && resource.getType() == IResource.FILE)
    return (IFile) resource;
  return null;
}

private void checkOverridden(RefactoringStatus status, IProgressMonitor pm) throws JavaModelException {
  pm.beginTask("", 9); //$NON-NLS-1$
  pm.setTaskName(RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden);
  MethodDeclaration decl = fSourceProvider.getDeclaration();
  IMethod method = (IMethod) decl.resolveBinding().getJavaElement();
  if (method == null || Flags.isPrivate(method.getFlags())) {
    pm.worked(8);
    return;
  }
  IType type = method.getDeclaringType();
  ITypeHierarchy hierarchy = type.newTypeHierarchy(new SubProgressMonitor(pm, 6));
  checkSubTypes(status, method, hierarchy.getAllSubtypes(type), new SubProgressMonitor(pm, 1));
  checkSuperClasses(status, method, hierarchy.getAllSuperclasses(type), new SubProgressMonitor(pm, 1));
  checkSuperInterfaces(status, method, hierarchy.getAllSuperInterfaces(type), new SubProgressMonitor(pm, 1));
  pm.setTaskName(""); //$NON-NLS-1$
}

private void checkSubTypes(RefactoringStatus result, IMethod method, IType[] types, IProgressMonitor pm) {
  checkTypes(result, method, types, RefactoringCoreMessages.InlineMethodRefactoring_checking_overridden_error, pm);
}

private void checkSuperClasses(RefactoringStatus result, IMethod method, IType[] types, IProgressMonitor pm) {
  checkTypes(result, method, types, RefactoringCoreMessages.InlineMethodRefactoring_checking_overrides_error, pm);
}

private void checkSuperInterfaces(RefactoringStatus result, IMethod method, IType[] types, IProgressMonitor pm) {
  checkTypes(result, method, types, RefactoringCoreMessages.InlineMethodRefactoring_checking_implements_error, pm);
}

private void checkTypes(RefactoringStatus result, IMethod method, IType[] types, String key, IProgressMonitor pm) {
  pm.beginTask("", types.length); //$NON-NLS-1$
  for (int i = 0; i < types.length; i++) {
    pm.worked(1);
    IMethod[] overridden = types[i].findMethods(method);
    if (overridden != null && overridden.length > 0) {
      result.addError(Messages.format(key, types[i].getElementName()), JavaStatusContext.create(overridden[0]));
    }
  }
}

private ASTNode[] removeNestedCalls(RefactoringStatus status, ICompilationUnit unit, ASTNode[] invocations) {
  if (invocations.length <= 1)
    return invocations;
  ASTNode[] parents = new ASTNode[invocations.length];
  for (int i = 0; i < invocations.length; i++) {
    parents[i] = invocations[i].getParent();
  }
  for (int i = 0; i < invocations.length; i++) {
    removeNestedCalls(status, unit, parents, invocations, i);
  }
  List result = new ArrayList();
  for (int i = 0; i < invocations.length; i++) {
    if (invocations[i] != null)
      result.add(invocations[i]);
  }
  return (ASTNode[]) result.toArray(new ASTNode[result.size()]);
}

private void removeNestedCalls(RefactoringStatus status, ICompilationUnit unit, ASTNode[] parents, ASTNode[] invocations, int index) {
  ASTNode invocation = invocations[index];
  for (int i = 0; i < parents.length; i++) {
    ASTNode parent = parents[i];
    while (parent != null) {
      if (parent == invocation) {
        status.addError(RefactoringCoreMessages.InlineMethodRefactoring_nestedInvocation, JavaStatusContext.create(unit, parent));
        invocations[index] = null;
      }
      parent = parent.getParent();
    }
  }
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
None