String key = name.replace("_", "").toUpperCase(); int index = names.indexOf(key); if (index != -1) { if (diagnostics == null) { return false; } else { result = false; EClassifier otherEClassifier = eClassifiers.get(index); String otherName = otherEClassifier.getName(); diagnostics.add (createDiagnostic (name.equals(otherName) ? Diagnostic.ERROR : Diagnostic.WARNING, DIAGNOSTIC_SOURCE, UNIQUE_CLASSIFIER_NAMES, name.equals(otherName) ? "_UI_EPackageUniqueClassifierNames_diagnostic" : "_UI_EPackageDissimilarClassifierNames_diagnostic", name.equals(otherName) ? new Object[] { name } : new Object[] { name, otherName }, new Object[] { ePackage, eClassifier, otherEClassifier }, context)); } } names.add(key);
String key = name.replace("_", "").toUpperCase(); int index = names.indexOf(key); if (index != -1) { if (diagnostics == null) { return false; } else { result = false; EEnumLiteral otherEEnumLiteral = eLiterals.get(index); String otherName = otherEEnumLiteral.getName(); diagnostics.add (createDiagnostic (name.equals(otherName) ? Diagnostic.ERROR : Diagnostic.WARNING, DIAGNOSTIC_SOURCE, UNIQUE_ENUMERATOR_NAMES, name.equals(otherName) ? "_UI_EEnumUniqueEnumeratorNames_diagnostic" : "_UI_EEnumDissimilarEnumeratorNames_diagnostic", name.equals(otherName) ? new Object[] { name } : new Object[] { name, otherName }, new Object[] { eEnum, eEnumLiteral, otherEEnumLiteral }, context)); } } names.add(key);
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_UniqueClassifierNames(EPackage, DiagnosticChain, Map) Method name: boolean validateEEnum_UniqueEnumeratorNames(EEnum, DiagnosticChain, Map)
Number of AST nodes: 10 Number of AST nodes: 10
1
String key = name.replace("_", "").toUpperCase();
1
String key = name.replace("_", "").toUpperCase();
2
        int index = names.indexOf(key);
2
        int index = names.indexOf(key);
3
        if (index != -1)
3
        if (index != -1)
4
        {
4
        {
5
          if (diagnostics == null)
5
          if (diagnostics == null)
6
          {
6
          {
7
            return false;
7
           return false;
8
          }
8
          }
9
          else
9
          else
10
          {
10
          {
11
            result = false;
11
            result = false;
12
            EClassifier otherEClassifier = eClassifiers.get(index);
12
            EEnumLiteral otherEEnumLiteral = eLiterals.get(index);
13
            String otherName = otherEClassifier.getName();
13
            String otherName = otherEEnumLiteral.getName();
14
            diagnostics.add
14
            diagnostics.add
15
              (createDiagnostic
15
              (createDiagnostic
16
                (name.equals(otherName) ? Diagnostic.ERROR : Diagnostic.WARNING,
16
                (name.equals(otherName) ? Diagnostic.ERROR : Diagnostic.WARNING,
17
                 DIAGNOSTIC_SOURCE,
17
                 DIAGNOSTIC_SOURCE,
18
                 UNIQUE_CLASSIFIER_NAMES,
18
                 UNIQUE_ENUMERATOR_NAMES,
19
                 name.equals(otherName) ? "_UI_EPackageUniqueClassifierNames_diagnostic" : "_UI_EPackageDissimilarClassifierNames_diagnostic",
19
                 name.equals(otherName) ? "_UI_EEnumUniqueEnumeratorNames_diagnostic" : "_UI_EEnumDissimilarEnumeratorNames_diagnostic",
20
                 name.equals(otherName) ? new Object[] { name } : new Object[] { name, otherName },
20
                 name.equals(otherName) ? new Object[] { name } : new Object[] { name, otherName },
21
                 new Object[] { ePackage, eClassifier, otherEClassifier },
21
                 new Object[] { eEnum, eEnumLiteral, otherEEnumLiteral },
22
                 context));
22
                 context));
23
          }
23
          }
24
        }
24
        }
25
        names.add(key);
25
        names.add(key);
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.2
Clones locationClones are declared in the same class
Number of node comparisons47
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)7.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    7
    String key = name.replace("_", "").toUpperCase();
    8
    String key = name.replace("_", "").toUpperCase();
    8
    int index = names.indexOf(key);
    9
    int index = names.indexOf(key);
    9
    if (index != -1)
    10
    if (index != -1)
    10
    if (diagnostics == null)
    11
    if (diagnostics == null)
    11
    return false;
    12
    return false;
    else
    else
    12
    result = false;
    13
    result = false;
    13
    EClassifier otherEClassifier = eClassifiers.get(index);
    13
    EClassifier otherEClassifier = eClassifiers.get(index);
    Preondition Violations
    Unmatched statement EClassifier otherEClassifier=eClassifiers.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                      
                                                                                                                    
    14
    EEnumLiteral otherEEnumLiteral = eLiterals.get(index);
    Preondition Violations
    Unmatched statement EEnumLiteral otherEEnumLiteral=eLiterals.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    14
    EEnumLiteral otherEEnumLiteral = eLiterals.get(index);
    14
    String otherName = otherEClassifier.getName();
    14
    String otherName = otherEClassifier.getName();
    15
    String otherName = otherEEnumLiteral.getName();
    Differences
    Expression1Expression2Difference
    otherEClassifierotherEEnumLiteralVARIABLE_NAME_MISMATCH
    org.eclipse.emf.ecore.EClassifierorg.eclipse.emf.ecore.EEnumLiteralVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.eclipse.emf.ecore.EClassifier of variable otherEClassifier does not match with type org.eclipse.emf.ecore.EEnumLiteral of variable otherEEnumLiteral
    • Make classes org.eclipse.emf.ecore.EClassifier and org.eclipse.emf.ecore.EEnumLiteral extend a common superclass
    15
    String otherName = otherEEnumLiteral.getName();
    15
    diagnostics.add(createDiagnostic(name.equals(otherName) ? Diagnostic.ERROR : Diagnostic.WARNING, DIAGNOSTIC_SOURCE, UNIQUE_CLASSIFIER_NAMES, name.equals(otherName) ? "_UI_EPackageUniqueClassifierNames_diagnostic" : "_UI_EPackageDissimilarClassifierNames_diagnostic", name.equals(otherName) ? new Object[] {name} : new Object[] {name, otherName}, new Object[] {ePackage, eClassifier, otherEClassifier}, context));
    15
    diagnostics.add(createDiagnostic(name.equals(otherName) ? Diagnostic.ERROR : Diagnostic.WARNING, DIAGNOSTIC_SOURCE, UNIQUE_CLASSIFIER_NAMES, name.equals(otherName) ? "_UI_EPackageUniqueClassifierNames_diagnostic" : "_UI_EPackageDissimilarClassifierNames_diagnostic", name.equals(otherName) ? new Object[] {name} : new Object[] {name, otherName}, new Object[] {ePackage, eClassifier, otherEClassifier}, context));
    Preondition Violations
    Unmatched statement diagnostics.add(createDiagnostic(name.equals(otherName) ? Diagnostic.ERROR : Diagnostic.WARNING,DIAGNOSTIC_SOURCE,UNIQUE_CLASSIFIER_NAMES,name.equals(otherName) ? "_UI_EPackageUniqueClassifierNames_diagnostic" : "_UI_EPackageDissimilarClassifierNames_diagnostic",name.equals(otherName) ? new Object[]{name} : new Object[]{name,otherName},new Object[]{ePackage,eClassifier,otherEClassifier},context)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
    16
    diagnostics.add(createDiagnostic(name.equals(otherName) ? Diagnostic.ERROR : Diagnostic.WARNING, DIAGNOSTIC_SOURCE, UNIQUE_ENUMERATOR_NAMES, name.equals(otherName) ? "_UI_EEnumUniqueEnumeratorNames_diagnostic" : "_UI_EEnumDissimilarEnumeratorNames_diagnostic", name.equals(otherName) ? new Object[] {name} : new Object[] {name, otherName}, new Object[] {eEnum, eEnumLiteral, otherEEnumLiteral}, context));
    Preondition Violations
    Unmatched statement diagnostics.add(createDiagnostic(name.equals(otherName) ? Diagnostic.ERROR : Diagnostic.WARNING,DIAGNOSTIC_SOURCE,UNIQUE_ENUMERATOR_NAMES,name.equals(otherName) ? "_UI_EEnumUniqueEnumeratorNames_diagnostic" : "_UI_EEnumDissimilarEnumeratorNames_diagnostic",name.equals(otherName) ? new Object[]{name} : new Object[]{name,otherName},new Object[]{eEnum,eEnumLiteral,otherEEnumLiteral},context)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    16
    diagnostics.add(createDiagnostic(name.equals(otherName) ? Diagnostic.ERROR : Diagnostic.WARNING, DIAGNOSTIC_SOURCE, UNIQUE_ENUMERATOR_NAMES, name.equals(otherName) ? "_UI_EEnumUniqueEnumeratorNames_diagnostic" : "_UI_EEnumDissimilarEnumeratorNames_diagnostic", name.equals(otherName) ? new Object[] {name} : new Object[] {name, otherName}, new Object[] {eEnum, eEnumLiteral, otherEEnumLiteral}, context));
    16
    names.add(key);
    17
    names.add(key);
    Precondition Violations (6)
    Row Violation
    1Unmatched statement EClassifier otherEClassifier=eClassifiers.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement EEnumLiteral otherEEnumLiteral=eLiterals.get(index); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type org.eclipse.emf.ecore.EClassifier of variable otherEClassifier does not match with type org.eclipse.emf.ecore.EEnumLiteral of variable otherEEnumLiteral
    4Unmatched statement diagnostics.add(createDiagnostic(name.equals(otherName) ? Diagnostic.ERROR : Diagnostic.WARNING,DIAGNOSTIC_SOURCE,UNIQUE_CLASSIFIER_NAMES,name.equals(otherName) ? "_UI_EPackageUniqueClassifierNames_diagnostic" : "_UI_EPackageDissimilarClassifierNames_diagnostic",name.equals(otherName) ? new Object[]{name} : new Object[]{name,otherName},new Object[]{ePackage,eClassifier,otherEClassifier},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(name.equals(otherName) ? Diagnostic.ERROR : Diagnostic.WARNING,DIAGNOSTIC_SOURCE,UNIQUE_ENUMERATOR_NAMES,name.equals(otherName) ? "_UI_EEnumUniqueEnumeratorNames_diagnostic" : "_UI_EEnumDissimilarEnumeratorNames_diagnostic",name.equals(otherName) ? new Object[]{name} : new Object[]{name,otherName},new Object[]{eEnum,eEnumLiteral,otherEEnumLiteral},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, otherName, result , while Clone fragment #2 returns variables index, otherName, result