int refno = op.getData(); if (refno <= 0 || refno >= this.nofparen) throw new RuntimeException("Internal Error: Reference number must be more than zero: "+refno); if (con.match.getBeginning(refno) < 0 || con.match.getEnd(refno) < 0) return -1; // ******** int o2 = con.match.getBeginning(refno); int literallen = con.match.getEnd(refno)-o2; if (!isSet(opts, IGNORE_CASE)) { if (dx > 0) { if (!regionMatches(target, offset, con.limit, o2, literallen)) return -1; offset += literallen; } else { if (!regionMatches(target, offset-literallen, con.limit, o2, literallen)) return -1; offset -= literallen; } } else { if (dx > 0) { if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen)) return -1; offset += literallen; } else { if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit, o2, literallen)) return -1; offset -= literallen; } }
int refno = op.getData(); if (refno <= 0 || refno >= this.nofparen) throw new RuntimeException("Internal Error: Reference number must be more than zero: "+refno); if (con.match.getBeginning(refno) < 0 || con.match.getEnd(refno) < 0) return -1; // ******** int o2 = con.match.getBeginning(refno); int literallen = con.match.getEnd(refno)-o2; if (!isSet(opts, IGNORE_CASE)) { if (dx > 0) { if (!regionMatches(target, offset, con.limit, o2, literallen)) return -1; offset += literallen; } else { if (!regionMatches(target, offset-literallen, con.limit, o2, literallen)) return -1; offset -= literallen; } } else { if (dx > 0) { if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen)) return -1; offset += literallen; } else { if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit, o2, literallen)) return -1; offset -= literallen; } }
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 matchCharArray(Context, Op, int, int, int) Method name: int matchString(Context, Op, int, int, int)
Number of AST nodes: 22 Number of AST nodes: 22
1
int refno = op.getData();
1
int refno = op.getData();
2
                      if (refno <= 0 || refno >= this.nofparen)
2
                      if (refno <= 0 || refno >= this.nofparen)
3
                          throw new RuntimeException("Internal Error: Reference number must be more than zero: "+refno);
3
                          throw new RuntimeException("Internal Error: Reference number must be more than zero: "+refno);
4
                      if (con.match.getBeginning(refno) < 0
4
                      if (con.match.getBeginning(refno) < 0
5
                          || con.match.getEnd(refno) < 0)
5
                          || con.match.getEnd(refno) < 0)
6
                          return -1;                // ********
6
                          return -1;                // ********
7
                      int o2 = con.match.getBeginning(refno);
7
                      int o2 = con.match.getBeginning(refno);
8
                      int literallen = con.match.getEnd(refno)-o2;
8
                      int literallen = con.match.getEnd(refno)-o2;
9
                      if (!isSet(opts, IGNORE_CASE)) {
9
                      if (!isSet(opts, IGNORE_CASE)) {
10
                          if (dx > 0) {
10
                          if (dx > 0) {
11
                              if (!regionMatches(target, offset, con.limit, o2, literallen))
11
                              if (!regionMatches(target, offset, con.limit, o2, literallen))
12
                                  return -1;
12
                                  return -1;
13
                              offset += literallen;
13
                              offset += literallen;
14
                          } else {
14
                          } else {
15
                              if (!regionMatches(target, offset-literallen, con.limit, o2, literallen))
15
                              if (!regionMatches(target, offset-literallen, con.limit, o2, literallen))
16
                                  return -1;
16
                                  return -1;
17
                              offset -= literallen;
17
                              offset -= literallen;
18
                          }
18
                          }
19
                      } else {
19
                      } else {
20
                          if (dx > 0) {
20
                          if (dx > 0) {
21
                              if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen))
21
                              if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen))
22
                                  return -1;
22
                                  return -1;
23
                              offset += literallen;
23
                              offset += literallen;
24
                          } else {
24
                          } else {
25
                              if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit,
25
                              if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit,
26
                                                           o2, literallen))
26
                                                           o2, literallen))
27
                                  return -1;
27
                                  return -1;
28
                              offset -= literallen;
28
                              offset -= literallen;
29
                          }
29
                          }
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.0
Clones locationClones are declared in the same class
Number of node comparisons88
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements22
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)118.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    163
    int refno = op.getData();
    163
    int refno = op.getData();
    164
    if (refno <= 0 || refno >= this.nofparen)
    164
    if (refno <= 0 || refno >= this.nofparen)
    165
    throw new RuntimeException("Internal Error: Reference number must be more than zero: " + refno);
    165
    throw new RuntimeException("Internal Error: Reference number must be more than zero: " + refno);
    166
    if (con.match.getBeginning(refno) < 0 || con.match.getEnd(refno) < 0)
    166
    if (con.match.getBeginning(refno) < 0 || con.match.getEnd(refno) < 0)
    167
    return -1;
    167
    return -1;
    168
    int o2 = con.match.getBeginning(refno);
    168
    int o2 = con.match.getBeginning(refno);
    169
    int literallen = con.match.getEnd(refno) - o2;
    169
    int literallen = con.match.getEnd(refno) - o2;
    170
    if (!isSet(opts, IGNORE_CASE))
    170
    if (!isSet(opts, IGNORE_CASE))
    171
    if (dx > 0)
    171
    if (dx > 0)
    172
    if (!regionMatches(target, offset, con.limit, o2, literallen))
    172
    if (!regionMatches(target, offset, con.limit, o2, literallen))
    172
    if (!regionMatches(target, offset, con.limit, o2, literallen))
    Differences
    Expression1Expression2Difference
    char[]java.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type char[] of variable target does not match with type java.lang.String of variable target
    • Make classes char[] and java.lang.String extend a common superclass
    172
    if (!regionMatches(target, offset, con.limit, o2, literallen))
    173
    return -1;
    173
    return -1;
    174
    offset += literallen;
    174
    offset += literallen;
    else
    else
    175
    if (!regionMatches(target, offset - literallen, con.limit, o2, literallen))
    175
    if (!regionMatches(target, offset - literallen, con.limit, o2, literallen))
    175
    if (!regionMatches(target, offset - literallen, con.limit, o2, literallen))
    Differences
    Expression1Expression2Difference
    char[]java.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type char[] of variable target does not match with type java.lang.String of variable target
    • Make classes char[] and java.lang.String extend a common superclass
    175
    if (!regionMatches(target, offset - literallen, con.limit, o2, literallen))
    176
    return -1;
    176
    return -1;
    177
    offset -= literallen;
    177
    offset -= literallen;
    else
    else
    178
    if (dx > 0)
    178
    if (dx > 0)
    179
    if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen))
    179
    if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen))
    179
    if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen))
    Differences
    Expression1Expression2Difference
    char[]java.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type char[] of variable target does not match with type java.lang.String of variable target
    • Make classes char[] and java.lang.String extend a common superclass
    179
    if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen))
    180
    return -1;
    180
    return -1;
    181
    offset += literallen;
    181
    offset += literallen;
    else
    else
    182
    if (!regionMatchesIgnoreCase(target, offset - literallen, con.limit, o2, literallen))
    182
    if (!regionMatchesIgnoreCase(target, offset - literallen, con.limit, o2, literallen))
    182
    if (!regionMatchesIgnoreCase(target, offset - literallen, con.limit, o2, literallen))
    Differences
    Expression1Expression2Difference
    char[]java.lang.StringVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type char[] of variable target does not match with type java.lang.String of variable target
    • Make classes char[] and java.lang.String extend a common superclass
    182
    if (!regionMatchesIgnoreCase(target, offset - literallen, con.limit, o2, literallen))
    183
    return -1;
    183
    return -1;
    184
    offset -= literallen;
    184
    offset -= literallen;
    Precondition Violations (4)
    Row Violation
    1Type char[] of variable target does not match with type java.lang.String of variable target
    2Type char[] of variable target does not match with type java.lang.String of variable target
    3Type char[] of variable target does not match with type java.lang.String of variable target
    4Type char[] of variable target does not match with type java.lang.String of variable target