for(int i = 2; i < comp.length; i++) { int btnWidth = comp[i].getPreferredSize().width; if(btnWidth + x > width) { returnValue.height += rowHeight; x = insets.left; } x += btnWidth; }
for(int i = 2; i < comp.length; i++) { int btnHeight = comp[i].getPreferredSize().height; if(btnHeight + y > height) { returnValue.width += colWidth; y = insets.top; } y += btnHeight; }
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/org/gjt/sp/jedit/gui/PanelWindowContainer.java File path: /jEdit-4.2/src/org/gjt/sp/jedit/gui/PanelWindowContainer.java
Method name: Dimension preferredLayoutSize(Container) Method name: Dimension preferredLayoutSize(Container)
Number of AST nodes: 6 Number of AST nodes: 6
1
for(int i = 2; i < comp.length; i++)
1
for(int i = 2; i < comp.length; i++)
2
				{
2
				{
3
					int btnWidth = comp[i].getPreferredSize().width;
3
					int btnHeight = comp[i].getPreferredSize().height;
4
					if(btnWidth + x > width)
4
					if(btnHeight + y > height)
5
					{
5
					{
6
						returnValue.height += rowHeight;
6
						returnValue.width += colWidth;
7
						x = insets.left;
7
						y = insets.top;
8
					}
8
					}
9
					x += btnWidth;
9
					y += btnHeight;
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.3
Clones locationClones are in the same method
Number of node comparisons18
  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.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    11
    for (int i = 2; i < comp.length; i++)
    22
    for (int i = 2; i < comp.length; i++)
    12
    int btnWidth = comp[i].getPreferredSize().width;
    12
    int btnWidth = comp[i].getPreferredSize().width;
    23
    int btnHeight = comp[i].getPreferredSize().height;
    Differences
    Expression1Expression2Difference
    btnWidthbtnHeightVARIABLE_NAME_MISMATCH
    widthheightVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression comp[i].getPreferredSize().width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression comp[i].getPreferredSize().height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23
    int btnHeight = comp[i].getPreferredSize().height;
    13
    if (btnWidth + x > width)
    13
    if (btnWidth + x > width)
    24
    if (btnHeight + y > height)
    Differences
    Expression1Expression2Difference
    btnWidthbtnHeightVARIABLE_NAME_MISMATCH
    xyVARIABLE_NAME_MISMATCH
    widthheightVARIABLE_NAME_MISMATCH
    24
    if (btnHeight + y > height)
    14
    returnValue.height += rowHeight;
    14
    returnValue.height += rowHeight;
    25
    returnValue.width += colWidth;
    Differences
    Expression1Expression2Difference
    heightwidthVARIABLE_NAME_MISMATCH
    rowHeightcolWidthVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression returnValue.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression returnValue.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    25
    returnValue.width += colWidth;
    15
    x = insets.left;
    15
    x = insets.left;
    26
    y = insets.top;
    Differences
    Expression1Expression2Difference
    xyVARIABLE_NAME_MISMATCH
    lefttopVARIABLE_NAME_MISMATCH
    26
    y = insets.top;
    16
    x += btnWidth;
    16
    x += btnWidth;
    27
    y += btnHeight;
    Differences
    Expression1Expression2Difference
    xyVARIABLE_NAME_MISMATCH
    btnWidthbtnHeightVARIABLE_NAME_MISMATCH
    27
    y += btnHeight;
    Precondition Violations (4)
    Row Violation
    1Expression comp[i].getPreferredSize().width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression comp[i].getPreferredSize().height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression returnValue.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression returnValue.width cannot be parameterized, because it has dependencies to/from statements that will be extracted