Handler handler = null; for (int i = 0; i < macroHandlers.size(); i++) { handler = (Handler)macroHandlers.get(i); if (handler.getName().equals(name)) return handler; } return null;
for(int i = 0; i < modes.size(); i++) { Mode mode = (Mode)modes.elementAt(i); if(mode.getName().equals(name)) return mode; } return null;
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/org/gjt/sp/jedit/Macros.java File path: /jEdit-4.2/src/org/gjt/sp/jedit/jEdit.java
Method name: Handler getHandler(String) Method name: Mode getMode(String)
Number of AST nodes: 6 Number of AST nodes: 5
1
Handler handler = null;
2
		for (int i = 0; i < macroHandlers.size(); i++)
1
for(int i = 0; i < modes.size(); i++)
3
		{
2
		{
4
			handler = (Handler)macroHandlers.get(i);
3
			Mode mode = (Mode)modes.elementAt(i);
5
			if (handler.getName().equals(name)) 
4
			if(mode.getName().equals(name))
6
return handler;
5
				return mode;
7
		}
6
		}
8
		return null;
7
		return null;
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.4
Clones locationClones are in different classes
Number of node comparisons10
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment2
    Time elapsed for statement mapping (ms)1.0
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    Handler handler = null;
                                                    
    2
    for (int i = 0; i < macroHandlers.size(); i++)
    2
    for (int i = 0; i < macroHandlers.size(); i++)
    1
    for (int i = 0; i < modes.size(); i++)
    Differences
    Expression1Expression2Difference
    macroHandlersmodesVARIABLE_NAME_MISMATCH
    java.util.ArrayListjava.util.VectorSUBCLASS_TYPE_MISMATCH
    1
    for (int i = 0; i < modes.size(); i++)
                                                                                
    2
    Mode mode = (Mode)modes.elementAt(i);
    Preondition Violations
    Unmatched statement Mode mode=(Mode)modes.elementAt(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2
    Mode mode = (Mode)modes.elementAt(i);
    3
    handler = (Handler)macroHandlers.get(i);
    3
    handler = (Handler)macroHandlers.get(i);
    Preondition Violations
    Unmatched statement handler=(Handler)macroHandlers.get(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                      
    4
    if (handler.getName().equals(name))
    4
    if (handler.getName().equals(name))
    3
    if (mode.getName().equals(name))
    Differences
    Expression1Expression2Difference
    handlermodeVARIABLE_NAME_MISMATCH
    org.gjt.sp.jedit.Macros.Handlerorg.gjt.sp.jedit.ModeVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.gjt.sp.jedit.Macros.Handler of variable handler does not match with type org.gjt.sp.jedit.Mode of variable mode
    • Make classes org.gjt.sp.jedit.Macros.Handler and org.gjt.sp.jedit.Mode extend a common superclass
    3
    if (mode.getName().equals(name))
                                  
    4
    return mode;
    Preondition Violations
    Unmatched return mode;
    4
    return mode;
    5
    return handler;
    5
    return handler;
    Preondition Violations
    Unmatched return handler;
                                        
    6
    return null;
    5
    return null;
    Precondition Violations (5)
    Row Violation
    1Unmatched statement Mode mode=(Mode)modes.elementAt(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement handler=(Handler)macroHandlers.get(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Type org.gjt.sp.jedit.Macros.Handler of variable handler does not match with type org.gjt.sp.jedit.Mode of variable mode
    4Unmatched return mode;
    5Unmatched return handler;