359-1-2

if (print) { if (separator) { new MenuItem(result, SWT.SEPARATOR); separator = false; } MenuItem printItem = new MenuItem(result, SWT.NONE); printItem.setText(localizationResources.getString("Print...")); printItem.setData(PRINT_COMMAND); printItem.addSelectionListener(this); separator = true; }
if (save) { if (separator) { new MenuItem(result, SWT.SEPARATOR); separator = false; } MenuItem saveItem = new MenuItem(result, SWT.NONE); saveItem.setText(localizationResources.getString("Save_as...")); saveItem.setData(SAVE_COMMAND); saveItem.addSelectionListener(this); separator = true; }

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/swt/org/jfree/experimental/chart/swt/ChartComposite.java |  | File path: /jfreechart-1.0.10/swt/org/jfree/experimental/chart/swt/ChartComposite.java
Method name: `Menu createPopupMenu(boolean, boolean, boolean, boolean)` |  | Method name: `Menu createPopupMenu(boolean, boolean, boolean, boolean)`
Number of AST nodes: 9 |  | Number of AST nodes: 9

1

    if (print) {↵

1

    if (save) {↵

2

                if (separator) {↵

2

                if (separator) {↵

3

                    new MenuItem(result, SWT.SEPARATOR);↵

3

                    new MenuItem(result, SWT.SEPARATOR);↵

4

                    separator = false;↵

4

                    separator = false;↵

5

                }↵

5

                }↵

6

                MenuItem printItem = new MenuItem(result, SWT.NONE);↵

6

                MenuItem saveItem = new MenuItem(result, SWT.NONE);↵

7

                printItem.setText(localizationResources.getString("Print..."));↵

7

                saveItem.setText(localizationResources.getString("Save_as..."));↵

8

                printItem.setData(PRINT_COMMAND);↵

8

                saveItem.setData(SAVE_COMMAND);↵

9

                printItem.addSelectionListener(this);↵

9

                saveItem.addSelectionListener(this);↵

10

                separator = true;↵

10

                separator = true;↵

11

            }

11

            }

See real code fragment |  | See real code fragment

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

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 9
   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) | 2.8
   Clone type | Type 2

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

   18

       if (print)

   18 | if (print)
   9 | if (save)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   print | save | VARIABLE_NAME_MISMATCH

   9

       if (save)

   19

       if (separator)

   10

       if (separator)

   20

       new MenuItem(result, SWT.SEPARATOR);

   11

       new MenuItem(result, SWT.SEPARATOR);

   21

       separator = false;

   12

       separator = false;

   22

       MenuItem printItem = new MenuItem(result, SWT.NONE);

   22 | MenuItem printItem = new MenuItem(result, SWT.NONE);
   13 | MenuItem saveItem = new MenuItem(result, SWT.NONE);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   printItem | saveItem | VARIABLE_NAME_MISMATCH

   13

       MenuItem saveItem = new MenuItem(result, SWT.NONE);

   23

       printItem.setText(localizationResources.getString("Print..."));

   23 | printItem.setText(localizationResources.getString("Print..."));
   14 | saveItem.setText(localizationResources.getString("Save_as..."));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   "Print..." | "Save_as..." | LITERAL_VALUE_MISMATCH
   printItem | saveItem | VARIABLE_NAME_MISMATCH

   14

       saveItem.setText(localizationResources.getString("Save_as..."));

   24

       printItem.setData(PRINT_COMMAND);

   24 | printItem.setData(PRINT_COMMAND);
   15 | saveItem.setData(SAVE_COMMAND);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   PRINT_COMMAND | SAVE_COMMAND | VARIABLE_NAME_MISMATCH
   printItem | saveItem | VARIABLE_NAME_MISMATCH

   15

       saveItem.setData(SAVE_COMMAND);

   25

       printItem.addSelectionListener(this);

   25 | printItem.addSelectionListener(this);
   16 | saveItem.addSelectionListener(this);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   printItem | saveItem | VARIABLE_NAME_MISMATCH

   16

       saveItem.addSelectionListener(this);

   26

       separator = true;

   17

       separator = true;

   Precondition Violations (0)
   Row | Violation
   --- | ---