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; } } }
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; } } }
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: REMatch matchRest(CharIndexed, REMatch) Method name: boolean match(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
	    // clone() separates a single match from the chain
2
	
3
	    single = (REMatch) current.clone();
3
	recurrent = (REMatch) current.clone();
4
	    if (next(input, single)) {
4
		if (token.match(input, recurrent)) {
5
		// chain results to doneIndex
5
		
6
		if (doneIndex == null) {
7
		    doneIndex = single;
8
		    doneIndexLast = single;
9
		} else {
10
		    doneIndexLast.next = single;
11
		}
12
		
6
    // add all items in current to doables array
7
		    if (doables == null) {
8
			doables = recurrent;
9
			doablesLast = recurrent;
10
		    } else {
11
			// Order these from longest to shortest
12
			// Start by assuming longest (more repeats)
13
			doablesLast.next = recurrent;
14
		    }
13
// Find new doneIndexLast
15
		    // Find new doablesLast
14
		while (doneIndexLast.next != null) {
16
		    while (doablesLast.next != null) {
15
		    doneIndexLast = doneIndexLast.next;
17
			doablesLast = doablesLast.next;
16
		
18
		    }
17
}
19
		}
18
	    }
20
	    }
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)1.8
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)128.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    for (current = newMatch; current != null; current = current.next)
    17
    for (current = newMatch; current != null; current = current.next)
    5
    single = (REMatch)current.clone();
    5
    single = (REMatch)current.clone();
    18
    recurrent = (REMatch)current.clone();
    Differences
    Expression1Expression2Difference
    singlerecurrentVARIABLE_NAME_MISMATCH
    18
    recurrent = (REMatch)current.clone();
    6
    if (next(input, single))
    6
    if (next(input, single))
    19
    if (token.match(input, recurrent))
    Differences
    Expression1Expression2Difference
    nextmatchMETHOD_INVOCATION_NAME_MISMATCH
    singlerecurrentVARIABLE_NAME_MISMATCH
    tokenMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    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
    Expression token.match(input,recurrent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19
    if (token.match(input, recurrent))
    7
    if (doneIndex == null)
    7
    if (doneIndex == null)
    20
    if (doables == null)
    Differences
    Expression1Expression2Difference
    doneIndexdoablesVARIABLE_NAME_MISMATCH
    20
    if (doables == null)
    8
    doneIndex = single;
    8
    doneIndex = single;
    21
    doables = recurrent;
    Differences
    Expression1Expression2Difference
    doneIndexdoablesVARIABLE_NAME_MISMATCH
    singlerecurrentVARIABLE_NAME_MISMATCH
    21
    doables = recurrent;
    9
    doneIndexLast = single;
    9
    doneIndexLast = single;
    22
    doablesLast = recurrent;
    Differences
    Expression1Expression2Difference
    doneIndexLastdoablesLastVARIABLE_NAME_MISMATCH
    singlerecurrentVARIABLE_NAME_MISMATCH
    22
    doablesLast = recurrent;
    else
    else
    10
    doneIndexLast.next = single;
    10
    doneIndexLast.next = single;
    23
    doablesLast.next = recurrent;
    Differences
    Expression1Expression2Difference
    doneIndexLastdoablesLastVARIABLE_NAME_MISMATCH
    singlerecurrentVARIABLE_NAME_MISMATCH
    23
    doablesLast.next = recurrent;
    11
    while (doneIndexLast.next != null)
    11
    while (doneIndexLast.next != null)
    24
    while (doablesLast.next != null)
    Differences
    Expression1Expression2Difference
    doneIndexLastdoablesLastVARIABLE_NAME_MISMATCH
    24
    while (doablesLast.next != null)
    12
    doneIndexLast = doneIndexLast.next;
    12
    doneIndexLast = doneIndexLast.next;
    25
    doablesLast = doablesLast.next;
    Differences
    Expression1Expression2Difference
    doneIndexLastdoablesLastVARIABLE_NAME_MISMATCH
    doneIndexLastdoablesLastVARIABLE_NAME_MISMATCH
    25
    doablesLast = doablesLast.next;
    Precondition Violations (5)
    Row Violation
    1Expression next(input,single) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression token.match(input,recurrent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression next(input,single) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression token.match(input,recurrent) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Clone fragment #1 returns variables doneIndex , while Clone fragment #2 returns variables doables, current