boolean result = true; List<String> names = new ArrayList<String>(); EList<EPackage> eSubpackages = ePackage.getESubpackages(); for (EPackage eSubpackage : eSubpackages) { String name = eSubpackage.getName(); if (name != null) { int index = names.indexOf(name); if (index != -1) { if (diagnostics == null) { return false; } else { result = false; EPackage otherESubpackage = eSubpackages.get(index); diagnostics.add (createDiagnostic (Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_SUBPACKAGE_NAMES, "_UI_EPackageUniqueSubpackageNames_diagnostic", new Object[] { name }, new Object[] { ePackage, eSubpackage, otherESubpackage }, context)); } } } names.add(name); } return result;
boolean result = true; List<String> names = new ArrayList<String>(); EList<ETypeParameter> eTypeParameters = eClassifier.getETypeParameters(); for (ETypeParameter eTypeParameter : eTypeParameters) { String name = eTypeParameter.getName(); if (name != null) { int index = names.indexOf(name); if (index != -1) { if (diagnostics == null) { return false; } else { result = false; ETypeParameter otherETypeParameter = eTypeParameters.get(index); diagnostics.add (createDiagnostic (Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_TYPE_PARAMETER_NAMES, "_UI_UniqueTypeParameterNames_diagnostic", new Object[] { name }, new Object[] { eClassifier, eTypeParameter, otherETypeParameter }, context)); } } } names.add(name); } return result;
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/EcoreValidator.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/EcoreValidator.java
Method name: boolean validateEPackage_UniqueSubpackageNames(EPackage, DiagnosticChain, Map) Method name: boolean validateEClassifier_UniqueTypeParameterNames(EClassifier, DiagnosticChain, Map)
Number of AST nodes: 15 Number of AST nodes: 15
1
boolean result = true;
1
boolean result = true;
2
    List<String> names = new ArrayList<String>();
2
    List<String> names = new ArrayList<String>();
3
    EList<EPackage> eSubpackages = ePackage.getESubpackages();
3
    EList<E
4
    for (EPackage eSubpackage : eSubpackage
4
TypeParameter> eTypeParameters = eClassifier.getETypeParameters();
5
s)
5
    for (ETypeParameter eTypeParameter : eTypeParameters)
6
    {
6
    {
7
      String name = eSubpackage.getName();
7
      String name = eTypeParameter.getName();
8
      if (name != null)
8
      if (name != null)
9
      {
9
      {
10
        int index = names.indexOf(name);
10
        int index = names.indexOf(name);
11
        if (index != -1)
11
        if (index != -1)
12
        {
12
        {
13
          if (diagnostics == null)
13
          if (diagnostics == null)
14
          {
14
          {
15
            return false;
15
            return false;
16
          }
16
          }
17
          else
17
          else
18
          {
18
          {
19
            result = false;
19
            result = false;
20
            EPackage otherESubpackage = eSubpackages.get(index);
20
            ETypeParameter otherETypeParameter = eTypeParameters.get(index);
21
            diagnostics.add
21
            diagnostics.add
22
              (createDiagnostic
22
              (createDiagnostic
23
                (Diagnostic.ERROR,
23
                (Diagnostic.ERROR,
24
                 DIAGNOSTIC_SOURCE,
24
                 DIAGNOSTIC_SOURCE,
25
                 UNIQUE_SUBPACKAGE_NAMES,
25
                 UNIQUE_TYPE_PARAMETER_NAMES,
26
                 "_UI_EPackageUniqueSubpackageNames_diagnostic", 
26
                 "_UI_UniqueTypeParameterNames_diagnostic", 
27
                 new Object[] { name },
27
                 new Object[] { name },
28
                 new Object[] { ePackage, eSubpackage, otherESubpackage },
28
                 new Object[] { eClassifier, eTypeParameter, otherETypeParameter },
29
                 context));
29
                 context));
30
          }
30
          }
31
        }
31
        }
32
      }
32
      }
33
      names.add(name);
33
      names.add(name);
34
    }
34
    }
35
    return result;
35
    return result;
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.4
Clones locationClones are declared in the same class
Number of node comparisons32
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)2.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    String name = eSubpackage.getName();
    5
    String name = eSubpackage.getName();
    5
    String name = eTypeParameter.getName();
    Differences
    Expression1Expression2Difference
    eSubpackageeTypeParameterVARIABLE_NAME_MISMATCH
    org.eclipse.emf.ecore.EPackageorg.eclipse.emf.ecore.ETypeParameterVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.eclipse.emf.ecore.EPackage of variable eSubpackage does not match with type org.eclipse.emf.ecore.ETypeParameter of variable eTypeParameter
    • Make classes org.eclipse.emf.ecore.EPackage and org.eclipse.emf.ecore.ETypeParameter extend a common superclass
    5
    String name = eTypeParameter.getName();
    6
    if (name != null)
    6
    if (name != null)
    7
    int index = names.indexOf(name);
    7
    int index = names.indexOf(name);
    8
    if (index != -1)
    8
    if (index != -1)
    9
    if (diagnostics == null)
    9
    if (diagnostics == null)
    10
    return false;
    10
    return false;
    else
    else
    11
    result = false;
    11
    result = false;
                                                                                                                                        
    12
    ETypeParameter otherETypeParameter = eTypeParameters.get(index);
    Preondition Violations
    Unmatched statement ETypeParameter otherETypeParameter=eTypeParameters.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    ETypeParameter otherETypeParameter = eTypeParameters.get(index);
    12
    EPackage otherESubpackage = eSubpackages.get(index);
    12
    EPackage otherESubpackage = eSubpackages.get(index);
    Preondition Violations
    Unmatched statement EPackage otherESubpackage=eSubpackages.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    13
    diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_TYPE_PARAMETER_NAMES, "_UI_UniqueTypeParameterNames_diagnostic", new Object[] {name}, new Object[] {eClassifier, eTypeParameter, otherETypeParameter}, context));
    Preondition Violations
    Unmatched statement diagnostics.add(createDiagnostic(Diagnostic.ERROR,DIAGNOSTIC_SOURCE,UNIQUE_TYPE_PARAMETER_NAMES,"_UI_UniqueTypeParameterNames_diagnostic",new Object[]{name},new Object[]{eClassifier,eTypeParameter,otherETypeParameter},context)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13
    diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_TYPE_PARAMETER_NAMES, "_UI_UniqueTypeParameterNames_diagnostic", new Object[] {name}, new Object[] {eClassifier, eTypeParameter, otherETypeParameter}, context));
    13
    diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_SUBPACKAGE_NAMES, "_UI_EPackageUniqueSubpackageNames_diagnostic", new Object[] {name}, new Object[] {ePackage, eSubpackage, otherESubpackage}, context));
    13
    diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_SUBPACKAGE_NAMES, "_UI_EPackageUniqueSubpackageNames_diagnostic", new Object[] {name}, new Object[] {ePackage, eSubpackage, otherESubpackage}, context));
    Preondition Violations
    Unmatched statement diagnostics.add(createDiagnostic(Diagnostic.ERROR,DIAGNOSTIC_SOURCE,UNIQUE_SUBPACKAGE_NAMES,"_UI_EPackageUniqueSubpackageNames_diagnostic",new Object[]{name},new Object[]{ePackage,eSubpackage,otherESubpackage},context)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    Precondition Violations (6)
    Row Violation
    1Type org.eclipse.emf.ecore.EPackage of variable eSubpackage does not match with type org.eclipse.emf.ecore.ETypeParameter of variable eTypeParameter
    2Unmatched statement ETypeParameter otherETypeParameter=eTypeParameters.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement EPackage otherESubpackage=eSubpackages.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement diagnostics.add(createDiagnostic(Diagnostic.ERROR,DIAGNOSTIC_SOURCE,UNIQUE_TYPE_PARAMETER_NAMES,"_UI_UniqueTypeParameterNames_diagnostic",new Object[]{name},new Object[]{eClassifier,eTypeParameter,otherETypeParameter},context)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement diagnostics.add(createDiagnostic(Diagnostic.ERROR,DIAGNOSTIC_SOURCE,UNIQUE_SUBPACKAGE_NAMES,"_UI_EPackageUniqueSubpackageNames_diagnostic",new Object[]{name},new Object[]{ePackage,eSubpackage,otherESubpackage},context)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Clone fragment #1 returns variables index, name, result , while Clone fragment #2 returns variables index, name, result