boolean result = true; List<String> literals = new ArrayList<String>(); EList<EEnumLiteral> eLiterals = eEnum.getELiterals(); for (EEnumLiteral eEnumLiteral : eLiterals) { String literal = eEnumLiteral.getLiteral(); if (literal != null) { int index = literals.indexOf(literal); if (index != -1) { if (diagnostics == null) { return false; } else { result = false; EEnumLiteral otherEEnumLiteral = eLiterals.get(index); // Don't complain about the literals if they are the same as the names and the names collide. // String name = eEnumLiteral.getName(); if (name == null || !name.equals(literal) || !name.equals(otherEEnumLiteral.getName())) { diagnostics.add (createDiagnostic (Diagnostic.ERROR, DIAGNOSTIC_SOURCE, UNIQUE_ENUMERATOR_LITERALS, "_UI_EEnumUniqueEnumeratorLiterals_diagnostic", new Object[] { literal }, new Object[] { eEnum, eEnumLiteral, otherEEnumLiteral }, context)); } } } } literals.add(literal); } return result;
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;
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 validateEEnum_UniqueEnumeratorLiterals(EEnum, DiagnosticChain, Map) Method name: boolean validateEOperation_UniqueTypeParameterNames(EOperation, DiagnosticChain, Map)
Number of AST nodes: 17 Number of AST nodes: 15
1
boolean result = true;
1
boolean result = true;
2
    List<String> literals = new ArrayList<String>();
2
    List<String> names = new ArrayList<String>();
3
    EList<EEnumLiteral> eLiterals = eEnum.getELiterals();
3
    EList<ETypeParameter> eTypeParameters = eOperation.getETypeParameters();
4
    for (EEnumLiteral eEnumLiteral : eLiterals)
4
    for (ETypeParameter eTypeParameter : eTypeParameters)
5
    {
5
    {
6
      String literal = eEnumLiteral.getLiteral();
6
      String name = eTypeParameter.getName();
7
      if (literal != null)
7
      if (name != null)
8
      {
8
      {
9
        int index = literals.indexOf(literal);
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
            EEnumLiteral otherEEnumLiteral = eLiterals.get(index);
19
            E
20
            // Don't complain about the literals if they are the same as the names and the names collide.
21
            //
22
            String name = eEnumLiteral.getName();
23
            if (name == null || !name.equals(literal) || !name.equals(otherEEnumLiteral.getName()))
24
            {
25
 
20
TypeParameter otherETypeParameter = eTypeParameters.get(index);
26
             diagnostics.add
21
            diagnostics.add
27
                (createDiagnostic
22
              (createDiagnostic
28
                  (Diagnostic.ERROR,
23
                (Diagnostic.ERROR,
29
                   DIAGNOSTIC_SOURCE,
24
                 DIAGNOSTIC_SOURCE,
30
                   UNIQUE_ENUMERATOR_LITERALS,
25
                 UNIQUE_TYPE_PARAMETER_NAMES,
31
                   "_UI_EEnumUniqueEnumeratorLiterals_diagnostic", 
26
                 "_UI_UniqueTypeParameterNames_diagnostic", 
32
                   new Object[] { literal },
27
                 new Object[] { name },
33
                   new Object[] { eEnum, eEnumLiteral, otherEEnumLiteral },
28
                 new Object[] { eOperation, eTypeParameter, otherETypeParameter },
34
                   context));
29
                 context));
35
            }
30
          }
36
          }
31
        }
37
        }
32
      }
38
      }
33
      
39
      literals.add(literal);
34
names.add(name);
40
    }
35
    }
41
    return result;
36
    return result;
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are declared in the same class
Number of node comparisons1