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<EParameter> eParameters = eOperation.getEParameters(); for (EParameter eParameter : eParameters) { String name = eParameter.getName(); if (name != null) { int index = names.indexOf(name); if (index != -1) { if (diagnostics == null) { return false; } else { result = false; EParameter otherEParameter = eParameters.get(index); diagnostics.add (createDiagnostic (Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_PARAMETER_NAMES, "_UI_EOperationUniqueParameterNames_diagnostic", new Object[] { name }, new Object[] { eOperation, eParameter, otherEParameter }, 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 validateEOperation_UniqueParameterNames(EOperation, 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<EPa
4
    for (EPackage eSubpackage : eSubpackage
4
rameter> eParameters = eOperation.getEParameters();
5
s)
5
    for (EParameter eParameter : eParameters)
6
    {
6
    {
7
      String name = eSubpackage.getName();
7
      String name = eParameter.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
            EParameter otherEParameter = eParameters.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_PARAMETER_NAMES,
26
                 "_UI_EPackageUniqueSubpackageNames_diagnostic", 
26
                 "_UI_EOperationUniqueParameterNames_diagnostic", 
27
                 new Object[] { name },
27
                 new Object[] { name },
28
                 new Object[] { ePackage, eSubpackage, otherESubpackage },
28
                 new Object[] { eOperation, eParameter, otherEParameter },
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 = eParameter.getName();
    Differences
    Expression1Expression2Difference
    eSubpackageeParameterVARIABLE_NAME_MISMATCH
    org.eclipse.emf.ecore.EPackageorg.eclipse.emf.ecore.EParameterVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.eclipse.emf.ecore.EPackage of variable eSubpackage does not match with type org.eclipse.emf.ecore.EParameter of variable eParameter
    • Make classes org.eclipse.emf.ecore.EPackage and org.eclipse.emf.ecore.EParameter extend a common superclass
    5
    String name = eParameter.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
    EParameter otherEParameter = eParameters.get(index);
    Preondition Violations
    Unmatched statement EParameter otherEParameter=eParameters.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    EParameter otherEParameter = eParameters.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_PARAMETER_NAMES, "_UI_EOperationUniqueParameterNames_diagnostic", new Object[] {name}, new Object[] {eOperation, eParameter, otherEParameter}, context));
    Preondition Violations
    Unmatched statement diagnostics.add(createDiagnostic(Diagnostic.ERROR,DIAGNOSTIC_SOURCE,UNIQUE_PARAMETER_NAMES,"_UI_EOperationUniqueParameterNames_diagnostic",new Object[]{name},new Object[]{eOperation,eParameter,otherEParameter},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_PARAMETER_NAMES, "_UI_EOperationUniqueParameterNames_diagnostic", new Object[] {name}, new Object[] {eOperation, eParameter, otherEParameter}, 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.EParameter of variable eParameter
    2Unmatched statement EParameter otherEParameter=eParameters.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_PARAMETER_NAMES,"_UI_EOperationUniqueParameterNames_diagnostic",new Object[]{name},new Object[]{eOperation,eParameter,otherEParameter},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