1295-1-3

ITableItemColorProvider tableItemColorProvider = (ITableItemColorProvider)adapterFactory.adapt(object, ITableItemColorProvider.class); // No color is a good default. // Object result = null; // Now we could check that the adapter implements interface ITableItemColorProvider. // if (tableItemColorProvider != null) { // And delegate the call. // result = tableItemColorProvider.getBackground(object, columnIndex); } // Otherwise, we could check that the adapter implements interface IItemColorProvider. // else { IItemColorProvider itemColorProvider = (IItemColorProvider)adapterFactory.adapt(object, IItemColorProvider.class); if (itemColorProvider != null) { // And delegate the call. // result = itemColorProvider.getBackground(object); } } return result;
ITableItemFontProvider tableItemFontProvider = (ITableItemFontProvider)adapterFactory.adapt(object, ITableItemFontProvider.class); // No font is a good default. // Object result = null; // Now we could check that the adapter implements interface ITableItemFontProvider. // if (tableItemFontProvider != null) { // And delegate the call. // result = tableItemFontProvider.getFont(object, columnIndex); } // Otherwise, we could check that the adapter implements interface IItemFontProvider. // else { IItemFontProvider itemFontProvider = (IItemFontProvider)adapterFactory.adapt(object, IItemFontProvider.class); if (itemFontProvider != null) { // And delegate the call. // result = itemFontProvider.getFont(object); } } return result;

Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/edit/provider/AdapterFactoryItemDelegator.java |  | File path: /emf-2.4.1/src/org/eclipse/emf/edit/provider/AdapterFactoryItemDelegator.java
Method name: `Object getBackground(Object, int)` |  | Method name: `Object getFont(Object, int)`
Number of AST nodes: 8 |  | Number of AST nodes: 8

1

    ITableItemColorProvider tableItemColorProvider = (ITableItemColorProvider)adapterFactory.adapt(object, ITableItemColorProvider.class);↵

1

    ITableItemFontProvider tableItemFontProvider = (ITableItemFontProvider)adapterFactory.adapt(object, ITableItemFontProvider.class);↵

2

        // No color is a good default.↵

2

        // No font is a good default.↵

3

        //↵

3

        //↵

4

        Object result = null;↵

4

        Object result = null;↵

5

        // Now we could check that the adapter implements interface ITableItemColorProvider.↵

5

        // Now we could check that the adapter implements interface ITableItemFontProvider.↵

6

        //↵

6

        //↵

7

        if (tableItemColorProvider  != null)↵

7

        if (tableItemFontProvider  != null)↵

8

        {↵

8

        {↵

9

          // And delegate the call.↵

9

          // And delegate the call.↵

10

          //↵

10

          //↵

11

          result = tableItemColorProvider.getBackground(object, columnIndex);↵

11

          result = tableItemFontProvider.getFont(object, columnIndex);↵

12

        }↵

12

        }↵

13

        // Otherwise, we could check that the adapter implements interface IItemColorProvider.↵

13

        // Otherwise, we could check that the adapter implements interface IItemFontProvider.↵

14

        //↵

14

        //↵

15

        else↵

15

        else↵

16

        {↵

16

        {↵

17

          IItemColorProvider itemColorProvider = (IItemColorProvider)adapterFactory.adapt(object, IItemColorProvider.class);↵

17

          IItemFontProvider itemFontProvider = (IItemFontProvider)adapterFactory.adapt(object, IItemFontProvider.class);↵

18

          if (itemColorProvider != null)↵

18

          if (itemFontProvider != null)↵

19

          {↵

19

          {↵

20

            // And delegate the call.↵

20

            // And delegate the call.↵

21

            //↵

21

            //↵

22

            result = itemColorProvider.getBackground(object);↵

22

            result = itemFontProvider.getFont(object);↵

23

          }↵

23

          }↵

24

        }↵

24

        }↵

25

        return result;

25

        return result;

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.2
Clones location | Clones are declared in the same class
Number of node comparisons | 22

1. {Non-refactorable}

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

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

   1

       ITableItemFontProvider tableItemFontProvider = (ITableItemFontProvider)adapterFactory.adapt(object, ITableItemFontProvider.class);

   1

       ITableItemColorProvider tableItemColorProvider = (ITableItemColorProvider)adapterFactory.adapt(object, ITableItemColorProvider.class);

   2

       Object result = null;

   2

       Object result = null;

   3

       if (tableItemColorProvider != null)

   3 | if (tableItemColorProvider != null)
   3 | if (tableItemFontProvider != null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   tableItemColorProvider | tableItemFontProvider | VARIABLE_NAME_MISMATCH
   org.eclipse.emf.edit.provider.ITableItemColorProvider | org.eclipse.emf.edit.provider.ITableItemFontProvider | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.eclipse.emf.edit.provider.ITableItemColorProvider of variable tableItemColorProvider does not match with type org.eclipse.emf.edit.provider.ITableItemFontProvider of variable tableItemFontProvider
   - Make classes org.eclipse.emf.edit.provider.ITableItemColorProvider and org.eclipse.emf.edit.provider.ITableItemFontProvider extend a common superclass

   3

       if (tableItemFontProvider != null)

   4 | result = tableItemFontProvider.getFont(object, columnIndex);

   Preondition Violations
   Unmatched statement result=tableItemFontProvider.getFont(object,columnIndex); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   4

       result = tableItemFontProvider.getFont(object, columnIndex);

   4

       result = tableItemColorProvider.getBackground(object, columnIndex);

   4 | result = tableItemColorProvider.getBackground(object, columnIndex);

   Preondition Violations
   Unmatched statement result=tableItemColorProvider.getBackground(object,columnIndex); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

       else

       else

   5

       IItemFontProvider itemFontProvider = (IItemFontProvider)adapterFactory.adapt(object, IItemFontProvider.class);

   5

       IItemColorProvider itemColorProvider = (IItemColorProvider)adapterFactory.adapt(object, IItemColorProvider.class);

   6

       if (itemColorProvider != null)

   6 | if (itemColorProvider != null)
   6 | if (itemFontProvider != null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   itemColorProvider | itemFontProvider | VARIABLE_NAME_MISMATCH
   org.eclipse.emf.edit.provider.IItemColorProvider | org.eclipse.emf.edit.provider.IItemFontProvider | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.eclipse.emf.edit.provider.IItemColorProvider of variable itemColorProvider does not match with type org.eclipse.emf.edit.provider.IItemFontProvider of variable itemFontProvider
   - Make classes org.eclipse.emf.edit.provider.IItemColorProvider and org.eclipse.emf.edit.provider.IItemFontProvider extend a common superclass

   6

       if (itemFontProvider != null)

   7 | result = itemFontProvider.getFont(object);

   Preondition Violations
   Unmatched statement result=itemFontProvider.getFont(object); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   7

       result = itemFontProvider.getFont(object);

   7

       result = itemColorProvider.getBackground(object);

   7 | result = itemColorProvider.getBackground(object);

   Preondition Violations
   Unmatched statement result=itemColorProvider.getBackground(object); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   8

       return result;

   8

       return result;

   Precondition Violations (6)
   Row | Violation
   --- | ---
   1 | Type org.eclipse.emf.edit.provider.ITableItemColorProvider of variable tableItemColorProvider does not match with type org.eclipse.emf.edit.provider.ITableItemFontProvider of variable tableItemFontProvider
   2 | Unmatched statement result=tableItemFontProvider.getFont(object,columnIndex); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   3 | Unmatched statement result=tableItemColorProvider.getBackground(object,columnIndex); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   4 | Type org.eclipse.emf.edit.provider.IItemColorProvider of variable itemColorProvider does not match with type org.eclipse.emf.edit.provider.IItemFontProvider of variable itemFontProvider
   5 | Unmatched statement result=itemFontProvider.getFont(object); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   6 | Unmatched statement result=itemColorProvider.getBackground(object); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted