1476-1-3

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

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

1

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

1

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

2

     ↵

2

        // No font is a good default.↵

3

        // No color is a good default.↵

3

        //↵

4

        //↵

4

        Font result = null;↵

5

        Color result = null;↵

6

     ↵

5

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

7

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

6

        //↵

8

        //↵

7

        if (tableItemFontProvider  != null)↵

9

        if (tableItemColorProvider  != null)↵

8

        {↵

10

        {↵

9

          // And delegate the call.↵

11

          // And delegate the call.↵

10

          //↵

12

          //↵

11

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

13

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

12

        }↵

14

        }↵

13

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

15

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

14

        //↵

16

        //↵

15

        else↵

17

        else↵

16

        {↵

18

        {↵

17

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

19

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

18

          if (itemFontProvider != null)↵

20

          if (itemColorProvider != null)↵

19

          {↵

21

          {↵

20

            // And delegate the call.↵

22

            // And delegate the call.↵

21

            //↵

23

            //↵

22

            result = getFontFromObject(itemFontProvider.getFont(object));↵

24

            result = getColorFromObject(itemColorProvider.getBackground(object));↵

23

          }↵

25

          }↵

24

        }↵

26

        }↵

25

        return result;

27

        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.3
   Clone type | Type 2

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

   1

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

   1

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

   2

       Font result = null;

   2 | Font result = null;
   2 | Color result = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.eclipse.swt.graphics.Font | org.eclipse.swt.graphics.Color | SUBCLASS_TYPE_MISMATCH
   org.eclipse.swt.graphics.Font | org.eclipse.swt.graphics.Color | SUBCLASS_TYPE_MISMATCH

   2

       Color result = null;

   3

       if (tableItemFontProvider != null)

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

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

   Preondition Violations

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

   3

       if (tableItemColorProvider != null)

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

   Preondition Violations
   Unmatched statement result=getColorFromObject(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

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

   4

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

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

   Preondition Violations
   Unmatched statement result=getFontFromObject(tableItemFontProvider.getFont(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

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

   5

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

   6

       if (itemFontProvider != null)

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

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

   Preondition Violations

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

   6

       if (itemColorProvider != null)

   7 | result = getColorFromObject(itemColorProvider.getBackground(object));

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

   7

       result = getColorFromObject(itemColorProvider.getBackground(object));

   7

       result = getFontFromObject(itemFontProvider.getFont(object));

   7 | result = getFontFromObject(itemFontProvider.getFont(object));

   Preondition Violations
   Unmatched statement result=getFontFromObject(itemFontProvider.getFont(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;
   8 | return result;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.eclipse.swt.graphics.Font | org.eclipse.swt.graphics.Color | SUBCLASS_TYPE_MISMATCH

   8

       return result;

   Precondition Violations (7)
   Row | Violation
   --- | ---
   1 | Type org.eclipse.emf.edit.provider.ITableItemFontProvider of variable tableItemFontProvider does not match with type org.eclipse.emf.edit.provider.ITableItemColorProvider of variable tableItemColorProvider
   2 | Unmatched statement result=getColorFromObject(tableItemColorProvider.getBackground(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=getFontFromObject(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 | Type org.eclipse.emf.edit.provider.IItemFontProvider of variable itemFontProvider does not match with type org.eclipse.emf.edit.provider.IItemColorProvider of variable itemColorProvider
   5 | Unmatched statement result=getColorFromObject(itemColorProvider.getBackground(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=getFontFromObject(itemFontProvider.getFont(object)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   7 | Clone fragment #1 returns variable result with type org.eclipse.swt.graphics.Font , while Clone fragment #2 returns variable result with type org.eclipse.swt.graphics.Color