if (dx > 0) { if (offset >= con.limit) return -1; int ch = target .charAt( offset ) ; if (isSet(opts, SINGLE_LINE)) { if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit) offset ++; } else { if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit) ch = REUtil.composeFromSurrogates(ch, target .charAt( ++offset ) ); if (isEOLChar(ch)) return -1; } offset ++; } else { int o1 = offset-1; if (o1 >= con.limit || o1 < 0) return -1; int ch = target .charAt( o1 ) ; if (isSet(opts, SINGLE_LINE)) { if (REUtil.isLowSurrogate(ch) && o1-1 >= 0) o1 --; } else { if (REUtil.isLowSurrogate(ch) && o1-1 >= 0) ch = REUtil.composeFromSurrogates( target .charAt( --o1 ) , ch); if (!isEOLChar(ch)) return -1; } offset = o1; }
if (dx > 0) { if (offset >= con.limit) return -1; int ch = target .setIndex( offset ) ; if (isSet(opts, SINGLE_LINE)) { if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit) offset ++; } else { if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit) ch = REUtil.composeFromSurrogates(ch, target .setIndex( ++offset ) ); if (isEOLChar(ch)) return -1; } offset ++; } else { int o1 = offset-1; if (o1 >= con.limit || o1 < 0) return -1; int ch = target .setIndex( o1 ) ; if (isSet(opts, SINGLE_LINE)) { if (REUtil.isLowSurrogate(ch) && o1-1 >= 0) o1 --; } else { if (REUtil.isLowSurrogate(ch) && o1-1 >= 0) ch = REUtil.composeFromSurrogates( target .setIndex( --o1 ) , ch); if (!isEOLChar(ch)) return -1; } offset = o1; }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xml/type/internal/RegEx.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/xml/type/internal/RegEx.java
Method name: int matchString(Context, Op, int, int, int) Method name: int matchCharacterIterator(Context, Op, int, int, int)
Number of AST nodes: 24 Number of AST nodes: 24
1
if (dx > 0) {
1
if (dx > 0) {
2
                      if (offset >= con.limit)
2
                      if (offset >= con.limit)
3
                          return -1;
3
                          return -1;
4
                      int ch =  target .charAt(  offset ) ;
4
                      int ch =  target .setIndex(  offset ) ;
5
                      if (isSet(opts, SINGLE_LINE)) {
5
                      if (isSet(opts, SINGLE_LINE)) {
6
                          if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
6
                          if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
7
                              offset ++;
7
                              offset ++;
8
                      } else {
8
                      } else {
9
                          if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
9
                          if (REUtil.isHighSurrogate(ch) && offset+1 < con.limit)
10
                              ch = REUtil.composeFromSurrogates(ch,  target .charAt(  ++offset ) );
10
                              ch = REUtil.composeFromSurrogates(ch,  target .setIndex(  ++offset ) );
11
                          if (isEOLChar(ch))
11
                          if (isEOLChar(ch))
12
                              return -1;
12
                              return -1;
13
                      }
13
                      }
14
                      offset ++;
14
                      offset ++;
15
                  } else {
15
                  } else {
16
                      int o1 = offset-1;
16
                      int o1 = offset-1;
17
                      if (o1 >= con.limit || o1 < 0)
17
                      if (o1 >= con.limit || o1 < 0)
18
                          return -1;
18
                          return -1;
19
                      int ch =  target .charAt(  o1 ) ;
19
                      int ch =  target .setIndex(  o1 ) ;
20
                      if (isSet(opts, SINGLE_LINE)) {
20
                      if (isSet(opts, SINGLE_LINE)) {
21
                          if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
21
                          if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
22
                              o1 --;
22
                              o1 --;
23
                      } else {
23
                      } else {
24
                          if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
24
                          if (REUtil.isLowSurrogate(ch) && o1-1 >= 0)
25
                              ch = REUtil.composeFromSurrogates( target .charAt(  --o1 ) , ch);
25
                              ch = REUtil.composeFromSurrogates( target .setIndex(  --o1 ) , ch);
26
                          if (!isEOLChar(ch))
26
                          if (!isEOLChar(ch))
27
                              return -1;
27
                              return -1;
28
                      }
28
                      }
29
                      offset = o1;
29
                      offset = o1;
30
                  }
30
                  }
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)4.8
Clones locationClones are declared in the same class
Number of node comparisons138
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements24
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)88.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    31
    if (dx > 0)
    31
    if (dx > 0)
    32
    if (offset >= con.limit)
    32
    if (offset >= con.limit)
    33
    return -1;
    33
    return -1;
    34
    int ch = target.charAt(offset);
    34
    int ch = target.charAt(offset);
    34
    int ch = target.setIndex(offset);
    Differences
    Expression1Expression2Difference
    charAtsetIndexMETHOD_INVOCATION_NAME_MISMATCH
    java.lang.Stringjava.text.CharacterIteratorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression target.charAt(offset) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression target.setIndex(offset) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.lang.String of variable target does not match with type java.text.CharacterIterator of variable target
    • Make classes java.lang.String and java.text.CharacterIterator extend a common superclass
    34
    int ch = target.setIndex(offset);
    35
    if (isSet(opts, SINGLE_LINE))
    35
    if (isSet(opts, SINGLE_LINE))
    36
    if (REUtil.isHighSurrogate(ch) && offset + 1 < con.limit)
    36
    if (REUtil.isHighSurrogate(ch) && offset + 1 < con.limit)
    37
    offset++;
    37
    offset++;
    else
    else
    38
    if (REUtil.isHighSurrogate(ch) && offset + 1 < con.limit)
    38
    if (REUtil.isHighSurrogate(ch) && offset + 1 < con.limit)
    39
    ch = REUtil.composeFromSurrogates(ch, target.charAt(++offset));
    39
    ch = REUtil.composeFromSurrogates(ch, target.charAt(++offset));
    39
    ch = REUtil.composeFromSurrogates(ch, target.setIndex(++offset));
    Differences
    Expression1Expression2Difference
    charAtsetIndexMETHOD_INVOCATION_NAME_MISMATCH
    java.lang.Stringjava.text.CharacterIteratorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression target.charAt(++offset) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression target.setIndex(++offset) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.lang.String of variable target does not match with type java.text.CharacterIterator of variable target
    • Make classes java.lang.String and java.text.CharacterIterator extend a common superclass
    39
    ch = REUtil.composeFromSurrogates(ch, target.setIndex(++offset));
    40
    if (isEOLChar(ch))
    40
    if (isEOLChar(ch))
    41
    return -1;
    41
    return -1;
    42
    offset++;
    42
    offset++;
    else
    else
    43
    int o1 = offset - 1;
    43
    int o1 = offset - 1;
    44
    if (o1 >= con.limit || o1 < 0)
    44
    if (o1 >= con.limit || o1 < 0)
    45
    return -1;
    45
    return -1;
    46
    int ch = target.charAt(o1);
    46
    int ch = target.charAt(o1);
    46
    int ch = target.setIndex(o1);
    Differences
    Expression1Expression2Difference
    charAtsetIndexMETHOD_INVOCATION_NAME_MISMATCH
    java.lang.Stringjava.text.CharacterIteratorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression target.charAt(o1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression target.setIndex(o1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.lang.String of variable target does not match with type java.text.CharacterIterator of variable target
    • Make classes java.lang.String and java.text.CharacterIterator extend a common superclass
    46
    int ch = target.setIndex(o1);
    47
    if (isSet(opts, SINGLE_LINE))
    47
    if (isSet(opts, SINGLE_LINE))
    48
    if (REUtil.isLowSurrogate(ch) && o1 - 1 >= 0)
    48
    if (REUtil.isLowSurrogate(ch) && o1 - 1 >= 0)
    49
    o1--;
    49
    o1--;
    else
    else
    50
    if (REUtil.isLowSurrogate(ch) && o1 - 1 >= 0)
    50
    if (REUtil.isLowSurrogate(ch) && o1 - 1 >= 0)
    51
    ch = REUtil.composeFromSurrogates(target.charAt(--o1), ch);
    51
    ch = REUtil.composeFromSurrogates(target.charAt(--o1), ch);
    51
    ch = REUtil.composeFromSurrogates(target.setIndex(--o1), ch);
    Differences
    Expression1Expression2Difference
    charAtsetIndexMETHOD_INVOCATION_NAME_MISMATCH
    java.lang.Stringjava.text.CharacterIteratorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression target.charAt(--o1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression target.setIndex(--o1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.lang.String of variable target does not match with type java.text.CharacterIterator of variable target
    • Make classes java.lang.String and java.text.CharacterIterator extend a common superclass
    51
    ch = REUtil.composeFromSurrogates(target.setIndex(--o1), ch);
    52
    if (!isEOLChar(ch))
    52
    if (!isEOLChar(ch))
    53
    return -1;
    53
    return -1;
    54
    offset = o1;
    54
    offset = o1;
    Precondition Violations (12)
    Row Violation
    1Expression target.charAt(offset) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression target.setIndex(offset) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Type java.lang.String of variable target does not match with type java.text.CharacterIterator of variable target
    4Expression target.charAt(++offset) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression target.setIndex(++offset) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Type java.lang.String of variable target does not match with type java.text.CharacterIterator of variable target
    7Expression target.charAt(o1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression target.setIndex(o1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Type java.lang.String of variable target does not match with type java.text.CharacterIterator of variable target
    10Expression target.charAt(--o1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression target.setIndex(--o1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Type java.lang.String of variable target does not match with type java.text.CharacterIterator of variable target