final Collection<?> theSelection = collection; // Make sure it's okay. // if (theSelection != null && !theSelection.isEmpty()) { // I don't know if this should be run this deferred // because we might have to give the editor a chance to process the viewer update events // and hence to update the views first. // // Runnable runnable = new Runnable() { public void run() { // Try to select the items in the current content viewer of the editor. // if (currentViewer != null) { currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true); } } }; runnable.run(); }
final Collection<?> theSelection = collection; // Make sure it's okay. // if (theSelection != null && !theSelection.isEmpty()) { // I don't know if this should be run this deferred // because we might have to give the editor a chance to process the viewer update events // and hence to update the views first. // // Runnable runnable = new Runnable() { public void run() { // Try to select the items in the current content viewer of the editor. // if (currentViewer != null) { currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true); } } }; runnable.run(); }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/presentation/EcoreEditor.java File path: /emf-2.4.1/src/org/eclipse/emf/mapping/ecore2xml/presentation/Ecore2XMLEditor.java
Method name: void setSelectionToViewer(Collection) Method name: void setSelectionToViewer(Collection)
Number of AST nodes: 4 Number of AST nodes: 4
1
final Collection<?> theSelection = collection;
1
final Collection<?> theSelection = collection;
2
    // Make sure it's okay.
2
    // Make sure it's okay.
3
    //
3
    //
4
    if (theSelection != null && !theSelection.isEmpty())
4
    if (theSelection != null && !theSelection.isEmpty())
5
    {
5
    {
6
      // I don't know if this should be run this deferred
6
      // I don't know if this should be run this deferred
7
      // because we might have to give the editor a chance to process the viewer update events
7
      // because we might have to give the editor a chance to process the viewer update events
8
      // and hence to update the views first.
8
      // and hence to update the views first.
9
      //
9
      //
10
      //
10
      //
11
      Runnable runnable =
11
      Runnable runnable =
12
        new Runnable()
12
        new Runnable()
13
        {
13
        {
14
          public void run()
14
          public void run()
15
          {
15
          {
16
            // Try to select the items in the current content viewer of the editor.
16
            // Try to select the items in the current content viewer of the editor.
17
            //
17
            //
18
            if (currentViewer != null)
18
            if (currentViewer != null)
19
            {
19
            {
20
              currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true);
20
              currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true);
21
            }
21
            }
22
          }
22
          }
23
        };
23
        };
24
      runnable.run();
24
      runnable.run();
25
    }
25
    }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are in different classes having the same super class
Number of node comparisons10
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.7
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
                                                                                                  
    1
    final Collection<?> theSelection = collection;
    1
    final Collection<?> theSelection = collection;
                                                                                                  
    2
    if (theSelection != null && !theSelection.isEmpty())
    2
    if (theSelection != null && !theSelection.isEmpty())
    2
    if (theSelection != null && !theSelection.isEmpty())
    Differences
    Expression1Expression2Difference
    java.util.Collection<>java.util.Collection<>VARIABLE_TYPE_MISMATCH
    java.util.Collection<>java.util.Collection<>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<> of variable theSelection does not match with type java.util.Collection<> of variable theSelection
    • Make classes java.util.Collection<> and java.util.Collection<> extend a common superclass
    Type java.util.Collection<> of variable theSelection does not match with type java.util.Collection<> of variable theSelection
    • Make classes java.util.Collection<> and java.util.Collection<> extend a common superclass
    2
    if (theSelection != null && !theSelection.isEmpty())
    3
    Runnable runnable = new Runnable() {...};
    3
    Runnable runnable = new Runnable() {...};
    3
    Runnable runnable = new Runnable() {...};
    Differences
    Expression1Expression2Difference
    java.util.Collection<>java.util.Collection<>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<> of variable theSelection does not match with type java.util.Collection<> of variable theSelection
    • Make classes java.util.Collection<> and java.util.Collection<> extend a common superclass
    3
    Runnable runnable = new Runnable() {...};
    4
    runnable.run();
    4
    runnable.run();
    Precondition Violations (3)
    Row Violation
    1Type java.util.Collection<> of variable theSelection does not match with type java.util.Collection<> of variable theSelection
    2Type java.util.Collection<> of variable theSelection does not match with type java.util.Collection<> of variable theSelection
    3Type java.util.Collection<> of variable theSelection does not match with type java.util.Collection<> of variable theSelection