if (comp == null) { throw new IllegalArgumentException("Component == null"); } switch (menuId) { case IMenuIDs.PLUGINS_MENU : { _pluginsMenu.add(comp); break; } case IMenuIDs.SESSION_MENU : { _sessionMenu.add(comp); break; } default : { throw new IllegalArgumentException("Invalid menuId passed: " + menuId); } }
if (action == null) { throw new IllegalArgumentException("Null Action passed"); } switch (menuId) { case IMenuIDs.PLUGINS_MENU : { _pluginsMenu.add(action); break; } case IMenuIDs.SESSION_MENU : { _sessionMenu.add(action); break; } default : { throw new IllegalArgumentException("Invalid menuId passed: " + menuId); } }
Clone fragments detected by clone detection tool
File path: /sql12/app/src/net/sourceforge/squirrel_sql/client/gui/mainframe/MainFrameMenuBar.java File path: /sql12/app/src/net/sourceforge/squirrel_sql/client/gui/mainframe/MainFrameMenuBar.java
Method name: void addToMenu(int, Component) Method name: void addToMenu(int, Action)
Number of AST nodes: 11 Number of AST nodes: 11
1
if (comp == null)
1
if (action == null)
2
		{
2
		{
3
			throw new IllegalArgumentException("Component == null");
3
			throw new IllegalArgumentException("Null Action passed");
4
		}
4
		}
5
		switch (menuId)
5
		switch (menuId)
6
		{
6
		{
7
			case IMenuIDs.PLUGINS_MENU :
7
			case IMenuIDs.PLUGINS_MENU :
8
			{
8
			{
9
				_pluginsMenu.add(comp);
9
				_pluginsMenu.add(action);
10
				break;
10
				break;
11
			}
11
			}
12
			case IMenuIDs.SESSION_MENU :
12
			case IMenuIDs.SESSION_MENU :
13
			{
13
			{
14
				_sessionMenu.add(comp);
14
				_sessionMenu.add(action);
15
				break;
15
				break;
16
			}
16
			}
17
			default :
17
			default :
18
			{
18
			{
19
				throw new IllegalArgumentException("Invalid menuId passed: " + menuId);
19
				throw new IllegalArgumentException("Invalid menuId passed: " + menuId);
20
			}
20
			}
21
		}
21
		}
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 declared in the same class
Number of node comparisons50
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    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.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (comp == null)
    1
    if (comp == null)
    1
    if (action == null)
    Differences
    Expression1Expression2Difference
    compactionVARIABLE_NAME_MISMATCH
    java.awt.Componentjavax.swing.ActionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.awt.Component of variable comp does not match with type javax.swing.Action of variable action
    • Make classes java.awt.Component and javax.swing.Action extend a common superclass
    1
    if (action == null)
    2
    throw new IllegalArgumentException("Component == null");
    2
    throw new IllegalArgumentException("Component == null");
    2
    throw new IllegalArgumentException("Null Action passed");
    Differences
    Expression1Expression2Difference
    "Component == null""Null Action passed"LITERAL_VALUE_MISMATCH
    2
    throw new IllegalArgumentException("Null Action passed");
    3
    switch (menuId)
    3
    switch (menuId)
    4
    case IMenuIDs.PLUGINS_MENU:
    4
    case IMenuIDs.PLUGINS_MENU:
    5
    _pluginsMenu.add(comp);
    5
    _pluginsMenu.add(comp);
    5
    _pluginsMenu.add(action);
    Differences
    Expression1Expression2Difference
    compactionVARIABLE_NAME_MISMATCH
    java.awt.Componentjavax.swing.ActionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.awt.Component of variable comp does not match with type javax.swing.Action of variable action
    • Make classes java.awt.Component and javax.swing.Action extend a common superclass
    5
    _pluginsMenu.add(action);
    6
    break;
    6
    break;
    7
    case IMenuIDs.SESSION_MENU:
    7
    case IMenuIDs.SESSION_MENU:
    8
    _sessionMenu.add(comp);
    8
    _sessionMenu.add(comp);
    8
    _sessionMenu.add(action);
    Differences
    Expression1Expression2Difference
    compactionVARIABLE_NAME_MISMATCH
    java.awt.Componentjavax.swing.ActionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.awt.Component of variable comp does not match with type javax.swing.Action of variable action
    • Make classes java.awt.Component and javax.swing.Action extend a common superclass
    8
    _sessionMenu.add(action);
    9
    break;
    9
    break;
    10
    default:
    10
    default:
    11
    throw new IllegalArgumentException("Invalid menuId passed: " + menuId);
    11
    throw new IllegalArgumentException("Invalid menuId passed: " + menuId);
    Precondition Violations (3)
    Row Violation
    1Type java.awt.Component of variable comp does not match with type javax.swing.Action of variable action
    2Type java.awt.Component of variable comp does not match with type javax.swing.Action of variable action
    3Type java.awt.Component of variable comp does not match with type javax.swing.Action of variable action