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;
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_UniqueParameterNames(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<EParameter> eParameters = eOperation.getEParameters();
3
    EList<ETypeParameter> eTypeParameters = eClassifier.getETypeParameters();
4
    for (EParameter eParameter : eParameters)
4
    for (ETypeParameter eTypeParameter : eTypeParameters)
5
    {
5
    {
6
      String name = eParameter.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
            EParameter otherEParameter = eParameters.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_PARAMETER_NAMES,
24
                 UNIQUE_TYPE_PARAMETER_NAMES,
25
                 "_UI_EOperationUniqueParameterNames_diagnostic", 
25
                 "_UI_UniqueTypeParameterNames_diagnostic", 
26
                 new Object[] { name },
26
                 new Object[] { name },
27
                 new Object[] { eOperation, eParameter, otherEParameter },
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 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.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    5
    String name = eParameter.getName();
    5
    String name = eParameter.getName();
    5
    String name = eTypeParameter.getName();
    Differences
    Expression1Expression2Difference
    eParametereTypeParameterVARIABLE_NAME_MISMATCH
    org.eclipse.emf.ecore.EParameterorg.eclipse.emf.ecore.ETypeParameterVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.eclipse.emf.ecore.EParameter of variable eParameter does not match with type org.eclipse.emf.ecore.ETypeParameter of variable eTypeParameter
    • Make classes org.eclipse.emf.ecore.EParameter 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
    EParameter otherEParameter = eParameters.get(index);
    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
                                                                                                                
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    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_PARAMETER_NAMES, "_UI_EOperationUniqueParameterNames_diagnostic", new Object[] {name}, new Object[] {eOperation, eParameter, otherEParameter}, context));
    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
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    Precondition Violations (6)
    Row Violation
    1Type org.eclipse.emf.ecore.EParameter of variable eParameter 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 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
    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_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
    6Clone fragment #1 returns variables index, name, result , while Clone fragment #2 returns variables index, name, result