1648-1-2

if (pattern.isEmpty()) { EAnnotation eAnnotation = getAnnotation(eDataType, false); if (eAnnotation != null) { eAnnotation.getDetails().remove("pattern"); } } else { EAnnotation eAnnotation = getAnnotation(eDataType, true); StringBuffer result = new StringBuffer(); for (int i = 0, size = pattern.size(); i < size; ++i) { result.append(replace(replace(pattern.get(i), "%","%25"), " ", "%20")); result.append(' '); } eAnnotation.getDetails().put("pattern", result.substring(0, result.length() - 1)); } getExtendedMetaData(eDataType).setPatternFacet(pattern);
if (literals.isEmpty()) { EAnnotation eAnnotation = getAnnotation(eDataType, false); if (eAnnotation != null) { eAnnotation.getDetails().remove("enumeration"); } } else { EAnnotation eAnnotation = getAnnotation(eDataType, true); StringBuffer result = new StringBuffer(); for (int i = 0, size = literals.size(); i < size; ++i) { result.append(replace(replace(literals.get(i), "%","%25"), " ", "%20")); result.append(' '); } eAnnotation.getDetails().put("enumeration", result.substring(0, result.length() - 1)); } getExtendedMetaData(eDataType).setEnumerationFacet(literals);

Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/BasicExtendedMetaData.java |  | File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/BasicExtendedMetaData.java
Method name: `void setPatternFacet(EDataType, List)` |  | Method name: `void setEnumerationFacet(EDataType, List)`
Number of AST nodes: 11 |  | Number of AST nodes: 11

1

    if (pattern.isEmpty())↵

1

    if (literals.isEmpty())↵

2

        {↵

2

        {↵

3

          EAnnotation eAnnotation = getAnnotation(eDataType, false);↵

3

          EAnnotation eAnnotation = getAnnotation(eDataType, false);↵

4

          if (eAnnotation != null)↵

4

          if (eAnnotation != null)↵

5

          {↵

5

          {↵

6

            eAnnotation.getDetails().remove("pattern");↵

6

            eAnnotation.getDetails().remove("enumeration");↵

7

          }↵

7

          }↵

8

        }↵

8

        }↵

9

        else↵

9

        else↵

10

        {↵

10

        {↵

11

          EAnnotation eAnnotation = getAnnotation(eDataType, true);↵

11

          EAnnotation eAnnotation = getAnnotation(eDataType, true);↵

12

          StringBuffer result = new StringBuffer();↵

12

          StringBuffer result = new StringBuffer();↵

13

          for (int i = 0, size = pattern.size(); i < size; ++i)↵

13

          for (int i = 0, size = literals.size(); i < size; ++i)↵

14

          {↵

14

          {↵

15

            result.append(replace(replace(pattern.get(i), "%","%25"), " ", "%20"));↵

15

            result.append(replace(replace(literals.get(i), "%","%25"), " ", "%20"));↵

16

            result.append(' ');↵

16

            result.append(' ');↵

17

          }↵

17

          }↵

18

          eAnnotation.getDetails().put("pattern", result.substring(0, result.length() - 1));↵

18

          eAnnotation.getDetails().put("enumeration", result.substring(0, result.length() - 1));↵

19

        }↵

19

        }↵

20

        getExtendedMetaData(eDataType).setPatternFacet(pattern);

20

        getExtendedMetaData(eDataType).setEnumerationFacet(literals);

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.6
Clones location | Clones are declared in the same class
Number of node comparisons | 46

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 11
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 4.7
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       if (pattern.isEmpty())

   1 | if (pattern.isEmpty())
   1 | if (literals.isEmpty())

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   pattern | literals | VARIABLE_NAME_MISMATCH

   1

       if (literals.isEmpty())

   2

       EAnnotation eAnnotation = getAnnotation(eDataType, false);

   2

       EAnnotation eAnnotation = getAnnotation(eDataType, false);

   3

       if (eAnnotation != null)

   3

       if (eAnnotation != null)

   4

       eAnnotation.getDetails().remove("pattern");

   4 | eAnnotation.getDetails().remove("pattern");
   4 | eAnnotation.getDetails().remove("enumeration");

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   "pattern" | "enumeration" | LITERAL_VALUE_MISMATCH

   4

       eAnnotation.getDetails().remove("enumeration");

       else

       else

   5

       EAnnotation eAnnotation = getAnnotation(eDataType, true);

   5

       EAnnotation eAnnotation = getAnnotation(eDataType, true);

   6

       StringBuffer result = new StringBuffer();

   6

       StringBuffer result = new StringBuffer();

   7

       for (int i = 0, size = pattern.size(); i < size; ++i)

   7 | for (int i = 0, size = pattern.size(); i < size; ++i)
   7 | for (int i = 0, size = literals.size(); i < size; ++i)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   pattern | literals | VARIABLE_NAME_MISMATCH

   7

       for (int i = 0, size = literals.size(); i < size; ++i)

   8

       result.append(replace(replace(pattern.get(i), "%", "%25"), " ", "%20"));

   8 | result.append(replace(replace(pattern.get(i), "%", "%25"), " ", "%20"));
   8 | result.append(replace(replace(literals.get(i), "%", "%25"), " ", "%20"));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   pattern | literals | VARIABLE_NAME_MISMATCH

   8

       result.append(replace(replace(literals.get(i), "%", "%25"), " ", "%20"));

   9

       result.append(' ');

   9

       result.append(' ');

   10

       eAnnotation.getDetails().put("pattern", result.substring(0, result.length() - 1));

   10 | eAnnotation.getDetails().put("pattern", result.substring(0, result.length() - 1));
   10 | eAnnotation.getDetails().put("enumeration", result.substring(0, result.length() - 1));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   "pattern" | "enumeration" | LITERAL_VALUE_MISMATCH

   10

       eAnnotation.getDetails().put("enumeration", result.substring(0, result.length() - 1));

   11

       getExtendedMetaData(eDataType).setPatternFacet(pattern);

   11 | getExtendedMetaData(eDataType).setPatternFacet(pattern);
   11 | getExtendedMetaData(eDataType).setEnumerationFacet(literals);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   setPatternFacet | setEnumerationFacet | METHOD_INVOCATION_NAME_MISMATCH
   pattern | literals | VARIABLE_NAME_MISMATCH

   Preondition Violations
   Expression getExtendedMetaData(eDataType).setPatternFacet(pattern) is a void method call, and thus it cannot be parameterized
   Expression getExtendedMetaData(eDataType).setEnumerationFacet(literals) is a void method call, and thus it cannot be parameterized

   11

       getExtendedMetaData(eDataType).setEnumerationFacet(literals);

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Expression getExtendedMetaData(eDataType).setPatternFacet(pattern) is a void method call, and thus it cannot be parameterized
   2 | Expression getExtendedMetaData(eDataType).setEnumerationFacet(literals) is a void method call, and thus it cannot be parameterized