CloneSet149


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
61201.000class_body_declarations[3]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
161210
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CleanUpAction.java
261201
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/OrganizeImportsAction.java
Clone Instance
1
Line Count
61
Source Line
210
Source File
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/actions/CleanUpAction.java

        private ICompilationUnit[] getCompilationUnits(IStructuredSelection selection) {
                HashSet result = new HashSet();
                Object[] selected = selection.toArray();
                for (int i = 0; i < selected.length; i++) {
                        try {
                                if (selected[i] instanceof IJavaElement) {
                                        IJavaElement elem = (IJavaElement) selected[i];
                                        if (elem.exists()) {

                                                switch (elem.getElementType()) {
                                                        case IJavaElement.TYPE:
                                                                if (elem.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) {
                                                                        result.add(elem.getParent());
                                                                }
                                                                break;
                                                        case IJavaElement.COMPILATION_UNIT:
                                                                result.add(elem);
                                                                break;
                                                        case IJavaElement.IMPORT_CONTAINER:
                                                                result.add(elem.getParent());
                                                                break;
                                                        case IJavaElement.PACKAGE_FRAGMENT:
                                                                collectCompilationUnits((IPackageFragment) elem, result);
                                                                break;
                                                        case IJavaElement.PACKAGE_FRAGMENT_ROOT:
                                                                collectCompilationUnits((IPackageFragmentRoot) elem, result);
                                                                break;
                                                        case IJavaElement.JAVA_PROJECT:
                                                                IPackageFragmentRoot[] roots = ((IJavaProject) elem).getPackageFragmentRoots();
                                                                for (int k = 0; k < roots.length; k++) {
                                                                        collectCompilationUnits(roots[k], result);
                                                                }
                                                                break;
                                                      }
                                        }
                                }
                                else   if (selected[i] instanceof LogicalPackage) {
                                        IPackageFragment[] packageFragments = ((LogicalPackage) selected[i]).getFragments();
                                        for (int k = 0; k < packageFragments.length; k++) {
                                                IPackageFragment pack = packageFragments[k];
                                                if (pack.exists()) {
                                                        collectCompilationUnits(pack, result);
                                                }
                                        }
                                       }
                        } catch (JavaModelException e) {
                                if (JavaModelUtil.isExceptionToBeLogged(e))
                                        JavaPlugin.log(e);
                          }
                }
                return (ICompilationUnit[]) result.toArray(new ICompilationUnit[result.size()]);
        }

        private void collectCompilationUnits(IPackageFragment pack, Collection result) throws JavaModelException {
                result.addAll(Arrays.asList(pack.getCompilationUnits()));
        }

        private void collectCompilationUnits(IPackageFragmentRoot root, Collection result) throws JavaModelException {
                if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
                        IJavaElement[] children = root.getChildren();
                        for (int i = 0; i < children.length; i++) {
                                collectCompilationUnits((IPackageFragment) children[i], result);
                        }
                }
        }


Clone Instance
2
Line Count
61
Source Line
201
Source File
plugins/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/OrganizeImportsAction.java

        private ICompilationUnit[] getCompilationUnits(IStructuredSelection selection) {
                HashSet result = new HashSet();
                Object[] selected = selection.toArray();
                for (int i = 0; i < selected.length; i++) {
                        try {
                                if (selected[i] instanceof IJavaElement) {
                                        IJavaElement elem = (IJavaElement) selected[i];
                                        if (elem.exists()) {

                                                switch (elem.getElementType()) {
                                                        case IJavaElement.TYPE:
                                                                if (elem.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) {
                                                                        result.add(elem.getParent());
                                                                }
                                                                break;
                                                        case IJavaElement.COMPILATION_UNIT:
                                                                result.add(elem);
                                                                break;
                                                        case IJavaElement.IMPORT_CONTAINER:
                                                                result.add(elem.getParent());
                                                                break;
                                                        case IJavaElement.PACKAGE_FRAGMENT:
                                                                collectCompilationUnits((IPackageFragment) elem, result);
                                                                break;
                                                        case IJavaElement.PACKAGE_FRAGMENT_ROOT:
                                                                collectCompilationUnits((IPackageFragmentRoot) elem, result);
                                                                break;
                                                        case IJavaElement.JAVA_PROJECT:
                                                                IPackageFragmentRoot[] roots = ((IJavaProject) elem).getPackageFragmentRoots();
                                                                for (int k = 0; k < roots.length; k++) {
                                                                        collectCompilationUnits(roots[k], result);
                                                                }
                                                                break;
                                                      }
                                        }
                                }
                                else   if (selected[i] instanceof LogicalPackage) {
                                        IPackageFragment[] packageFragments = ((LogicalPackage) selected[i]).getFragments();
                                        for (int k = 0; k < packageFragments.length; k++) {
                                                IPackageFragment pack = packageFragments[k];
                                                if (pack.exists()) {
                                                        collectCompilationUnits(pack, result);
                                                }
                                        }
                                       }
                        } catch (JavaModelException e) {
                                if (JavaModelUtil.isExceptionToBeLogged(e))
                                        JavaPlugin.log(e);
                          }
                }
                return (ICompilationUnit[]) result.toArray(new ICompilationUnit[result.size()]);
        }

        private void collectCompilationUnits(IPackageFragment pack, Collection result) throws JavaModelException {
                result.addAll(Arrays.asList(pack.getCompilationUnits()));
        }

        private void collectCompilationUnits(IPackageFragmentRoot root, Collection result) throws JavaModelException {
                if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
                        IJavaElement[] children = root.getChildren();
                        for (int i = 0; i < children.length; i++) {
                                collectCompilationUnits((IPackageFragment) children[i], result);
                        }
                }
        }


Clone AbstractionParameter Count: 0Parameter Bindings

private ICompilationUnit[] getCompilationUnits(IStructuredSelection selection) {
  HashSet result = new HashSet();
  Object[] selected = selection.toArray();
  for (int i = 0; i < selected.length; i++) {
    try {
      if (selected[i] instanceof IJavaElement) {
        IJavaElement elem = (IJavaElement) selected[i];
        if (elem.exists()) {
          switch (elem.getElementType()) {
            case IJavaElement.TYPE:
              if (elem.getParent().getElementType() == IJavaElement.COMPILATION_UNIT) {
                result.add(elem.getParent());
              }
              break;
            case IJavaElement.COMPILATION_UNIT:
              result.add(elem);
              break;
            case IJavaElement.IMPORT_CONTAINER:
              result.add(elem.getParent());
              break;
            case IJavaElement.PACKAGE_FRAGMENT:
              collectCompilationUnits((IPackageFragment) elem, result);
              break;
            case IJavaElement.PACKAGE_FRAGMENT_ROOT:
              collectCompilationUnits((IPackageFragmentRoot) elem, result);
              break;
            case IJavaElement.JAVA_PROJECT:
              IPackageFragmentRoot[] roots = ((IJavaProject) elem).getPackageFragmentRoots();
              for (int k = 0; k < roots.length; k++) {
                collectCompilationUnits(roots[k], result);
              }
              break;
          }
        }
      }
      else
        if (selected[i] instanceof LogicalPackage) {
          IPackageFragment[] packageFragments = ((LogicalPackage) selected[i]).getFragments();
          for (int k = 0; k < packageFragments.length; k++) {
            IPackageFragment pack = packageFragments[k];
            if (pack.exists()) {
              collectCompilationUnits(pack, result);
            }
          }
        }
    }
    catch (JavaModelException e) {
      if (JavaModelUtil.isExceptionToBeLogged(e))
        JavaPlugin.log(e);
    }
  }
  return (ICompilationUnit[]) result.toArray(new ICompilationUnit[result.size()]);
}

private void collectCompilationUnits(IPackageFragment pack, Collection result) throws JavaModelException {
  result.addAll(Arrays.asList(pack.getCompilationUnits()));
}

private void collectCompilationUnits(IPackageFragmentRoot root, Collection result) throws JavaModelException {
  if (root.getKind() == IPackageFragmentRoot.K_SOURCE) {
    IJavaElement[] children = root.getChildren();
    for (int i = 0; i < children.length; i++) {
      collectCompilationUnits((IPackageFragment) children[i], result);
    }
  }
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
None