private void toggleComponents(JMeterTreeNode[] nodes) { GuiPackage pack = GuiPackage.getInstance(); for (int i = 0; i < nodes.length; i++) { boolean enable = !nodes[i].isEnabled(); nodes[i].setEnabled(enable); pack.getGui(nodes[i].getTestElement()).setEnabled(enable); } }
private void enableComponents(JMeterTreeNode[] nodes, boolean enable) { GuiPackage pack = GuiPackage.getInstance(); for (JMeterTreeNode node : nodes) { node.setEnabled(enable); pack.getGui(node.getTestElement()).setEnabled(enable); } }
Clone fragments detected by clone detection tool
File path: /apache-jmeter-2.11/src/core/org/apache/jmeter/gui/action/EnableComponent.java File path: /apache-jmeter-2.11/src/core/org/apache/jmeter/gui/action/EnableComponent.java
Method name: void toggleComponents(JMeterTreeNode[]) Method name: void enableComponents(JMeterTreeNode[], boolean)
Number of AST nodes: 4 Number of AST nodes: 3
1
private void toggleComponents(JMeterTreeNode[] nodes) {
1
private void enableComponents(JMeterTreeNode[] nodes, boolean enable) {
2
        GuiPackage pack = GuiPackage.getInstance();
2
        GuiPackage pack = GuiPackage.getInstance();
3
        for (int i = 0; i < nodes.length; i++) {
3
        for (JMeterTreeNode node : nodes) {
4
            boolean enable = !nodes[i].isEnabled();
4
            node.setEnabled(enable);
5
            nodes[i].setEnabled(enable);
5
            pack.getGui(node.getTestElement()).setEnabled(enable);
6
            pack.getGui(nodes[i].getTestElement()).setEnabled(enable);
6
        }
7
        }
7
    }
8
    }
  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 fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.600
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    2
    for (int i = 0; i < nodes.length; i++)
    2
    for (JMeterTreeNode node : nodes)
    3
    boolean enable = !nodes[i].isEnabled();
    3
    boolean enable = !nodes[i].isEnabled();
    Preondition Violations
    Unmatched statement boolean enable=!nodes[i].isEnabled(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                    
    4
    nodes[i].setEnabled(enable);
    4
    nodes[i].setEnabled(enable);
    3
    node.setEnabled(enable);
    Differences
    Expression1Expression2Difference
    nodes[i]nodeTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression nodes[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression node cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    node.setEnabled(enable);
    5
    pack.getGui(nodes[i].getTestElement()).setEnabled(enable);
    5
    pack.getGui(nodes[i].getTestElement()).setEnabled(enable);
    4
    pack.getGui(node.getTestElement()).setEnabled(enable);
    Differences
    Expression1Expression2Difference
    nodes[i]nodeTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression nodes[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression node cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4
    pack.getGui(node.getTestElement()).setEnabled(enable);
    Precondition Violations (6)
    Row Violation
    1Unmatched statement boolean enable=!nodes[i].isEnabled(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Expression nodes[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression node cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression nodes[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression node cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Clone fragment #1 returns variables i , while Clone fragment #2 returns variables