CloneSet119


Previous CloneSetNext CloneSetBack to Main Report
Clone
Mass
Clones in
CloneSet
Parameter
Count
Clone
Similarity
Syntax Category
[Sequence Length]
64220.980class_body_declarations[4]
Clone AbstractionParameter Bindings
Clone Instance
(Click to see clone)
Line CountSource Line
Source File
164361
plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTester.java
264820
plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTester.java
Clone Instance
1
Line Count
64
Source Line
361
Source File
plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTester.java

        public static boolean isExtractSupertypeAvailable(IMember member) throws JavaModelException {
                final int type = member.getElementType();
                if (type != IJavaElement.METHOD && type != IJavaElement.FIELD && type != IJavaElement.TYPE)
                        return false;
                if (JdtFlags.isEnum(member) && type != IJavaElement.TYPE)
                        return false;
                if ( !Checks.isAvailable(member))
                        return false;
                if (member instanceof IType) {
                        if ( !JdtFlags.isStatic(member) && !JdtFlags.isEnum(member) && !JdtFlags.isAnnotation(member))
                                return false;
                }
                if (member instanceof IMethod) {
                        final IMethod method = (IMethod) member;
                        if (method.isConstructor())
                                return false;
                        if (JdtFlags.isNative(method))
                                return false;
                        final IType declaring = method.getDeclaringType();
                        if (declaring != null && declaring.isAnnotation())
                                return false;
                }
                return true;
        }

        public static boolean isExtractSupertypeAvailable( final IMember[] members) throws JavaModelException {
                if (members != null && members.length != 0) {
                        final IType type = getTopLevelType(members);
                        if (type != null && !type.isInterface())
                                return true;
                        for (int index = 0; index < members.length; index++) {
                                if ( !isExtractSupertypeAvailable(members[index]))
                                        return false;
                        }
                        return isCommonDeclaringType(members);
                }
                return false;
        }

        public static boolean isExtractSupertypeAvailable( final IStructuredSelection selection) throws JavaModelException {
                if ( !selection.isEmpty()) {
                        if (selection.size() == 1) {
                                if (selection.getFirstElement() instanceof ICompilationUnit)
                                        return true; // Do not force opening
                                final IType type = getSingleSelectedType(selection);
                                if (type != null)
                                        return Checks.isAvailable(type) && isExtractSupertypeAvailable(new IType[] {
                                                                                                                     type
                                                                                                                   } );
                        }
                        for ( final Iterator iterator = selection.iterator(); iterator.hasNext();) {
                                if ( !(iterator.next() instanceof IMember))
                                        return false;
                        }
                        final Set members = new HashSet();
                        members.addAll(Arrays.asList(selection.toArray()));
                        return isExtractSupertypeAvailable((IMember[]) members.toArray(new IMember[members.size()]));
                }
                return false;
        }

        public static boolean isExtractSupertypeAvailable( final JavaTextSelection selection) throws JavaModelException {
                IJavaElement element = selection.resolveEnclosingElement();
                if ( !(element instanceof IMember))
                        return false;
                return isExtractSupertypeAvailable(new IMember[] {
                                                                   (IMember) element
                                                                 } );
        }


Clone Instance
2
Line Count
64
Source Line
820
Source File
plugins/org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/RefactoringAvailabilityTester.java

        public static boolean isPullUpAvailable(IMember member) throws JavaModelException {
                final int type = member.getElementType();
                if (type != IJavaElement.METHOD && type != IJavaElement.FIELD && type != IJavaElement.TYPE)
                        return false;
                if (JdtFlags.isEnum(member) && type != IJavaElement.TYPE)
                        return false;
                if ( !Checks.isAvailable(member))
                        return false;
                if (member instanceof IType) {
                        if ( !JdtFlags.isStatic(member) && !JdtFlags.isEnum(member) && !JdtFlags.isAnnotation(member))
                                return false;
                }
                if (member instanceof IMethod) {
                        final IMethod method = (IMethod) member;
                        if (method.isConstructor())
                                return false;
                        if (JdtFlags.isNative(method))
                                return false;
                        final IType declaring = method.getDeclaringType();
                        if (declaring != null && declaring.isAnnotation())
                                return false;
                }
                return true;
        }

        public static boolean isPullUpAvailable( final IMember[] members) throws JavaModelException {
                if (members != null && members.length != 0) {
                        final IType type = getTopLevelType(members);
                        if (type != null && getPullUpMembers(type).length != 0)
                                return true;
                        for (int index = 0; index < members.length; index++) {
                                if ( !isPullUpAvailable(members[index]))
                                        return false;
                        }
                        return isCommonDeclaringType(members);
                }
                return false;
        }

        public static boolean isPullUpAvailable( final IStructuredSelection selection) throws JavaModelException {
                if ( !selection.isEmpty()) {
                        if (selection.size() == 1) {
                                if (selection.getFirstElement() instanceof ICompilationUnit)
                                        return true; // Do not force opening
                                final IType type = getSingleSelectedType(selection);
                                if (type != null)
                                        return Checks.isAvailable(type) && isPullUpAvailable(new IType[] {
                                                                                                           type
                                                                                                         } );
                        }
                        for ( final Iterator iterator = selection.iterator(); iterator.hasNext();) {
                                if ( !(iterator.next() instanceof IMember))
                                        return false;
                        }
                        final Set members = new HashSet();
                        members.addAll(Arrays.asList(selection.toArray()));
                        return isPullUpAvailable((IMember[]) members.toArray(new IMember[members.size()]));
                }
                return false;
        }

        public static boolean isPullUpAvailable( final JavaTextSelection selection) throws JavaModelException {
                IJavaElement element = selection.resolveEnclosingElement();
                if ( !(element instanceof IMember))
                        return false;
                return isPullUpAvailable(new IMember[] {
                                                         (IMember) element
                                                       } );
        }


Clone AbstractionParameter Count: 2Parameter Bindings

public static boolean  [[#variableb76668c0]](IMember member) throws JavaModelException {
  final int type = member.getElementType();
  if (type != IJavaElement.METHOD && type != IJavaElement.FIELD && type != IJavaElement.TYPE)
    return false;
  if (JdtFlags.isEnum(member) && type != IJavaElement.TYPE)
    return false;
  if ( !Checks.isAvailable(member))
    return false;
  if (member instanceof IType) {
    if ( !JdtFlags.isStatic(member) && !JdtFlags.isEnum(member) && !JdtFlags.isAnnotation(member))
      return false;
  }
  if (member instanceof IMethod) {
    final IMethod method = (IMethod) member;
    if (method.isConstructor())
      return false;
    if (JdtFlags.isNative(method))
      return false;
    final IType declaring = method.getDeclaringType();
    if (declaring != null && declaring.isAnnotation())
      return false;
  }
  return true;
}

public static boolean  [[#variableb76668c0]]( final IMember[] members) throws JavaModelException {
  if (members != null && members.length != 0) {
    final IType type = getTopLevelType(members);
    if (type != null && [[#variableb7666840]])
      return true;
    for (int index = 0; index < members.length; index++) {
      if ( ! [[#variableb76668c0]](members[index]))
        return false;
    }
    return isCommonDeclaringType(members);
  }
  return false;
}

public static boolean  [[#variableb76668c0]]( final IStructuredSelection selection) throws JavaModelException {
  if ( !selection.isEmpty()) {
    if (selection.size() == 1) {
      if (selection.getFirstElement() instanceof ICompilationUnit)
        return true; // Do not force opening
      final IType type = getSingleSelectedType(selection);
      if (type != null)
        return Checks.isAvailable(type) && [[#variableb76668c0]](new IType[] {
                                                                               type
                                                                             } );
    }
    for ( final Iterator iterator = selection.iterator(); iterator.hasNext();) {
      if ( !(iterator.next() instanceof IMember))
        return false;
    }
    final Set members = new HashSet();
    members.addAll(Arrays.asList(selection.toArray()));
    return [[#variableb76668c0]]((IMember[]) members.toArray(new IMember[members.size()]));
  }
  return false;
}

public static boolean  [[#variableb76668c0]]( final JavaTextSelection selection) throws JavaModelException {
  IJavaElement element = selection.resolveEnclosingElement();
  if ( !(element instanceof IMember))
    return false;
  return [[#variableb76668c0]](new IMember[] {
                                               (IMember) element
                                             } );
}
 

CloneAbstraction
Parameter Bindings
Parameter
Index
Clone
Instance
Parameter
Name
Value
11[[#b76668c0]]
isPullUpAvailable 
12[[#b76668c0]]
isExtractSupertypeAvailable 
21[[#b7666840]]
getPullUpMembers(type).length != 0 
22[[#b7666840]]
!type.isInterface()