10068-2-3

case 'z': if (offset != con.limit) return -1; break; case 'b': if (con.length == 0) return -1; { int after = getWordType(target, con.start, con.limit, offset, opts); if (after == WT_IGNORE) return -1; int before = getPreviousWordType(target, con.start, con.limit, offset, opts); if (after == before) return -1; } break; case 'B': if (con.length == 0) go = true; else { int after = getWordType(target, con.start, con.limit, offset, opts); go = after == WT_IGNORE || after == getPreviousWordType(target, con.start, con.limit, offset, opts); } if (!go) return -1; break; case '<': if (con.length == 0 || offset == con.limit) return -1; if (getWordType(target, con.start, con.limit, offset, opts) != WT_LETTER || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_OTHER) return -1; break; case '>': if (con.length == 0 || offset == con.start) return -1; if (getWordType(target, con.start, con.limit, offset, opts) != WT_OTHER || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_LETTER) return -1; break; } // switch anchor type op = op.next; break; case Op.BACKREFERENCE: { 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; } } } op = op.next; break; case Op.STRING: { String literal = op.getString(); int literallen = literal.length(); if (!isSet(opts, IGNORE_CASE)) { if (dx > 0) { if (!regionMatches(target, offset, con.limit, literal, literallen)) return -1; offset += literallen; } else { if (!regionMatches(target, offset-literallen, con.limit, literal, literallen)) return -1; offset -= literallen; } } else { if (dx > 0) { if (!regionMatchesIgnoreCase(target, offset, con.limit, literal, literallen)) return -1; offset += literallen; } else { if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit, literal, literallen)) return -1; offset -= literallen; } } } op = op.next; break; case Op.CLOSURE: { /* * Saves current position to avoid * zero-width repeats. */ int id = op.getData(); if (id >= 0) { int previousOffset = con.offsets[id]; if (previousOffset < 0 || previousOffset != offset) { con.offsets[id] = offset; } else { con.offsets[id] = -1; op = op.next; break; } } int ret = this. matchString (con, op.getChild(), offset, dx, opts); if (id >= 0) con.offsets[id] = -1; if (ret >= 0) return ret; op = op.next; } break; case Op.QUESTION: { int ret = this. matchString (con, op.getChild(), offset, dx, opts); if (ret >= 0) return ret; op = op.next; } break; case Op.NONGREEDYCLOSURE: case Op.NONGREEDYQUESTION: { int ret = this. matchString (con, op.next, offset, dx, opts); if (ret >= 0) return ret; op = op.getChild(); } break; case Op.UNION: for (int i = 0; i < op.size(); i ++) { int ret = this. matchString (con, op.elementAt(i), offset, dx, opts); if (DEBUG) { System.err.println("UNION: "+i+", ret="+ret); } if (ret >= 0) return ret; } return -1; case Op.CAPTURE: int refno = op.getData(); if (con.match != null && refno > 0) { int save = con.match.getBeginning(refno); con.match.setBeginning(refno, offset); int ret = this. matchString (con, op.next, offset, dx, opts); if (ret < 0) con.match.setBeginning(refno, save); return ret; } else if (con.match != null && refno < 0) { int index = -refno; int save = con.match.getEnd(index); con.match.setEnd(index, offset); int ret = this. matchString (con, op.next, offset, dx, opts); if (ret < 0) con.match.setEnd(index, save); return ret; } op = op.next; break; case Op.LOOKAHEAD: if (0 > this. matchString (con, op.getChild(), offset, 1, opts)) return -1; op = op.next; break; case Op.NEGATIVELOOKAHEAD: if (0 <= this. matchString (con, op.getChild(), offset, 1, opts)) return -1; op = op.next; break; case Op.LOOKBEHIND: if (0 > this. matchString (con, op.getChild(), offset, -1, opts)) return -1; op = op.next; break; case Op.NEGATIVELOOKBEHIND: if (0 <= this. matchString (con, op.getChild(), offset, -1, opts)) return -1; op = op.next; break; case Op.INDEPENDENT: { int ret = this. matchString (con, op.getChild(), offset, dx, opts); if (ret < 0) return ret; offset = ret; op = op.next; } break; case Op.MODIFIER: { int localopts = opts; localopts |= op.getData(); localopts &= ~op.getData2(); //System.err.println("MODIFIER: "+Integer.toString(opts, 16)+" -> "+Integer.toString(localopts, 16)); int ret = this. matchString (con, op.getChild(), offset, dx, localopts); if (ret < 0) return ret; offset = ret; op = op.next; } break; case Op.CONDITION: { Op.ConditionOp cop = (Op.ConditionOp)op; boolean matchp = false; if (cop.refNumber > 0) { if (cop.refNumber >= this.nofparen) throw new RuntimeException("Internal Error: Reference number must be more than zero: "+cop.refNumber); matchp = con.match.getBeginning(cop.refNumber) >= 0 && con.match.getEnd(cop.refNumber) >= 0; } else { matchp = 0 <= this. matchString (con, cop.condition, offset, dx, opts); } if (matchp) { op = cop.yes; } else if (cop.no != null) { op = cop.no; } else { op = cop.next; } } break; default: throw new RuntimeException("Unknown operation type: "+op.type);
case 'z': if (offset != con.limit) return -1; break; case 'b': if (con.length == 0) return -1; { int after = getWordType(target, con.start, con.limit, offset, opts); if (after == WT_IGNORE) return -1; int before = getPreviousWordType(target, con.start, con.limit, offset, opts); if (after == before) return -1; } break; case 'B': if (con.length == 0) go = true; else { int after = getWordType(target, con.start, con.limit, offset, opts); go = after == WT_IGNORE || after == getPreviousWordType(target, con.start, con.limit, offset, opts); } if (!go) return -1; break; case '<': if (con.length == 0 || offset == con.limit) return -1; if (getWordType(target, con.start, con.limit, offset, opts) != WT_LETTER || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_OTHER) return -1; break; case '>': if (con.length == 0 || offset == con.start) return -1; if (getWordType(target, con.start, con.limit, offset, opts) != WT_OTHER || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_LETTER) return -1; break; } // switch anchor type op = op.next; break; case Op.BACKREFERENCE: { 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; } } } op = op.next; break; case Op.STRING: { String literal = op.getString(); int literallen = literal.length(); if (!isSet(opts, IGNORE_CASE)) { if (dx > 0) { if (!regionMatches(target, offset, con.limit, literal, literallen)) return -1; offset += literallen; } else { if (!regionMatches(target, offset-literallen, con.limit, literal, literallen)) return -1; offset -= literallen; } } else { if (dx > 0) { if (!regionMatchesIgnoreCase(target, offset, con.limit, literal, literallen)) return -1; offset += literallen; } else { if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit, literal, literallen)) return -1; offset -= literallen; } } } op = op.next; break; case Op.CLOSURE: { /* * Saves current position to avoid * zero-width repeats. */ int id = op.getData(); if (id >= 0) { int previousOffset = con.offsets[id]; if (previousOffset < 0 || previousOffset != offset) { con.offsets[id] = offset; } else { con.offsets[id] = -1; op = op.next; break; } } int ret = this. matchCharArray (con, op.getChild(), offset, dx, opts); if (id >= 0) con.offsets[id] = -1; if (ret >= 0) return ret; op = op.next; } break; case Op.QUESTION: { int ret = this. matchCharArray (con, op.getChild(), offset, dx, opts); if (ret >= 0) return ret; op = op.next; } break; case Op.NONGREEDYCLOSURE: case Op.NONGREEDYQUESTION: { int ret = this. matchCharArray (con, op.next, offset, dx, opts); if (ret >= 0) return ret; op = op.getChild(); } break; case Op.UNION: for (int i = 0; i < op.size(); i ++) { int ret = this. matchCharArray (con, op.elementAt(i), offset, dx, opts); if (DEBUG) { System.err.println("UNION: "+i+", ret="+ret); } if (ret >= 0) return ret; } return -1; case Op.CAPTURE: int refno = op.getData(); if (con.match != null && refno > 0) { int save = con.match.getBeginning(refno); con.match.setBeginning(refno, offset); int ret = this. matchCharArray (con, op.next, offset, dx, opts); if (ret < 0) con.match.setBeginning(refno, save); return ret; } else if (con.match != null && refno < 0) { int index = -refno; int save = con.match.getEnd(index); con.match.setEnd(index, offset); int ret = this. matchCharArray (con, op.next, offset, dx, opts); if (ret < 0) con.match.setEnd(index, save); return ret; } op = op.next; break; case Op.LOOKAHEAD: if (0 > this. matchCharArray (con, op.getChild(), offset, 1, opts)) return -1; op = op.next; break; case Op.NEGATIVELOOKAHEAD: if (0 <= this. matchCharArray (con, op.getChild(), offset, 1, opts)) return -1; op = op.next; break; case Op.LOOKBEHIND: if (0 > this. matchCharArray (con, op.getChild(), offset, -1, opts)) return -1; op = op.next; break; case Op.NEGATIVELOOKBEHIND: if (0 <= this. matchCharArray (con, op.getChild(), offset, -1, opts)) return -1; op = op.next; break; case Op.INDEPENDENT: { int ret = this. matchCharArray (con, op.getChild(), offset, dx, opts); if (ret < 0) return ret; offset = ret; op = op.next; } break; case Op.MODIFIER: { int localopts = opts; localopts |= op.getData(); localopts &= ~op.getData2(); //System.err.println("MODIFIER: "+Integer.toString(opts, 16)+" -> "+Integer.toString(localopts, 16)); int ret = this. matchCharArray (con, op.getChild(), offset, dx, localopts); if (ret < 0) return ret; offset = ret; op = op.next; } break; case Op.CONDITION: { Op.ConditionOp cop = (Op.ConditionOp)op; boolean matchp = false; if (cop.refNumber > 0) { if (cop.refNumber >= this.nofparen) throw new RuntimeException("Internal Error: Reference number must be more than zero: "+cop.refNumber); matchp = con.match.getBeginning(cop.refNumber) >= 0 && con.match.getEnd(cop.refNumber) >= 0; } else { matchp = 0 <= this. matchCharArray (con, cop.condition, offset, dx, opts); } if (matchp) { op = cop.yes; } else if (cop.no != null) { op = cop.no; } else { op = cop.next; } } break; default: throw new RuntimeException("Unknown operation type: "+op.type);

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 matchCharArray(Context, Op, int, int, int)`
Number of AST nodes: 190 |  | Number of AST nodes: 190

1

    case 'z':↵

1

    case 'z':↵

2

                          if (offset != con.limit)  return -1;↵

2

                          if (offset != con.limit)  return -1;↵

3

                          break;↵

3

                          break;↵

4

                      case 'b':↵

4

                      case 'b':↵

5

                          if (con.length == 0)  return -1;↵

5

                          if (con.length == 0)  return -1;↵

6

                          {↵

6

                          {↵

7

                              int after = getWordType(target, con.start, con.limit, offset, opts);↵

7

                              int after = getWordType(target, con.start, con.limit, offset, opts);↵

8

                              if (after == WT_IGNORE)  return -1;↵

8

                              if (after == WT_IGNORE)  return -1;↵

9

                              int before = getPreviousWordType(target, con.start, con.limit, offset, opts);↵

9

                              int before = getPreviousWordType(target, con.start, con.limit, offset, opts);↵

10

                              if (after == before)  return -1;↵

10

                              if (after == before)  return -1;↵

11

                          }↵

11

                          }↵

12

                          break;↵

12

                          break;↵

13

                      case 'B':↵

13

                      case 'B':↵

14

                          if (con.length == 0)↵

14

                          if (con.length == 0)↵

15

                              go = true;↵

15

                              go = true;↵

16

                          else {↵

16

                          else {↵

17

                              int after = getWordType(target, con.start, con.limit, offset, opts);↵

17

                              int after = getWordType(target, con.start, con.limit, offset, opts);↵

18

                              go = after == WT_IGNORE↵

18

                              go = after == WT_IGNORE↵

19

                                   || after == getPreviousWordType(target, con.start, con.limit, offset, opts);↵

19

                                   || after == getPreviousWordType(target, con.start, con.limit, offset, opts);↵

20

                          }↵

20

                          }↵

21

                          if (!go)  return -1;↵

21

                          if (!go)  return -1;↵

22

                          break;↵

22

                          break;↵

23

                      case '<':↵

23

                      case '<':↵

24

                          if (con.length == 0 || offset == con.limit)  return -1;↵

24

                          if (con.length == 0 || offset == con.limit)  return -1;↵

25

                          if (getWordType(target, con.start, con.limit, offset, opts) != WT_LETTER↵

25

                          if (getWordType(target, con.start, con.limit, offset, opts) != WT_LETTER↵

26

                              || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_OTHER)↵

26

                              || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_OTHER)↵

27

                              return -1;↵

27

                              return -1;↵

28

                          break;↵

28

                          break;↵

29

                      case '>':↵

29

                      case '>':↵

30

                          if (con.length == 0 || offset == con.start)  return -1;↵

30

                          if (con.length == 0 || offset == con.start)  return -1;↵

31

                          if (getWordType(target, con.start, con.limit, offset, opts) != WT_OTHER↵

31

                          if (getWordType(target, con.start, con.limit, offset, opts) != WT_OTHER↵

32

                              || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_LETTER)↵

32

                              || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_LETTER)↵

33

                              return -1;↵

33

                              return -1;↵

34

                          break;↵

34

                          break;↵

35

                      } // switch anchor type↵

35

                      } // switch anchor type↵

36

                      op = op.next;↵

36

                      op = op.next;↵

37

                      break;↵

37

                      break;↵

38

                  case Op.BACKREFERENCE:↵

38

                  case Op.BACKREFERENCE:↵

39

                      {↵

39

                      {↵

40

                          int refno = op.getData();↵

40

                          int refno = op.getData();↵

41

                          if (refno <= 0 || refno >= this.nofparen)↵

41

                          if (refno <= 0 || refno >= this.nofparen)↵

42

                              throw new RuntimeException("Internal Error: Reference number must be more than zero: "+refno);↵

42

                              throw new RuntimeException("Internal Error: Reference number must be more than zero: "+refno);↵

43

                          if (con.match.getBeginning(refno) < 0↵

43

                          if (con.match.getBeginning(refno) < 0↵

44

                              || con.match.getEnd(refno) < 0)↵

44

                              || con.match.getEnd(refno) < 0)↵

45

                              return -1;                // ********↵

45

                              return -1;                // ********↵

46

                          int o2 = con.match.getBeginning(refno);↵

46

                          int o2 = con.match.getBeginning(refno);↵

47

                          int literallen = con.match.getEnd(refno)-o2;↵

47

                          int literallen = con.match.getEnd(refno)-o2;↵

48

                          if (!isSet(opts, IGNORE_CASE)) {↵

48

                          if (!isSet(opts, IGNORE_CASE)) {↵

49

                              if (dx > 0) {↵

49

                              if (dx > 0) {↵

50

                                  if (!regionMatches(target, offset, con.limit, o2, literallen))↵

50

                                  if (!regionMatches(target, offset, con.limit, o2, literallen))↵

51

                                      return -1;↵

51

                                      return -1;↵

52

                                  offset += literallen;↵

52

                                  offset += literallen;↵

53

                              } else {↵

53

                              } else {↵

54

                                  if (!regionMatches(target, offset-literallen, con.limit, o2, literallen))↵

54

                                  if (!regionMatches(target, offset-literallen, con.limit, o2, literallen))↵

55

                                      return -1;↵

55

                                      return -1;↵

56

                                  offset -= literallen;↵

56

                                  offset -= literallen;↵

57

                              }↵

57

                              }↵

58

                          } else {↵

58

                          } else {↵

59

                              if (dx > 0) {↵

59

                              if (dx > 0) {↵

60

                                  if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen))↵

60

                                  if (!regionMatchesIgnoreCase(target, offset, con.limit, o2, literallen))↵

61

                                      return -1;↵

61

                                      return -1;↵

62

                                  offset += literallen;↵

62

                                  offset += literallen;↵

63

                              } else {↵

63

                              } else {↵

64

                                  if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit,↵

64

                                  if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit,↵

65

                                                               o2, literallen))↵

65

                                                               o2, literallen))↵

66

                                      return -1;↵

66

                                      return -1;↵

67

                                  offset -= literallen;↵

67

                                  offset -= literallen;↵

68

                              }↵

68

                              }↵

69

                          }↵

69

                          }↵

70

                      }↵

70

                      }↵

71

                      op = op.next;↵

71

                      op = op.next;↵

72

                      break;↵

72

                      break;↵

73

                  case Op.STRING:↵

73

                  case Op.STRING:↵

74

                      {↵

74

                      {↵

75

                          String literal = op.getString();↵

75

                          String literal = op.getString();↵

76

                          int literallen = literal.length();↵

76

                          int literallen = literal.length();↵

77

                          if (!isSet(opts, IGNORE_CASE)) {↵

77

                          if (!isSet(opts, IGNORE_CASE)) {↵

78

                              if (dx > 0) {↵

78

                              if (dx > 0) {↵

79

                                  if (!regionMatches(target, offset, con.limit, literal, literallen))↵

79

                                  if (!regionMatches(target, offset, con.limit, literal, literallen))↵

80

                                      return -1;↵

80

                                      return -1;↵

81

                                  offset += literallen;↵

81

                                  offset += literallen;↵

82

                              } else {↵

82

                              } else {↵

83

                                  if (!regionMatches(target, offset-literallen, con.limit, literal, literallen))↵

83

                                  if (!regionMatches(target, offset-literallen, con.limit, literal, literallen))↵

84

                                      return -1;↵

84

                                      return -1;↵

85

                                  offset -= literallen;↵

85

                                  offset -= literallen;↵

86

                              }↵

86

                              }↵

87

                          } else {↵

87

                          } else {↵

88

                              if (dx > 0) {↵

88

                              if (dx > 0) {↵

89

                                  if (!regionMatchesIgnoreCase(target, offset, con.limit, literal, literallen))↵

89

                                  if (!regionMatchesIgnoreCase(target, offset, con.limit, literal, literallen))↵

90

                                      return -1;↵

90

                                      return -1;↵

91

                                  offset += literallen;↵

91

                                  offset += literallen;↵

92

                              } else {↵

92

                              } else {↵

93

                                  if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit,↵

93

                                  if (!regionMatchesIgnoreCase(target, offset-literallen, con.limit,↵

94

                                                               literal, literallen))↵

94

                                                               literal, literallen))↵

95

                                      return -1;↵

95

                                      return -1;↵

96

                                  offset -= literallen;↵

96

                                  offset -= literallen;↵

97

                              }↵

97

                              }↵

98

                          }↵

98

                          }↵

99

                      }↵

99

                      }↵

100

                      op = op.next;↵

100

                      op = op.next;↵

101

                      break;↵

101

                      break;↵

102

                  case Op.CLOSURE:↵

102

                  case Op.CLOSURE:↵

103

                      {↵

103

                      {↵

104

                          /*↵

104

                          /*↵

105

                           * Saves current position to avoid↵

105

                           * Saves current position to avoid↵

106

                           * zero-width repeats.↵

106

                           * zero-width repeats.↵

107

                           */↵

107

                           */↵

108

                          int id = op.getData();↵

108

                          int id = op.getData();↵

109

                          if (id >= 0) {↵

109

                          if (id >= 0) {↵

110

                              int previousOffset = con.offsets[id];↵

110

                              int previousOffset = con.offsets[id];↵

111

                              if (previousOffset < 0 || previousOffset != offset) {↵

111

                              if (previousOffset < 0 || previousOffset != offset) {↵

112

                                  con.offsets[id] = offset;↵

112

                                  con.offsets[id] = offset;↵

113

                              } else {↵

113

                              } else {↵

114

                                  con.offsets[id] = -1;↵

114

                                  con.offsets[id] = -1;↵

115

                                  op = op.next;↵

115

                                  op = op.next;↵

116

                                  break;↵

116

                                  break;↵

117

                              }↵

117

                              }↵

118

                          }↵

118

                          }↵

119

                          int ret = this. matchString (con, op.getChild(), offset, dx, opts);↵

119

                          int ret = this. matchCharArray (con, op.getChild(), offset, dx, opts);↵

120

                          if (id >= 0)  con.offsets[id] = -1;↵

120

                          if (id >= 0)  con.offsets[id] = -1;↵

121

                          if (ret >= 0)  return ret;↵

121

                          if (ret >= 0)  return ret;↵

122

                          op = op.next;↵

122

                          op = op.next;↵

123

                      }↵

123

                      }↵

124

                      break;↵

124

                      break;↵

125

                  case Op.QUESTION:↵

125

                  case Op.QUESTION:↵

126

                      {↵

126

                      {↵

127

                          int ret = this. matchString (con, op.getChild(), offset, dx, opts);↵

127

                          int ret = this. matchCharArray (con, op.getChild(), offset, dx, opts);↵

128

                          if (ret >= 0)  return ret;↵

128

                          if (ret >= 0)  return ret;↵

129

                          op = op.next;↵

129

                          op = op.next;↵

130

                      }↵

130

                      }↵

131

                      break;↵

131

                      break;↵

132

                  case Op.NONGREEDYCLOSURE:↵

132

                  case Op.NONGREEDYCLOSURE:↵

133

                  case Op.NONGREEDYQUESTION:↵

133

                  case Op.NONGREEDYQUESTION:↵

134

                      {↵

134

                      {↵

135

                          int ret = this. matchString (con, op.next, offset, dx, opts);↵

135

                          int ret = this. matchCharArray (con, op.next, offset, dx, opts);↵

136

                          if (ret >= 0)  return ret;↵

136

                          if (ret >= 0)  return ret;↵

137

                          op = op.getChild();↵

137

                          op = op.getChild();↵

138

                      }↵

138

                      }↵

139

                      break;↵

139

                      break;↵

140

                  case Op.UNION:↵

140

                  case Op.UNION:↵

141

                      for (int i = 0;  i < op.size();  i ++) {↵

141

                      for (int i = 0;  i < op.size();  i ++) {↵

142

                          int ret = this. matchString (con, op.elementAt(i), offset, dx, opts);↵

142

                          int ret = this. matchCharArray (con, op.elementAt(i), offset, dx, opts);↵

143

                          if (DEBUG) {↵

143

                          if (DEBUG) {↵

144

                              System.err.println("UNION: "+i+", ret="+ret);↵

144

                              System.err.println("UNION: "+i+", ret="+ret);↵

145

                          }↵

145

                          }↵

146

                          if (ret >= 0)  return ret;↵

146

                          if (ret >= 0)  return ret;↵

147

                      }↵

147

                      }↵

148

                      return -1;↵

148

                      return -1;↵

149

                  case Op.CAPTURE:↵

149

                  case Op.CAPTURE:↵

150

                      int refno = op.getData();↵

150

                      int refno = op.getData();↵

151

                      if (con.match != null && refno > 0) {↵

151

                      if (con.match != null && refno > 0) {↵

152

                          int save = con.match.getBeginning(refno);↵

152

                          int save = con.match.getBeginning(refno);↵

153

                          con.match.setBeginning(refno, offset);↵

153

                          con.match.setBeginning(refno, offset);↵

154

                          int ret = this. matchString (con, op.next, offset, dx, opts);↵

154

                          int ret = this. matchCharArray (con, op.next, offset, dx, opts);↵

155

                          if (ret < 0)  con.match.setBeginning(refno, save);↵

155

                          if (ret < 0)  con.match.setBeginning(refno, save);↵

156

                          return ret;↵

156

                          return ret;↵

157

                      } else if (con.match != null && refno < 0) {↵

157

                      } else if (con.match != null && refno < 0) {↵

158

                          int index = -refno;↵

158

                          int index = -refno;↵

159

                          int save = con.match.getEnd(index);↵

159

                          int save = con.match.getEnd(index);↵

160

                          con.match.setEnd(index, offset);↵

160

                          con.match.setEnd(index, offset);↵

161

                          int ret = this. matchString (con, op.next, offset, dx, opts);↵

161

                          int ret = this. matchCharArray (con, op.next, offset, dx, opts);↵

162

                          if (ret < 0)  con.match.setEnd(index, save);↵

162

                          if (ret < 0)  con.match.setEnd(index, save);↵

163

                          return ret;↵

163

                          return ret;↵

164

                      }↵

164

                      }↵

165

                      op = op.next;↵

165

                      op = op.next;↵

166

                      break;↵

166

                      break;↵

167

                  case Op.LOOKAHEAD:↵

167

                  case Op.LOOKAHEAD:↵

168

                      if (0 > this. matchString (con, op.getChild(), offset, 1, opts))  return -1;↵

168

                      if (0 > this. matchCharArray (con, op.getChild(), offset, 1, opts))  return -1;↵

169

                      op = op.next;↵

169

                      op = op.next;↵

170

                      break;↵

170

                      break;↵

171

                  case Op.NEGATIVELOOKAHEAD:↵

171

                  case Op.NEGATIVELOOKAHEAD:↵

172

                      if (0 <= this. matchString (con, op.getChild(), offset, 1, opts))  return -1;↵

172

                      if (0 <= this. matchCharArray (con, op.getChild(), offset, 1, opts))  return -1;↵

173

                      op = op.next;↵

173

                      op = op.next;↵

174

                      break;↵

174

                      break;↵

175

                  case Op.LOOKBEHIND:↵

175

                  case Op.LOOKBEHIND:↵

176

                      if (0 > this. matchString (con, op.getChild(), offset, -1, opts))  return -1;↵

176

                      if (0 > this. matchCharArray (con, op.getChild(), offset, -1, opts))  return -1;↵

177

                      op = op.next;↵

177

                      op = op.next;↵

178

                      break;↵

178

                      break;↵

179

                  case Op.NEGATIVELOOKBEHIND:↵

179

                  case Op.NEGATIVELOOKBEHIND:↵

180

                      if (0 <= this. matchString (con, op.getChild(), offset, -1, opts))  return -1;↵

180

                      if (0 <= this. matchCharArray (con, op.getChild(), offset, -1, opts))  return -1;↵

181

                      op = op.next;↵

181

                      op = op.next;↵

182

                      break;↵

182

                      break;↵

183

                  case Op.INDEPENDENT:↵

183

                  case Op.INDEPENDENT:↵

184

                      {↵

184

                      {↵

185

                          int ret = this. matchString (con, op.getChild(), offset, dx, opts);↵

185

                          int ret = this. matchCharArray (con, op.getChild(), offset, dx, opts);↵

186

                          if (ret < 0)  return ret;↵

186

                          if (ret < 0)  return ret;↵

187

                          offset = ret;↵

187

                          offset = ret;↵

188

                          op = op.next;↵

188

                          op = op.next;↵

189

                      }↵

189

                      }↵

190

                      break;↵

190

                      break;↵

191

                  case Op.MODIFIER:↵

191

                  case Op.MODIFIER:↵

192

                      {↵

192

                      {↵

193

                          int localopts = opts;↵

193

                          int localopts = opts;↵

194

                          localopts |= op.getData();↵

194

                          localopts |= op.getData();↵

195

                          localopts &= ~op.getData2();↵

195

                          localopts &= ~op.getData2();↵

196

                          //System.err.println("MODIFIER: "+Integer.toString(opts, 16)+" -> "+Integer.toString(localopts, 16));↵

196

                          //System.err.println("MODIFIER: "+Integer.toString(opts, 16)+" -> "+Integer.toString(localopts, 16));↵

197

                          int ret = this. matchString (con, op.getChild(), offset, dx, localopts);↵

197

                          int ret = this. matchCharArray (con, op.getChild(), offset, dx, localopts);↵

198

                          if (ret < 0)  return ret;↵

198

                          if (ret < 0)  return ret;↵

199

                          offset = ret;↵

199

                          offset = ret;↵

200

                          op = op.next;↵

200

                          op = op.next;↵

201

                      }↵

201

                      }↵

202

                      break;↵

202

                      break;↵

203

                  case Op.CONDITION:↵

203

                  case Op.CONDITION:↵

204

                      {↵

204

                      {↵

205

                          Op.ConditionOp cop = (Op.ConditionOp)op;↵

205

                          Op.ConditionOp cop = (Op.ConditionOp)op;↵

206

                          boolean matchp = false;↵

206

                          boolean matchp = false;↵

207

                          if (cop.refNumber > 0) {↵

207

                          if (cop.refNumber > 0) {↵

208

                              if (cop.refNumber >= this.nofparen)↵

208

                              if (cop.refNumber >= this.nofparen)↵

209

                                  throw new RuntimeException("Internal Error: Reference number must be more than zero: "+cop.refNumber);↵

209

                                  throw new RuntimeException("Internal Error: Reference number must be more than zero: "+cop.refNumber);↵

210

                              matchp = con.match.getBeginning(cop.refNumber) >= 0↵

210

                              matchp = con.match.getBeginning(cop.refNumber) >= 0↵

211

                                       && con.match.getEnd(cop.refNumber) >= 0;↵

211

                                       && con.match.getEnd(cop.refNumber) >= 0;↵

212

                          } else {↵

212

                          } else {↵

213

                              matchp = 0 <= this. matchString (con, cop.condition, offset, dx, opts);↵

213

                              matchp = 0 <= this. matchCharArray (con, cop.condition, offset, dx, opts);↵

214

                          }↵

214

                          }↵

215

                          if (matchp) {↵

215

                          if (matchp) {↵

216

                              op = cop.yes;↵

216

                              op = cop.yes;↵

217

                          } else if (cop.no != null) {↵

217

                          } else if (cop.no != null) {↵

218

                              op = cop.no;↵

218

                              op = cop.no;↵

219

                          } else {↵

219

                          } else {↵

220

                              op = cop.next;↵

220

                              op = cop.next;↵

221

                          }↵

221

                          }↵

222

                      }↵

222

                      }↵

223

                      break;↵

223

                      break;↵

224

                  default:↵

224

                  default:↵

225

                      throw new RuntimeException("Unknown operation type: "+op.type);

225

                      throw new RuntimeException("Unknown operation type: "+op.type);

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
Time elapsed for finding largest common nesting structure subtrees (ms) | 9.0
Clones location | Clones are declared in the same class
Number of node comparisons | 390

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 33
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 17.7
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   126

       case 'z':

   126

       case 'z':

   127

       if (offset != con.limit)

   127

       if (offset != con.limit)

   128

       return -1;

   128

       return -1;

   129

       break;

   129

       break;

   130

       case 'b':

   130

       case 'b':

   131

       if (con.length == 0)

   131

       if (con.length == 0)

   132

       return -1;

   132

       return -1;

   133

       int after = getWordType(target, con.start, con.limit, offset, opts);

   133 | int after = getWordType(target, con.start, con.limit, offset, opts);
   133 | int after = getWordType(target, con.start, con.limit, offset, opts);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   java.lang.String | char[] | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type java.lang.String of variable target does not match with type char[] of variable target
   - Make classes java.lang.String and char[] extend a common superclass

   133

       int after = getWordType(target, con.start, con.limit, offset, opts);

   134

       if (after == WT_IGNORE)

   134

       if (after == WT_IGNORE)

   135

       return -1;

   135

       return -1;

   136

       int before = getPreviousWordType(target, con.start, con.limit, offset, opts);

   136 | int before = getPreviousWordType(target, con.start, con.limit, offset, opts);
   136 | int before = getPreviousWordType(target, con.start, con.limit, offset, opts);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   java.lang.String | char[] | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type java.lang.String of variable target does not match with type char[] of variable target
   - Make classes java.lang.String and char[] extend a common superclass

   136

       int before = getPreviousWordType(target, con.start, con.limit, offset, opts);

   137

       if (after == before)

   137

       if (after == before)

   138

       return -1;

   138

       return -1;

   139

       break;

   139

       break;

   140

       case 'B':

   140

       case 'B':

   141

       if (con.length == 0)

   141

       if (con.length == 0)

   142

       go = true;

   142

       go = true;

       else

       else

   143

       int after = getWordType(target, con.start, con.limit, offset, opts);

   143 | int after = getWordType(target, con.start, con.limit, offset, opts);
   143 | int after = getWordType(target, con.start, con.limit, offset, opts);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   java.lang.String | char[] | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type java.lang.String of variable target does not match with type char[] of variable target
   - Make classes java.lang.String and char[] extend a common superclass

   143

       int after = getWordType(target, con.start, con.limit, offset, opts);

   144

       go = after == WT_IGNORE || after == getPreviousWordType(target, con.start, con.limit, offset, opts);

   144 | go = after == WT_IGNORE || after == getPreviousWordType(target, con.start, con.limit, offset, opts);
   144 | go = after == WT_IGNORE || after == getPreviousWordType(target, con.start, con.limit, offset, opts);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   java.lang.String | char[] | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type java.lang.String of variable target does not match with type char[] of variable target
   - Make classes java.lang.String and char[] extend a common superclass

   144

       go = after == WT_IGNORE || after == getPreviousWordType(target, con.start, con.limit, offset, opts);

   145

       if (!go)

   145

       if (!go)

   146

       return -1;

   146

       return -1;

   147

       break;

   147

       break;

   148

       case '<':

   148

       case '<':

   149

       if (con.length == 0 || offset == con.limit)

   149

       if (con.length == 0 || offset == con.limit)

   150

       return -1;

   150

       return -1;

   151

       if (getWordType(target, con.start, con.limit, offset, opts) != WT_LETTER || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_OTHER)

   151 | if (getWordType(target, con.start, con.limit, offset, opts) != WT_LETTER || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_OTHER)
   151 | if (getWordType(target, con.start, con.limit, offset, opts) != WT_LETTER || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_OTHER)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   java.lang.String | char[] | VARIABLE_TYPE_MISMATCH
   java.lang.String | char[] | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type java.lang.String of variable target does not match with type char[] of variable target
   - Make classes java.lang.String and char[] extend a common superclass

   Type java.lang.String of variable target does not match with type char[] of variable target
   - Make classes java.lang.String and char[] extend a common superclass

   151

       if (getWordType(target, con.start, con.limit, offset, opts) != WT_LETTER || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_OTHER)

   152

       return -1;

   152

       return -1;

   153

       break;

   153

       break;

   154

       case '>':

   154

       case '>':

   155

       if (con.length == 0 || offset == con.start)

   155

       if (con.length == 0 || offset == con.start)

   156

       return -1;

   156

       return -1;

   157

       if (getWordType(target, con.start, con.limit, offset, opts) != WT_OTHER || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_LETTER)

   157 | if (getWordType(target, con.start, con.limit, offset, opts) != WT_OTHER || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_LETTER)
   157 | if (getWordType(target, con.start, con.limit, offset, opts) != WT_OTHER || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_LETTER)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   java.lang.String | char[] | VARIABLE_TYPE_MISMATCH
   java.lang.String | char[] | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type java.lang.String of variable target does not match with type char[] of variable target
   - Make classes java.lang.String and char[] extend a common superclass

   Type java.lang.String of variable target does not match with type char[] of variable target
   - Make classes java.lang.String and char[] extend a common superclass

   157

       if (getWordType(target, con.start, con.limit, offset, opts) != WT_OTHER || getPreviousWordType(target, con.start, con.limit, offset, opts) != WT_LETTER)

   158

       return -1;

   158

       return -1;

   Precondition Violations (8)
   Row | Violation
   --- | ---
   1 | Type java.lang.String of variable target does not match with type char[] of variable target
   2 | Type java.lang.String of variable target does not match with type char[] of variable target
   3 | Type java.lang.String of variable target does not match with type char[] of variable target
   4 | Type java.lang.String of variable target does not match with type char[] of variable target
   5 | Type java.lang.String of variable target does not match with type char[] of variable target
   6 | Type java.lang.String of variable target does not match with type char[] of variable target
   7 | Type java.lang.String of variable target does not match with type char[] of variable target
   8 | Type java.lang.String of variable target does not match with type char[] of variable target