if (this.firstChar != null) { //System.err.println("DEBUG: with firstchar-matching: "+this.firstChar); 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; } } } /* * Straightforward matching. */ else { for (matchStart = con.start; matchStart <= limit; matchStart ++) { if (0 <= (matchEnd = this. matchString (con, this.operations, matchStart, 1, this.options))) break; } }
if (this.firstChar != null) { //System.err.println("DEBUG: with firstchar-matching: "+this.firstChar); 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; } } } /* * Straightforward matching. */ else { for (matchStart = con.start; matchStart <= limit; matchStart ++) { if (0 <= (matchEnd = this. matchCharacterIterator (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(String, int, int, Match) Method name: boolean matches(CharacterIterator, Match)
Number of AST nodes: 28 Number of AST nodes: 28
1
if (this.firstChar != null) {
1
if (this.firstChar != null) {
2
              //System.err.println("DEBUG: with firstchar-matching: "+this.firstChar);
2
              //System.err.println("DEBUG: with firstchar-matching: "+this.firstChar);
3
              RangeToken range = this.firstChar;
3
              RangeToken range = this.firstChar;
4
              if (RegularExpression.isSet(this.options, IGNORE_CASE)) {
4
              if (RegularExpression.isSet(this.options, IGNORE_CASE)) {
5
                  range = this.firstChar.getCaseInsensitiveToken();
5
                  range = this.firstChar.getCaseInsensitiveToken();
6
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
6
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
7
                      int ch =  target .charAt(  matchStart ) ;
7
                      int ch =  target .setIndex(  matchStart ) ;
8
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) {
8
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) {
9
                          ch = REUtil.composeFromSurrogates(ch,  target .charAt(  matchStart+1 ) );
9
                          ch = REUtil.composeFromSurrogates(ch,  target .setIndex(  matchStart+1 ) );
10
                          if (!range.match(ch))  continue;
10
                          if (!range.match(ch))  continue;
11
                      } else {
11
                      } else {
12
                          if (!range.match(ch)) {
12
                          if (!range.match(ch)) {
13
                              char ch1 = Character.toUpperCase((char)ch);
13
                              char ch1 = Character.toUpperCase((char)ch);
14
                              if (!range.match(ch1))
14
                              if (!range.match(ch1))
15
                                  if (!range.match(Character.toLowerCase(ch1)))
15
                                  if (!range.match(Character.toLowerCase(ch1)))
16
                                      continue;
16
                                      continue;
17
                          }
17
                          }
18
                      }
18
                      }
19
                      if (0 <= (matchEnd = this. matchString (con, this.operations,
19
                      if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations,
20
                                                              matchStart, 1, this.options)))
20
                                                                         matchStart, 1, this.options)))
21
                          break;
21
                          break;
22
                  }
22
                  }
23
              } else {
23
              } else {
24
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
24
                  for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
25
                      int ch =  target .charAt(  matchStart ) ;
25
                      int ch =  target .setIndex(  matchStart ) ;
26
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit)
26
                      if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit)
27
                          ch = REUtil.composeFromSurrogates(ch,  target .charAt(  matchStart+1 ) );
27
                          ch = REUtil.composeFromSurrogates(ch,  target .setIndex(  matchStart+1 ) );
28
                      if (!range.match(ch))  continue;
28
                      if (!range.match(ch))  continue;
29
                      if (0 <= (matchEnd = this. matchString (con, this.operations,
29
                      if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations,
30
                                                              matchStart, 1, this.options)))
30
                                                                         matchStart, 1, this.options)))
31
                          break;
31
                          break;
32
                  }
32
                  }
33
              }
33
              }
34
          }
34
          }
35
          /*
35
          /*
36
           * Straightforward matching.
36
           * Straightforward matching.
37
           */
37
           */
38
          else {
38
          else {
39
              for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
39
              for (matchStart = con.start;  matchStart <= limit;  matchStart ++) {
40
                  if (0 <= (matchEnd = this. matchString (con, this.operations, matchStart, 1, this.options)))
40
                  if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations, matchStart, 1, this.options)))
41
                      break;
41
                      break;
42
              }
42
              }
43
          }
43
          }
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)5.8
Clones locationClones are declared in the same class
Number of node comparisons98
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements28
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)10.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    62
    else if (this.firstChar != null)
    59
    else if (this.firstChar != null)
    63
    RangeToken range = this.firstChar;
    60
    RangeToken range = this.firstChar;
    64
    if (RegularExpression.isSet(this.options, IGNORE_CASE))
    61
    if (RegularExpression.isSet(this.options, IGNORE_CASE))
    65
    range = this.firstChar.getCaseInsensitiveToken();
    62
    range = this.firstChar.getCaseInsensitiveToken();
    66
    for (matchStart = con.start; matchStart <= limit; matchStart++)
    63
    for (matchStart = con.start; matchStart <= limit; matchStart++)
    67
    int ch = target.charAt(matchStart);
    67
    int ch = target.charAt(matchStart);
    64
    int ch = target.setIndex(matchStart);
    Differences
    Expression1Expression2Difference
    charAtsetIndexMETHOD_INVOCATION_NAME_MISMATCH
    java.lang.Stringjava.text.CharacterIteratorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression target.charAt(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression target.setIndex(matchStart) 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
    64
    int ch = target.setIndex(matchStart);
    68
    if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit)
    65
    if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit)
    69
    ch = REUtil.composeFromSurrogates(ch, target.charAt(matchStart + 1));
    69
    ch = REUtil.composeFromSurrogates(ch, target.charAt(matchStart + 1));
    66
    ch = REUtil.composeFromSurrogates(ch, target.setIndex(matchStart + 1));
    Differences
    Expression1Expression2Difference
    charAtsetIndexMETHOD_INVOCATION_NAME_MISMATCH
    java.lang.Stringjava.text.CharacterIteratorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression target.charAt(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression target.setIndex(matchStart + 1) 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
    66
    ch = REUtil.composeFromSurrogates(ch, target.setIndex(matchStart + 1));
    70
    if (!range.match(ch))
    67
    if (!range.match(ch))
    71
    continue;
    68
    continue;
    else
    else
    72
    if (!range.match(ch))
    69
    if (!range.match(ch))
    73
    char ch1 = Character.toUpperCase((char)ch);
    70
    char ch1 = Character.toUpperCase((char)ch);
    74
    if (!range.match(ch1))
    71
    if (!range.match(ch1))
    75
    if (!range.match(Character.toLowerCase(ch1)))
    72
    if (!range.match(Character.toLowerCase(ch1)))
    76
    continue;
    73
    continue;
    77
    if (0 <= (matchEnd = this.matchString(con, this.operations, matchStart, 1, this.options)))
    77
    if (0 <= (matchEnd = this.matchString(con, this.operations, matchStart, 1, this.options)))
    74
    if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options)))
    Differences
    Expression1Expression2Difference
    matchStringmatchCharacterIteratorMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    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
    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
    74
    if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options)))
    78
    break;
    75
    break;
    else
    else
    79
    for (matchStart = con.start; matchStart <= limit; matchStart++)
    76
    for (matchStart = con.start; matchStart <= limit; matchStart++)
    80
    int ch = target.charAt(matchStart);
    80
    int ch = target.charAt(matchStart);
    77
    int ch = target.setIndex(matchStart);
    Differences
    Expression1Expression2Difference
    charAtsetIndexMETHOD_INVOCATION_NAME_MISMATCH
    java.lang.Stringjava.text.CharacterIteratorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression target.charAt(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression target.setIndex(matchStart) 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
    77
    int ch = target.setIndex(matchStart);
    81
    if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit)
    78
    if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit)
    82
    ch = REUtil.composeFromSurrogates(ch, target.charAt(matchStart + 1));
    82
    ch = REUtil.composeFromSurrogates(ch, target.charAt(matchStart + 1));
    79
    ch = REUtil.composeFromSurrogates(ch, target.setIndex(matchStart + 1));
    Differences
    Expression1Expression2Difference
    charAtsetIndexMETHOD_INVOCATION_NAME_MISMATCH
    java.lang.Stringjava.text.CharacterIteratorVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Expression target.charAt(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression target.setIndex(matchStart + 1) 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
    79
    ch = REUtil.composeFromSurrogates(ch, target.setIndex(matchStart + 1));
    83
    if (!range.match(ch))
    80
    if (!range.match(ch))
    84
    continue;
    81
    continue;
    85
    if (0 <= (matchEnd = this.matchString(con, this.operations, matchStart, 1, this.options)))
    85
    if (0 <= (matchEnd = this.matchString(con, this.operations, matchStart, 1, this.options)))
    82
    if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options)))
    Differences
    Expression1Expression2Difference
    matchStringmatchCharacterIteratorMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    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
    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
    82
    if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options)))
    86
    break;
    83
    break;
    else
    else
    87
    for (matchStart = con.start; matchStart <= limit; matchStart++)
    84
    for (matchStart = con.start; matchStart <= limit; matchStart++)
    88
    if (0 <= (matchEnd = this.matchString(con, this.operations, matchStart, 1, this.options)))
    88
    if (0 <= (matchEnd = this.matchString(con, this.operations, matchStart, 1, this.options)))
    85
    if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options)))
    Differences
    Expression1Expression2Difference
    matchStringmatchCharacterIteratorMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    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
    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
    85
    if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options)))
    89
    break;
    86
    break;
    Precondition Violations (19)
    Row Violation
    1Expression target.charAt(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression target.setIndex(matchStart) 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(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression target.setIndex(matchStart + 1) 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 this.matchString(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression this.matchCharacterIterator(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression target.charAt(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression target.setIndex(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Type java.lang.String of variable target does not match with type java.text.CharacterIterator of variable target
    12Expression target.charAt(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression target.setIndex(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Type java.lang.String of variable target does not match with type java.text.CharacterIterator of variable target
    15Expression this.matchString(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    16Expression this.matchCharacterIterator(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression this.matchString(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    18Expression this.matchCharacterIterator(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Clone fragment #1 returns variables matchEnd, matchStart , while Clone fragment #2 returns variables matchEnd, matchStart