boolean result = true; List<String> names = new ArrayList<String>(); EList<ETypeParameter> eTypeParameters = eOperation.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[] { eOperation, eTypeParameter, otherETypeParameter }, 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 validateEOperation_UniqueTypeParameterNames(EOperation, 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<ETypeParameter> eTypeParameters = eOperation.getETypeParameters();
3
    EList<ETypeParameter> eTypeParameters = eClassifier.getETypeParameters();
4
    for (ETypeParameter eTypeParameter : eTypeParameters)
4
    for (ETypeParameter eTypeParameter : eTypeParameters)
5
    {
5
    {
6
      String name = eTypeParameter.getName();
6
      String name = eTypeParameter.getName();
7
      if (name != null)
7
      if (name != null)
8
      {
8
      {
9
        int index = names.indexOf(name);
9
        int index = names.indexOf(name);
10
        if (index != -1)
10
        if (index != -1)
11
        {
11
        {
12
          if (diagnostics == null)
12
          if (diagnostics == null)
13
          {
13
          {
14
            return false;
14
            return false;
15
          }
15
          }
16
          else
16
          else
17
          {
17
          {
18
            result = false;
18
            result = false;
19
            ETypeParameter otherETypeParameter = eTypeParameters.get(index);
19
            ETypeParameter otherETypeParameter = eTypeParameters.get(index);
20
            diagnostics.add
20
            diagnostics.add
21
              (createDiagnostic
21
              (createDiagnostic
22
                (Diagnostic.ERROR,
22
                (Diagnostic.ERROR,
23
                 DIAGNOSTIC_SOURCE,
23
                 DIAGNOSTIC_SOURCE,
24
                 UNIQUE_TYPE_PARAMETER_NAMES,
24
                 UNIQUE_TYPE_PARAMETER_NAMES,
25
                 "_UI_UniqueTypeParameterNames_diagnostic", 
25
                 "_UI_UniqueTypeParameterNames_diagnostic", 
26
                 new Object[] { name },
26
                 new Object[] { name },
27
                 new Object[] { eOperation, eTypeParameter, otherETypeParameter },
27
                 new Object[] { eClassifier, eTypeParameter, otherETypeParameter },
28
                 context));
28
                 context));
29
          }
29
          }
30
        }
30
        }
31
      }
31
      }
32
      names.add(name);
32
      names.add(name);
33
    }
33
    }
34
    return result;
34
    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 comparisons55
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements15
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)5.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    boolean result = true;
    1
    boolean result = true;
    2
    List<String> names = new ArrayList<String>();
    2
    List<String> names = new ArrayList<String>();
    3
    EList<ETypeParameter> eTypeParameters = eOperation.getETypeParameters();
    3
    EList<ETypeParameter> eTypeParameters = eOperation.getETypeParameters();
    3
    EList<ETypeParameter> eTypeParameters = eClassifier.getETypeParameters();
    Differences
    Expression1Expression2Difference
    eOperationeClassifierVARIABLE_NAME_MISMATCH
    org.eclipse.emf.ecore.EOperationorg.eclipse.emf.ecore.EClassifierVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.eclipse.emf.ecore.EOperation of variable eOperation does not match with type org.eclipse.emf.ecore.EClassifier of variable eClassifier
    • Make classes org.eclipse.emf.ecore.EOperation and org.eclipse.emf.ecore.EClassifier extend a common superclass
    3
    EList<ETypeParameter> eTypeParameters = eClassifier.getETypeParameters();
    4
    for (ETypeParameter eTypeParameter : eTypeParameters)
    4
    for (ETypeParameter eTypeParameter : eTypeParameters)
    5
    String name = eTypeParameter.getName();
    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);
    12
    ETypeParameter otherETypeParameter = eTypeParameters.get(index);
    13
    diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_TYPE_PARAMETER_NAMES, "_UI_UniqueTypeParameterNames_diagnostic", new Object[] {name}, new Object[] {eOperation, eTypeParameter, otherETypeParameter}, context));
    13
    diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_TYPE_PARAMETER_NAMES, "_UI_UniqueTypeParameterNames_diagnostic", new Object[] {name}, new Object[] {eOperation, eTypeParameter, otherETypeParameter}, context));
    13
    diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_TYPE_PARAMETER_NAMES, "_UI_UniqueTypeParameterNames_diagnostic", new Object[] {name}, new Object[] {eClassifier, eTypeParameter, otherETypeParameter}, context));
    Differences
    Expression1Expression2Difference
    eOperationeClassifierVARIABLE_NAME_MISMATCH
    org.eclipse.emf.ecore.EOperationorg.eclipse.emf.ecore.EClassifierVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.eclipse.emf.ecore.EOperation of variable eOperation does not match with type org.eclipse.emf.ecore.EClassifier of variable eClassifier
    • Make classes org.eclipse.emf.ecore.EOperation and org.eclipse.emf.ecore.EClassifier extend a common superclass
    13
    diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_TYPE_PARAMETER_NAMES, "_UI_UniqueTypeParameterNames_diagnostic", new Object[] {name}, new Object[] {eClassifier, eTypeParameter, otherETypeParameter}, context));
    14
    names.add(name);
    14
    names.add(name);
    15
    return result;
    15
    return result;
    Precondition Violations (2)
    Row Violation
    1Type org.eclipse.emf.ecore.EOperation of variable eOperation does not match with type org.eclipse.emf.ecore.EClassifier of variable eClassifier
    2Type org.eclipse.emf.ecore.EOperation of variable eOperation does not match with type org.eclipse.emf.ecore.EClassifier of variable eClassifier