comp.removeKeyListener(keyHandler); 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]); } }
comp.addKeyListener(keyHandler); 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]); } }
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 componentRemoved(Component) Method name: void componentAdded(Component)
Number of AST nodes: 7 Number of AST nodes: 7
1
comp.removeKeyListener(keyHandler);
1
comp.addKeyListener(keyHandler);
2
			if(comp instanceof Container)
2
			if(comp instanceof Container)
3
			{
3
			{
4
				Container cont = (Container)comp;
4
				Container cont = (Container)comp;
5
				cont.removeContainerListener(this);
5
				cont.addContainerListener(this);
6
				Component[] comps = cont.getComponents();
6
				Component[] comps = cont.getComponents();
7
				for(int i = 0; i < comps.length; i++)
7
				for(int i = 0; i < comps.length; i++)
8
				{
8
				{
9
					componentRemoved(comps[i]);
9
					componentAdded(comps[i]);
10
				}
10
				}
11
			}
11
			}
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.3
Clones locationClones are declared in the same class
Number of node comparisons21
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)3.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    comp.removeKeyListener(keyHandler);
    1
    comp.removeKeyListener(keyHandler);
    1
    comp.addKeyListener(keyHandler);
    Differences
    Expression1Expression2Difference
    removeKeyListeneraddKeyListenerMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression comp.removeKeyListener(keyHandler) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression comp.addKeyListener(keyHandler) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression comp.removeKeyListener(keyHandler) is a void method call, and thus it cannot be parameterized
    Expression comp.addKeyListener(keyHandler) is a void method call, and thus it cannot be parameterized
    1
    comp.addKeyListener(keyHandler);
    2
    if (comp instanceof Container)
    2
    if (comp instanceof Container)
    3
    Container cont = (Container)comp;
    3
    Container cont = (Container)comp;
    4
    cont.removeContainerListener(this);
    4
    cont.removeContainerListener(this);
    4
    cont.addContainerListener(this);
    Differences
    Expression1Expression2Difference
    removeContainerListeneraddContainerListenerMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression cont.removeContainerListener(this) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression cont.addContainerListener(this) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression cont.removeContainerListener(this) is a void method call, and thus it cannot be parameterized
    Expression cont.addContainerListener(this) is a void method call, and thus it cannot be parameterized
    4
    cont.addContainerListener(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
    componentRemoved(comps[i]);
    7
    componentRemoved(comps[i]);
    7
    componentAdded(comps[i]);
    Differences
    Expression1Expression2Difference
    componentRemovedcomponentAddedMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    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]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method componentAdded
    Expression componentRemoved(comps[i]) is a void method call, and thus it cannot be parameterized
    Expression componentAdded(comps[i]) is a void method call, and thus it cannot be parameterized
    7
    componentAdded(comps[i]);
    Precondition Violations (12)
    Row Violation
    1Expression comp.removeKeyListener(keyHandler) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression comp.addKeyListener(keyHandler) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression comp.removeKeyListener(keyHandler) is a void method call, and thus it cannot be parameterized
    4Expression comp.addKeyListener(keyHandler) is a void method call, and thus it cannot be parameterized
    5Expression cont.removeContainerListener(this) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression cont.addContainerListener(this) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression cont.removeContainerListener(this) is a void method call, and thus it cannot be parameterized
    8Expression cont.addContainerListener(this) is a void method call, and thus it cannot be parameterized
    9Expression componentRemoved(comps[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression componentAdded(comps[i]) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression componentRemoved(comps[i]) is a void method call, and thus it cannot be parameterized
    12Expression componentAdded(comps[i]) is a void method call, and thus it cannot be parameterized