RangeToken range = this.firstChar; if (RegularExpression.isSet(this.options, IGNORE_CASE)) { range = this.firstChar.getCaseInsensitiveToken(); for (matchStart = con.start; matchStart <= limit; matchStart ++) { int ch = target .setIndex( matchStart ) ; if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) { ch = REUtil.composeFromSurrogates(ch, target .setIndex( matchStart+1 ) ); if (!range.match(ch)) continue; } else { if (!range.match(ch)) { char ch1 = Character.toUpperCase((char)ch); if (!range.match(ch1)) if (!range.match(Character.toLowerCase(ch1))) continue; } } if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations, matchStart, 1, this.options))) break; } } else { for (matchStart = con.start; matchStart <= limit; matchStart ++) { int ch = target .setIndex( matchStart ) ; if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) ch = REUtil.composeFromSurrogates(ch, target .setIndex( matchStart+1 ) ); if (!range.match(ch)) continue; if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations, matchStart, 1, this.options))) break; } }
RangeToken range = this.firstChar; if (RegularExpression.isSet(this.options, IGNORE_CASE)) { range = this.firstChar.getCaseInsensitiveToken(); for (matchStart = con.start; matchStart <= limit; matchStart ++) { int ch = target .charAt( matchStart ) ; if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) { ch = REUtil.composeFromSurrogates(ch, target .charAt( matchStart+1 ) ); if (!range.match(ch)) continue; } else { if (!range.match(ch)) { char ch1 = Character.toUpperCase((char)ch); if (!range.match(ch1)) if (!range.match(Character.toLowerCase(ch1))) continue; } } if (0 <= (matchEnd = this. matchString (con, this.operations, matchStart, 1, this.options))) break; } } else { for (matchStart = con.start; matchStart <= limit; matchStart ++) { int ch = target .charAt( matchStart ) ; if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) ch = REUtil.composeFromSurrogates(ch, target .charAt( matchStart+1 ) ); if (!range.match(ch)) continue; if (0 <= (matchEnd = this. matchString (con, this.operations, matchStart, 1, this.options))) break; } }
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: boolean matches(CharacterIterator, Match) Method name: boolean matches(String, int, int, Match)
Number of AST nodes: 24 Number of AST nodes: 24
1
RangeToken range = this.firstChar;
1
RangeToken range = this.firstChar;
2
              if (RegularExpression.isSet(this.options, IGNORE_CASE)) {
2
              if (RegularExpression.isSet(this.options, IGNORE_CASE)) {
3
                  range = this.firstChar.getCaseInsensitiveToken();
3
                  range = this.firstChar.getCaseInsensitiveToken();
4
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
4
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
5
                      int ch =  target .setIndex(  matchStart ) ;
5
                      int ch =  target .charAt(  matchStart ) ;
6
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) {
6
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) {
7
                          ch = REUtil.composeFromSurrogates(ch,  target .setIndex(  matchStart+1 ) );
7
                          ch = REUtil.composeFromSurrogates(ch,  target .charAt(  matchStart+1 ) );
8
                          if (!range.match(ch))  continue;
8
                          if (!range.match(ch))  continue;
9
                      } else {
9
                      } else {
10
                          if (!range.match(ch)) {
10
                          if (!range.match(ch)) {
11
                              char ch1 = Character.toUpperCase((char)ch);
11
                              char ch1 = Character.toUpperCase((char)ch);
12
                              if (!range.match(ch1))
12
                              if (!range.match(ch1))
13
                                  if (!range.match(Character.toLowerCase(ch1)))
13
                                  if (!range.match(Character.toLowerCase(ch1)))
14
                                      continue;
14
                                      continue;
15
                          }
15
                          }
16
                      }
16
                      }
17
                      if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations,
17
                      if (0 <= (matchEnd = this. matchString (con, this.operations,
18
                                                                         matchStart, 1, this.options)))
18
                                                              matchStart, 1, this.options)))
19
                          break;
19
                          break;
20
                  }
20
                  }
21
              } else {
21
              } else {
22
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
22
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
23
                      int ch =  target .setIndex(  matchStart ) ;
23
                      int ch =  target .charAt(  matchStart ) ;
24
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit)
24
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit)
25
                          ch = REUtil.composeFromSurrogates(ch,  target .setIndex(  matchStart+1 ) );
25
                          ch = REUtil.composeFromSurrogates(ch,  target .charAt(  matchStart+1 ) );
26
                      if (!range.match(ch))  continue;
26
                      if (!range.match(ch))  continue;
27
                      if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations,
27
                      if (0 <= (matchEnd = this. matchString (con, this.operations,
28
                                                                         matchStart, 1, this.options)))
28
                                                              matchStart, 1, this.options)))
29
                          break;
29
                          break;
30
                  }
30
                  }
31
              }
31
              }
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 comparisons79
  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)8.0
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    60
    RangeToken range = this.firstChar;
    63
    RangeToken range = this.firstChar;
    61
    if (RegularExpression.isSet(this.options, IGNORE_CASE))
    64
    if (RegularExpression.isSet(this.options, IGNORE_CASE))
    62
    range = this.firstChar.getCaseInsensitiveToken();
    65
    range = this.firstChar.getCaseInsensitiveToken();
    63
    for (matchStart = con.start; matchStart <= limit; matchStart++)
    66
    for (matchStart = con.start; matchStart <= limit; matchStart++)
    64
    int ch = target.setIndex(matchStart);
    64
    int ch = target.setIndex(matchStart);
    67
    int ch = target.charAt(matchStart);
    Differences
    Expression1Expression2Difference
    setIndexcharAtMETHOD_INVOCATION_NAME_MISMATCH
    java.text.CharacterIteratorjava.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression target.setIndex(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression target.charAt(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.text.CharacterIterator of variable target does not match with type java.lang.String of variable target
    • Make classes java.text.CharacterIterator and java.lang.String extend a common superclass
    67
    int ch = target.charAt(matchStart);
    65
    if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit)
    68
    if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit)
    66
    ch = REUtil.composeFromSurrogates(ch, target.setIndex(matchStart + 1));
    66
    ch = REUtil.composeFromSurrogates(ch, target.setIndex(matchStart + 1));
    69
    ch = REUtil.composeFromSurrogates(ch, target.charAt(matchStart + 1));
    Differences
    Expression1Expression2Difference
    setIndexcharAtMETHOD_INVOCATION_NAME_MISMATCH
    java.text.CharacterIteratorjava.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression target.setIndex(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression target.charAt(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.text.CharacterIterator of variable target does not match with type java.lang.String of variable target
    • Make classes java.text.CharacterIterator and java.lang.String extend a common superclass
    69
    ch = REUtil.composeFromSurrogates(ch, target.charAt(matchStart + 1));
    67
    if (!range.match(ch))
    70
    if (!range.match(ch))
    68
    continue;
    71
    continue;
    else
    else
    69
    if (!range.match(ch))
    72
    if (!range.match(ch))
    70
    char ch1 = Character.toUpperCase((char)ch);
    73
    char ch1 = Character.toUpperCase((char)ch);
    71
    if (!range.match(ch1))
    74
    if (!range.match(ch1))
    72
    if (!range.match(Character.toLowerCase(ch1)))
    75
    if (!range.match(Character.toLowerCase(ch1)))
    73
    continue;
    76
    continue;
    74
    if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options)))
    74
    if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options)))
    77
    if (0 <= (matchEnd = this.matchString(con, this.operations, matchStart, 1, this.options)))
    Differences
    Expression1Expression2Difference
    matchCharacterIteratormatchStringMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression this.matchCharacterIterator(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method matchCharacterIterator
    Expression this.matchString(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method matchString
    77
    if (0 <= (matchEnd = this.matchString(con, this.operations, matchStart, 1, this.options)))
    75
    break;
    78
    break;
    else
    else
    76
    for (matchStart = con.start; matchStart <= limit; matchStart++)
    79
    for (matchStart = con.start; matchStart <= limit; matchStart++)
    77
    int ch = target.setIndex(matchStart);
    77
    int ch = target.setIndex(matchStart);
    80
    int ch = target.charAt(matchStart);
    Differences
    Expression1Expression2Difference
    setIndexcharAtMETHOD_INVOCATION_NAME_MISMATCH
    java.text.CharacterIteratorjava.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression target.setIndex(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression target.charAt(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.text.CharacterIterator of variable target does not match with type java.lang.String of variable target
    • Make classes java.text.CharacterIterator and java.lang.String extend a common superclass
    80
    int ch = target.charAt(matchStart);
    78
    if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit)
    81
    if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit)
    79
    ch = REUtil.composeFromSurrogates(ch, target.setIndex(matchStart + 1));
    79
    ch = REUtil.composeFromSurrogates(ch, target.setIndex(matchStart + 1));
    82
    ch = REUtil.composeFromSurrogates(ch, target.charAt(matchStart + 1));
    Differences
    Expression1Expression2Difference
    setIndexcharAtMETHOD_INVOCATION_NAME_MISMATCH
    java.text.CharacterIteratorjava.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression target.setIndex(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression target.charAt(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.text.CharacterIterator of variable target does not match with type java.lang.String of variable target
    • Make classes java.text.CharacterIterator and java.lang.String extend a common superclass
    82
    ch = REUtil.composeFromSurrogates(ch, target.charAt(matchStart + 1));
    80
    if (!range.match(ch))
    83
    if (!range.match(ch))
    81
    continue;
    84
    continue;
    82
    if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options)))
    82
    if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options)))
    85
    if (0 <= (matchEnd = this.matchString(con, this.operations, matchStart, 1, this.options)))
    Differences
    Expression1Expression2Difference
    matchCharacterIteratormatchStringMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression this.matchCharacterIterator(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method matchCharacterIterator
    Expression this.matchString(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method matchString
    85
    if (0 <= (matchEnd = this.matchString(con, this.operations, matchStart, 1, this.options)))
    83
    break;
    86
    break;
    Precondition Violations (17)
    Row Violation
    1Expression target.setIndex(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression target.charAt(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Type java.text.CharacterIterator of variable target does not match with type java.lang.String of variable target
    4Expression target.setIndex(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression target.charAt(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Type java.text.CharacterIterator of variable target does not match with type java.lang.String of variable target
    7Expression this.matchCharacterIterator(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression this.matchString(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression target.setIndex(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression target.charAt(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Type java.text.CharacterIterator of variable target does not match with type java.lang.String of variable target
    12Expression target.setIndex(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression target.charAt(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Type java.text.CharacterIterator of variable target does not match with type java.lang.String of variable target
    15Expression this.matchCharacterIterator(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression this.matchString(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Clone fragment #1 returns variables matchEnd, matchStart , while Clone fragment #2 returns variables matchEnd, matchStart