if(comp instanceof Container) { Container cont = (Container)comp; cont.addContainerListener(this); Component[] comps = cont.getComponents(); for(int i = 0; i < comps.length; i++) { componentAdded(comps[i]); } }
if(comp instanceof Container) { Container cont = (Container)comp; cont.removeContainerListener(this); Component[] comps = cont.getComponents(); for(int i = 0; i < comps.length; i++) { componentRemoved(comps[i]); } }
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/org/gjt/sp/jedit/gui/EnhancedDialog.java File path: /jEdit-4.2/src/org/gjt/sp/jedit/gui/EnhancedDialog.java
Method name: void componentAdded(Component) Method name: void componentRemoved(Component)
Number of AST nodes: 6 Number of AST nodes: 6
1
if(comp instanceof Container)
1
if(comp instanceof Container)
2
			{
2
			{
3
				Container cont = (Container)comp;
3
				Container cont = (Container)comp;
4
				cont.addContainerListener(this);
4
				cont.removeContainerListener(this);
5
				Component[] comps = cont.getComponents();
5
				Component[] comps = cont.getComponents();
6
				for(int i = 0; i < comps.length; i++)
6
				for(int i = 0; i < comps.length; i++)
7
				{
7
				{
8
					componentAdded(comps[i]);
8
					componentRemoved(comps[i]);
9
				}
9
				}
10
			}
10
			}
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 declared in the same class
Number of node comparisons20
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    if (comp instanceof Container)
    2
    if (comp instanceof Container)
    3
    Container cont = (Container)comp;
    3
    Container cont = (Container)comp;
    4
    cont.addContainerListener(this);
    4
    cont.addContainerListener(this);
    4
    cont.removeContainerListener(this);
    Differences
    Expression1Expression2Difference
    addContainerListenerremoveContainerListenerMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression cont.addContainerListener(this) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression cont.removeContainerListener(this) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression cont.addContainerListener(this) is a void method call, and thus it cannot be parameterized
    Expression cont.removeContainerListener(this) is a void method call, and thus it cannot be parameterized
    4
    cont.removeContainerListener(this);
    5
    Component[] comps = cont.getComponents();
    5
    Component[] comps = cont.getComponents();
    6
    for (int i = 0; i < comps.length; i++)
    6
    for (int i = 0; i < comps.length; i++)
    7
    componentAdded(comps[i]);
    7
    componentAdded(comps[i]);
    7
    componentRemoved(comps[i]);
    Differences
    Expression1Expression2Difference
    componentAddedcomponentRemovedMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression componentAdded(comps[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method componentAdded
    Expression componentRemoved(comps[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method componentRemoved
    Expression componentAdded(comps[i]) is a void method call, and thus it cannot be parameterized
    Expression componentRemoved(comps[i]) is a void method call, and thus it cannot be parameterized
    7
    componentRemoved(comps[i]);
    Precondition Violations (8)
    Row Violation
    1Expression cont.addContainerListener(this) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression cont.removeContainerListener(this) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression cont.addContainerListener(this) is a void method call, and thus it cannot be parameterized
    4Expression cont.removeContainerListener(this) is a void method call, and thus it cannot be parameterized
    5Expression componentAdded(comps[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression componentRemoved(comps[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression componentAdded(comps[i]) is a void method call, and thus it cannot be parameterized
    8Expression componentRemoved(comps[i]) is a void method call, and thus it cannot be parameterized