Previous CloneSet | Next CloneSet | Back to Main Report |
Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
---|---|---|---|---|
87 | 2 | 0 | 1.000 | class_body_declarations[8] |
Clone Abstraction | Parameter Bindings |
Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
---|---|---|---|
1 | 87 | 471 | plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/InlineMethodRefactoring.java |
2 | 87 | 457 | 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(); } } } |
| ||||
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(); } } } |
| |||
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 Index | Clone Instance | Parameter Name | Value |
---|---|---|---|
None |