List<EReference> eAllReferences = eClass.getEAllReferences(); for (int i = 0, size = eAllReferences.size(); i < size; ++i) { EReference eReference = eAllReferences.get(i); if ("xsi:schemaLocation".equals(getName(eReference))) { return eReference; } }
List<EStructuralFeature> allAttributes = getAllAttributes(eClass); for (int i = 0, size = allAttributes.size(); i < size; ++i) { EStructuralFeature result = allAttributes.get(i); if (matches(getWildcards(result), namespace)) { return result; } } return null;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/BasicExtendedMetaData.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/BasicExtendedMetaData.java
Method name: EReference getXSISchemaLocationMapFeature(EClass) Method name: EStructuralFeature getAttributeWildcardAffiliation(EClass, String, String)
Number of AST nodes: 5 Number of AST nodes: 6
1
List<EReference> eAllReferences = eClass.getEAllReferences();
1
List<EStructuralFeature> allAttributes = getAllAttributes(eClass);
2
      for (int i = 0, size = eAllReferences.size();  i < size; ++i)
2
    for (int i = 0, size = allAttributes.size(); i < size; ++i)
3
      {
3
    {
4
        EReference eReference = eAllReferences.get(i);
4
      EStructuralFeature result = allAttributes.get(i);
5
        if ("xsi:schemaLocation".equals(getName(eReference)))
5
      if (
6
  
6
matches(getWildcards(result), namespace))
7
      {
7
      {
8
          return eReference;
8
        return result;
9
    
9
      }
10
    }
10
    }
11
      }
11
    return null;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are declared in the same class
Number of node comparisons10
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment4
    Time elapsed for statement mapping (ms)10.1
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
                                                                                                                                          
    1
    List<EStructuralFeature> allAttributes = getAllAttributes(eClass);
    2
    List<EReference> eAllReferences = eClass.getEAllReferences();
                                                                                                                                
    3
    for (int i = 0, size = eAllReferences.size(); i < size; ++i)
    3
    for (int i = 0, size = eAllReferences.size(); i < size; ++i)
    2
    for (int i = 0, size = allAttributes.size(); i < size; ++i)
    Differences
    Expression1Expression2Difference
    eAllReferencesallAttributesVARIABLE_NAME_MISMATCH
    java.util.Listjava.util.ListVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.List<org.eclipse.emf.ecore.EReference> of variable eAllReferences does not match with type java.util.List<org.eclipse.emf.ecore.EStructuralFeature> of variable allAttributes
    • Make classes java.util.List and java.util.List extend a common superclass
    2
    for (int i = 0, size = allAttributes.size(); i < size; ++i)
                                                                                                        
    3
    EStructuralFeature result = allAttributes.get(i);
    Preondition Violations
    Unmatched statement EStructuralFeature result=allAttributes.get(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    EStructuralFeature result = allAttributes.get(i);
    4
    EReference eReference = eAllReferences.get(i);
    4
    EReference eReference = eAllReferences.get(i);
    Preondition Violations
    Unmatched statement EReference eReference=eAllReferences.get(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                  
    5
    if ("xsi:schemaLocation".equals(getName(eReference)))
    5
    if ("xsi:schemaLocation".equals(getName(eReference)))
    4
    if (matches(getWildcards(result), namespace))
    Differences
    Expression1Expression2Difference
    equalsmatchesMETHOD_INVOCATION_NAME_MISMATCH
    "xsi:schemaLocation".equals(getName(eReference))matches(getWildcards(result),namespace)ARGUMENT_NUMBER_MISMATCH
    "xsi:schemaLocation"MISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression "xsi:schemaLocation".equals(getName(eReference)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression matches(getWildcards(result),namespace) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression "xsi:schemaLocation".equals(getName(eReference)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression matches(getWildcards(result),namespace) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    if (matches(getWildcards(result), namespace))
                                      
    5
    return result;
    Preondition Violations
    Unmatched return result;
    5
    return result;
    6
    return eReference;
    6
    return eReference;
    Preondition Violations
    Unmatched return eReference;
                                              
                                  
    6
    return null;
    Preondition Violations
    Unmatched return null;
    6
    return null;
    Precondition Violations (10)
    Row Violation
    1Type java.util.List<org.eclipse.emf.ecore.EReference> of variable eAllReferences does not match with type java.util.List<org.eclipse.emf.ecore.EStructuralFeature> of variable allAttributes
    2Unmatched statement EStructuralFeature result=allAttributes.get(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement EReference eReference=eAllReferences.get(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Expression "xsi:schemaLocation".equals(getName(eReference)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression matches(getWildcards(result),namespace) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression "xsi:schemaLocation".equals(getName(eReference)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression matches(getWildcards(result),namespace) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Unmatched return result;
    9Unmatched return eReference;
    10Unmatched return null;