Community
Participate
Working Groups
Build Identifier: This is Ken Cheung, a Computer Science M.Phil. student. I observed some code clones in Tomcat and found inconsistent code: /e4/org.eclipse.e4.xwt/bundles/org.eclipse.e4.xwt.tools.ui.designer.core/src/org/eclipse/e4/xwt/tools/ui/designer/core/util/swt/GridLayoutHelper.java 184 Control child = children[i]; 185 GridData data = (GridData) child.getLayoutData(); 186 if (data == null) 187 child.setLayoutData(data = new GridData()); 188 runComputeSize(data, new Object[] { child, 189 Integer.valueOf(data.widthHint), 190 Integer.valueOf(data.heightHint), Boolean.FALSE }); 191 if (data.grabExcessHorizontalSpace && data.minimumWidth > 0) { 192 if (getCacheWidth(data) < data.minimumWidth) { 193 int trim = 0; 194 // TEMPORARY CODE 195 if (child instanceof Scrollable) { 196 Rectangle rect = ((Scrollable) child).computeTrim(0, 0, 197 0, 0); 198 trim = rect.width; 199 } else { 200 trim = child.getBorderWidth() * 2; 201 } 202 putCacheWidth(data, SWT.DEFAULT); 203 putCacheHeight(data, SWT.DEFAULT); 204 runComputeSize(data, new Object[] { child, 205 Integer.valueOf(Math.max(0, data.minimumWidth 206 - trim)), Integer.valueOf(data.heightHint), 207 Boolean.FALSE }); 208 } 209 } 210 if (data.grabExcessVerticalSpace && data.minimumHeight > 0) { 211 putCacheHeight(data, Math.max(getCacheHeight(data), 212 data.minimumHeight)); 213 } /e4/org.eclipse.e4.xwt/bundles/org.eclipse.e4.xwt.tools.ui.designer.core/src/org/eclipse/e4/xwt/tools/ui/designer/core/util/swt/GridLayoutHelper.java 480 for (int k = 0; k < hSpan; k++) { 481 currentWidth += widths[j - k]; 482 } 483 currentWidth += (hSpan - 1) 484 * fGridLayout.horizontalSpacing 485 - data.horizontalIndent; 486 if ((currentWidth != getCacheWidth(data) && data.horizontalAlignment == SWT.FILL) 487 || (getCacheWidth(data) > currentWidth)) { 488 int trim = 0; 489 if (child instanceof Scrollable) { 490 Rectangle rect = ((Scrollable) child) 491 .computeTrim(0, 0, 0, 0); 492 trim = rect.width; 493 } else { 494 trim = child.getBorderWidth() * 2; 495 } 496 putCacheWidth(data, SWT.DEFAULT); 497 putCacheHeight(data, SWT.DEFAULT); 498 runComputeSize(data, new Object[] { 499 child, 500 Integer.valueOf(Math.max(0, 501 currentWidth - trim)), 502 Integer.valueOf(data.heightHint), 503 Boolean.FALSE }); 504 if (data.grabExcessVerticalSpace 505 && data.minimumHeight > 0) { 506 putCacheHeight(data, Math.max( 507 getCacheHeight(data), 508 data.minimumHeight)); 509 } } Quick description of the inconsistency Two code snippets are very similar code, but as you see, the first code uses data.minimumWidth in function runComputerSizefrom while the second code uses currentWidth from the computation of for loop. We thought it could be a potential bug or inconsistency. Hope this helps. Reproducible: Didn't try
The code clones should be in Eclipse instead of Tomcat. It is a typo. May I know if this is a bug? Thank you.
May I confirm if this is a bug? Thank you.