for (current = newMatch; current != null; current = current.next) { recurrent = (REMatch) current.clone(); if (token.match(input, recurrent)) { // add all items in current to doables array if (doables == null) { doables = recurrent; doablesLast = recurrent; } else { // Order these from longest to shortest // Start by assuming longest (more repeats) doablesLast.next = recurrent; } // Find new doablesLast while (doablesLast.next != null) { doablesLast = doablesLast.next; } } }
for (current = newMatch; current != null; current = current.next) { // clone() separates a single match from the chain single = (REMatch) current.clone(); if (next(input, single)) { // chain results to doneIndex if (doneIndex == null) { doneIndex = single; doneIndexLast = single; } else { doneIndexLast.next = single; } // Find new doneIndexLast while (doneIndexLast.next != null) { doneIndexLast = doneIndexLast.next; } } }
Clone fragments detected by clone detection tool
File path: /jEdit-4.2/src/gnu/regexp/RETokenRepeated.java File path: /jEdit-4.2/src/gnu/regexp/RETokenRepeated.java
Method name: boolean match(CharIndexed, REMatch) Method name: REMatch matchRest(CharIndexed, REMatch)
Number of AST nodes: 9 Number of AST nodes: 9
1
for (current = newMatch; current != null; current = current.next) {
1
for (current = newMatch; current != null; current = current.next) {
2
		recurrent
2
	    // clone() separates a single match from the chain
3
 = (REMatch) current.clone();
3
	    single = (REMatch) current.clone();
4
		if (token.match(input, recurrent)) {
4
	
5
		    // add all items in current to doables array
6
		    if (doables == null) {
7
			doables = recurrent;
8
			doablesLast = recurrent;
9
		    } else {
10
			// Order these from longest to shortest
11
			// Start by assuming longest (more repeats)
12
			doablesLast.next = recurrent;
13
		    }
14
		    
5
    if (next(input, single)) {
6
		// chain results to doneIndex
7
		if (doneIndex == null) {
8
		    doneIndex = single;
9
		    doneIndexLast = single;
10
		} else {
11
		    doneIndexLast.next = single;
12
		}
15
// Find new doablesLast
13
		// Find new doneIndexLast
16
		    while (doablesLast.next != null) {
14
		while (doneIndexLast.next != null) {
17
			doablesLast = doablesLast.next;
15
		    doneIndexLast = doneIndexLast.next;
18
		
16
		}
19
    }
17
	    }
20
		}
18
	
21
	    }
19
}
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.5
Clones locationClones are declared in the same class
Number of node comparisons38
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)66.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    17
    for (current = newMatch; current != null; current = current.next)
    4
    for (current = newMatch; current != null; current = current.next)
    18
    recurrent = (REMatch)current.clone();
    18
    recurrent = (REMatch)current.clone();
    5
    single = (REMatch)current.clone();
    Differences
    Expression1Expression2Difference
    recurrentsingleVARIABLE_NAME_MISMATCH
    5
    single = (REMatch)current.clone();
    19
    if (token.match(input, recurrent))
    19
    if (token.match(input, recurrent))
    6
    if (next(input, single))
    Differences
    Expression1Expression2Difference
    matchnextMETHOD_INVOCATION_NAME_MISMATCH
    recurrentsingleVARIABLE_NAME_MISMATCH
    tokenMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression token.match(input,recurrent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression next(input,single) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression token.match(input,recurrent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression next(input,single) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    if (next(input, single))
    20
    if (doables == null)
    20
    if (doables == null)
    7
    if (doneIndex == null)
    Differences
    Expression1Expression2Difference
    doablesdoneIndexVARIABLE_NAME_MISMATCH
    7
    if (doneIndex == null)
    21
    doables = recurrent;
    21
    doables = recurrent;
    8
    doneIndex = single;
    Differences
    Expression1Expression2Difference
    doablesdoneIndexVARIABLE_NAME_MISMATCH
    recurrentsingleVARIABLE_NAME_MISMATCH
    8
    doneIndex = single;
    22
    doablesLast = recurrent;
    22
    doablesLast = recurrent;
    9
    doneIndexLast = single;
    Differences
    Expression1Expression2Difference
    doablesLastdoneIndexLastVARIABLE_NAME_MISMATCH
    recurrentsingleVARIABLE_NAME_MISMATCH
    9
    doneIndexLast = single;
    else
    else
    23
    doablesLast.next = recurrent;
    23
    doablesLast.next = recurrent;
    10
    doneIndexLast.next = single;
    Differences
    Expression1Expression2Difference
    doablesLastdoneIndexLastVARIABLE_NAME_MISMATCH
    recurrentsingleVARIABLE_NAME_MISMATCH
    10
    doneIndexLast.next = single;
    24
    while (doablesLast.next != null)
    24
    while (doablesLast.next != null)
    11
    while (doneIndexLast.next != null)
    Differences
    Expression1Expression2Difference
    doablesLastdoneIndexLastVARIABLE_NAME_MISMATCH
    11
    while (doneIndexLast.next != null)
    25
    doablesLast = doablesLast.next;
    25
    doablesLast = doablesLast.next;
    12
    doneIndexLast = doneIndexLast.next;
    Differences
    Expression1Expression2Difference
    doablesLastdoneIndexLastVARIABLE_NAME_MISMATCH
    doablesLastdoneIndexLastVARIABLE_NAME_MISMATCH
    12
    doneIndexLast = doneIndexLast.next;
    Precondition Violations (5)
    Row Violation
    1Expression token.match(input,recurrent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression next(input,single) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression token.match(input,recurrent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression next(input,single) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variables doables, current , while Clone fragment #2 returns variables doneIndex