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(char[], int, int, Match)
|
Method name: boolean matches(CharacterIterator, Match)
|
|||
Number of AST nodes: 67 | Number of AST nodes: 67 | |||
1 | if (this.fixedStringOnly) {↵ | 1 | if (this.fixedStringOnly) {↵ | |
2 | //System.err.println("DEBUG: fixed-only: "+this.fixedString);↵ | 2 | //System.err.println("DEBUG: fixed-only: "+this.fixedString);↵ | |
3 | int o = this.fixedStringTable.matches(target, con.start, con.limit);↵ | 3 | int o = this.fixedStringTable.matches(target, con.start, con.limit);↵ | |
4 | if (o >= 0) {↵ | 4 | if (o >= 0) {↵ | |
5 | if (con.match != null) {↵ | 5 | if (con.match != null) {↵ | |
6 | con.match.setBeginning(0, o);↵ | 6 | con.match.setBeginning(0, o);↵ | |
7 | con.match.setEnd(0, o+this.fixedString.length());↵ | 7 | con.match.setEnd(0, o+this.fixedString.length());↵ | |
8 | }↵ | 8 | }↵ | |
9 | con.inuse = false;↵ | 9 | con.inuse = false;↵ | |
10 | return true;↵ | 10 | return true;↵ | |
11 | }↵ | 11 | }↵ | |
12 | con.inuse = false;↵ | 12 | con.inuse = false;↵ | |
13 | return false;↵ | 13 | return false;↵ | |
14 | }↵ | 14 | }↵ | |
15 | /*↵ | 15 | /*↵ | |
16 | * The pattern contains a fixed string.↵ | 16 | * The pattern contains a fixed string.↵ | |
17 | * The engine checks with Boyer-Moore whether the text contains the fixed string or not.↵ | 17 | * The engine checks with Boyer-Moore whether the text contains the fixed string or not.↵ | |
18 | * If not, it return with false.↵ | 18 | * If not, it return with false.↵ | |
19 | */↵ | 19 | */↵ | |
20 | if (this.fixedString != null) {↵ | 20 | if (this.fixedString != null) {↵ | |
21 | int o = this.fixedStringTable.matches(target, con.start, con.limit);↵ | 21 | int o = this.fixedStringTable.matches(target, con.start, con.limit);↵ | |
22 | if (o < 0) {↵ | 22 | if (o < 0) {↵ | |
23 | //System.err.println("Non-match in fixed-string search.");↵ | 23 | //System.err.println("Non-match in fixed-string search.");↵ | |
24 | con.inuse = false;↵ | 24 | con.inuse = false;↵ | |
25 | return false;↵ | 25 | return false;↵ | |
26 | }↵ | 26 | }↵ | |
27 | }↵ | 27 | }↵ | |
28 | int limit = con.limit-this.minlength;↵ | 28 | int limit = con.limit-this.minlength;↵ | |
29 | int matchStart;↵ | 29 | int matchStart;↵ | |
30 | int matchEnd = -1;↵ | 30 | int matchEnd = -1;↵ | |
31 | /*↵ | 31 | /*↵ | |
32 | * Checks whether the expression starts with ".*".↵ | 32 | * Checks whether the expression starts with ".*".↵ | |
33 | */↵ | 33 | */↵ | |
34 | if (this.operations != null↵ | 34 | if (this.operations != null↵ | |
35 | && this.operations.type == Op.CLOSURE && this.operations.getChild().type == Op.DOT) {↵ | 35 | && this.operations.type == Op.CLOSURE && this.operations.getChild().type == Op.DOT) {↵ | |
36 | if (isSet(this.options, SINGLE_LINE)) {↵ | 36 | if (isSet(this.options, SINGLE_LINE)) {↵ | |
37 | matchStart = con.start;↵ | 37 | matchStart = con.start;↵ | |
38 | matchEnd = this. matchCharArray (con, this.operations, con.start, 1, this.options);↵ | 38 | matchEnd = this. matchCharacterIterator (con, this.operations, con.start, 1, this.options);↵ | |
39 | } else {↵ | 39 | } else {↵ | |
40 | boolean previousIsEOL = true;↵ | 40 | boolean previousIsEOL = true;↵ | |
41 | for (matchStart = con.start; matchStart <= limit; matchStart ++) {↵ | 41 | for (matchStart = con.start; matchStart <= limit; matchStart ++) {↵ | |
42 | int ch = target [ matchStart ] ;↵ | 42 | int ch = target .setIndex( matchStart ) ;↵ | |
43 | if (isEOLChar(ch)) {↵ | 43 | if (isEOLChar(ch)) {↵ | |
44 | previousIsEOL = true;↵ | 44 | previousIsEOL = true;↵ | |
45 | } else {↵ | 45 | } else {↵ | |
46 | if (previousIsEOL) {↵ | 46 | if (previousIsEOL) {↵ | |
47 | if (0 <= (matchEnd = this. matchCharArray (con, this.operations,↵ | 47 | if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations,↵ | |
48 | matchStart, 1, this.options)))↵ | 48 | matchStart, 1, this.options)))↵ | |
49 | break;↵ | 49 | break;↵ | |
50 | }↵ | 50 | }↵ | |
51 | previousIsEOL = false;↵ | 51 | previousIsEOL = false;↵ | |
52 | }↵ | 52 | }↵ | |
53 | }↵ | 53 | }↵ | |
54 | }↵ | 54 | }↵ | |
55 | }↵ | 55 | }↵ | |
56 | /*↵ | 56 | /*↵ | |
57 | * Optimization against the first character.↵ | 57 | * Optimization against the first character.↵ | |
58 | */↵ | 58 | */↵ | |
59 | else if (this.firstChar != null) {↵ | 59 | else if (this.firstChar != null) {↵ | |
60 | //System.err.println("DEBUG: with firstchar-matching: "+this.firstChar);↵ | 60 | //System.err.println("DEBUG: with firstchar-matching: "+this.firstChar);↵ | |
61 | RangeToken range = this.firstChar;↵ | 61 | RangeToken range = this.firstChar;↵ | |
62 | if (RegularExpression.isSet(this.options, IGNORE_CASE)) {↵ | 62 | if (RegularExpression.isSet(this.options, IGNORE_CASE)) {↵ | |
63 | range = this.firstChar.getCaseInsensitiveToken();↵ | 63 | range = this.firstChar.getCaseInsensitiveToken();↵ | |
64 | for (matchStart = con.start; matchStart <= limit; matchStart ++) {↵ | 64 | for (matchStart = con.start; matchStart <= limit; matchStart ++) {↵ | |
65 | int ch = target [ matchStart ] ;↵ | 65 | int ch = target .setIndex( matchStart ) ;↵ | |
66 | if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) {↵ | 66 | if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit) {↵ | |
67 | ch = REUtil.composeFromSurrogates(ch, target [ matchStart+1 ] );↵ | 67 | ch = REUtil.composeFromSurrogates(ch, target .setIndex( matchStart+1 ) );↵ | |
68 | if (!range.match(ch)) continue;↵ | 68 | if (!range.match(ch)) continue;↵ | |
69 | } else {↵ | 69 | } else {↵ | |
70 | if (!range.match(ch)) {↵ | 70 | if (!range.match(ch)) {↵ | |
71 | char ch1 = Character.toUpperCase((char)ch);↵ | 71 | char ch1 = Character.toUpperCase((char)ch);↵ | |
72 | if (!range.match(ch1))↵ | 72 | if (!range.match(ch1))↵ | |
73 | if (!range.match(Character.toLowerCase(ch1)))↵ | 73 | if (!range.match(Character.toLowerCase(ch1)))↵ | |
74 | continue;↵ | 74 | continue;↵ | |
75 | }↵ | 75 | }↵ | |
76 | }↵ | 76 | }↵ | |
77 | if (0 <= (matchEnd = this. matchCharArray (con, this.operations,↵ | 77 | if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations,↵ | |
78 | matchStart, 1, this.options)))↵ | 78 | matchStart, 1, this.options)))↵ | |
79 | break;↵ | 79 | break;↵ | |
80 | }↵ | 80 | }↵ | |
81 | } else {↵ | 81 | } else {↵ | |
82 | for (matchStart = con.start; matchStart <= limit; matchStart ++) {↵ | 82 | for (matchStart = con.start; matchStart <= limit; matchStart ++) {↵ | |
83 | int ch = target [ matchStart ] ;↵ | 83 | int ch = target .setIndex( matchStart ) ;↵ | |
84 | if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit)↵ | 84 | if (REUtil.isHighSurrogate(ch) && matchStart+1 < con.limit)↵ | |
85 | ch = REUtil.composeFromSurrogates(ch, target [ matchStart+1 ] );↵ | 85 | ch = REUtil.composeFromSurrogates(ch, target .setIndex( matchStart+1 ) );↵ | |
86 | if (!range.match(ch)) continue;↵ | 86 | if (!range.match(ch)) continue;↵ | |
87 | if (0 <= (matchEnd = this. matchCharArray (con, this.operations,↵ | 87 | if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations,↵ | |
88 | matchStart, 1, this.options)))↵ | 88 | matchStart, 1, this.options)))↵ | |
89 | break;↵ | 89 | break;↵ | |
90 | }↵ | 90 | }↵ | |
91 | }↵ | 91 | }↵ | |
92 | }↵ | 92 | }↵ | |
93 | /*↵ | 93 | /*↵ | |
94 | * Straightforward matching.↵ | 94 | * Straightforward matching.↵ | |
95 | */↵ | 95 | */↵ | |
96 | else {↵ | 96 | else {↵ | |
97 | for (matchStart = con.start; matchStart <= limit; matchStart ++) {↵ | 97 | for (matchStart = con.start; matchStart <= limit; matchStart ++) {↵ | |
98 | if (0 <= (matchEnd = this. matchCharArray (con, this.operations, matchStart, 1, this.options)))↵ | 98 | if (0 <= (matchEnd = this. matchCharacterIterator (con, this.operations, matchStart, 1, this.options)))↵ | |
99 | break;↵ | 99 | break;↵ | |
100 | }↵ | 100 | }↵ | |
101 | }↵ | 101 | }↵ | |
102 | if (matchEnd >= 0) {↵ | 102 | if (matchEnd >= 0) {↵ | |
103 | if (con.match != null) {↵ | 103 | if (con.match != null) {↵ | |
104 | con.match.setBeginning(0, matchStart);↵ | 104 | con.match.setBeginning(0, matchStart);↵ | |
105 | con.match.setEnd(0, matchEnd);↵ | 105 | con.match.setEnd(0, matchEnd);↵ | |
106 | }↵ | 106 | }↵ | |
107 | con.inuse = false;↵ | 107 | con.inuse = false;↵ | |
108 | return true;↵ | 108 | return true;↵ | |
109 | } else {↵ | 109 | } else {↵ | |
110 | con.inuse = false;↵ | 110 | con.inuse = false;↵ | |
111 | return false;↵ | 111 | return false;↵ | |
112 | } | 112 |
| |
See real code fragment | See real code fragment |
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) | 14.2 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 369 |
Number of mapped statements | 67 |
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) | 26.2 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
26 | if (this.fixedStringOnly) | 28 | if (this.fixedStringOnly) | |||||||||||||
27 | int o = this.fixedStringTable.matches(target, con.start, con.limit); |
| 29 | int o = this.fixedStringTable.matches(target, con.start, con.limit); | ||||||||||||
28 | if (o >= 0) | 30 | if (o >= 0) | |||||||||||||
29 | if (con.match != null) | 31 | if (con.match != null) | |||||||||||||
30 | con.match.setBeginning(0, o); | 32 | con.match.setBeginning(0, o); | |||||||||||||
31 | con.match.setEnd(0, o + this.fixedString.length()); | 33 | con.match.setEnd(0, o + this.fixedString.length()); | |||||||||||||
32 | con.inuse = false; | 34 | con.inuse = false; | |||||||||||||
33 | return true; |
| 35 | return true; | ||||||||||||
34 | con.inuse = false; | 36 | con.inuse = false; | |||||||||||||
35 | return false; |
| 37 | return false; | ||||||||||||
36 | if (this.fixedString != null) | 38 | if (this.fixedString != null) | |||||||||||||
37 | int o = this.fixedStringTable.matches(target, con.start, con.limit); |
| 39 | int o = this.fixedStringTable.matches(target, con.start, con.limit); | ||||||||||||
38 | if (o < 0) | 40 | if (o < 0) | |||||||||||||
39 | con.inuse = false; | 41 | con.inuse = false; | |||||||||||||
40 | return false; |
| 42 | return false; | ||||||||||||
41 | int limit = con.limit - this.minlength; | 43 | int limit = con.limit - this.minlength; | |||||||||||||
42 | int matchStart; | 44 | int matchStart; | |||||||||||||
43 | int matchEnd = -1; | 45 | int matchEnd = -1; | |||||||||||||
44 | if (this.operations != null && this.operations.type == Op.CLOSURE && this.operations.getChild().type == Op.DOT) | 46 | if (this.operations != null && this.operations.type == Op.CLOSURE && this.operations.getChild().type == Op.DOT) | |||||||||||||
45 | if (isSet(this.options, SINGLE_LINE)) | 47 | if (isSet(this.options, SINGLE_LINE)) | |||||||||||||
46 | matchStart = con.start; | 48 | matchStart = con.start; | |||||||||||||
47 | matchEnd = this.matchCharArray(con, this.operations, con.start, 1, this.options); |
| 49 | matchEnd = this.matchCharacterIterator(con, this.operations, con.start, 1, this.options); | ||||||||||||
else | else | |||||||||||||||
48 | boolean previousIsEOL = true; | 50 | boolean previousIsEOL = true; | |||||||||||||
49 | for (matchStart = con.start; matchStart <= limit; matchStart++) | 51 | for (matchStart = con.start; matchStart <= limit; matchStart++) | |||||||||||||
50 | int ch = target[matchStart]; |
| 52 | int ch = target.setIndex(matchStart); | ||||||||||||
51 | if (isEOLChar(ch)) | 53 | if (isEOLChar(ch)) | |||||||||||||
52 | previousIsEOL = true; | 54 | previousIsEOL = true; | |||||||||||||
else | else | |||||||||||||||
53 | if (previousIsEOL) | 55 | if (previousIsEOL) | |||||||||||||
54 | if (0 <= (matchEnd = this.matchCharArray(con, this.operations, matchStart, 1, this.options))) |
| 56 | if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options))) | ||||||||||||
55 | break; | 57 | break; | |||||||||||||
56 | previousIsEOL = false; | 58 | previousIsEOL = false; | |||||||||||||
57 | else if (this.firstChar != null) | 59 | else if (this.firstChar != null) | |||||||||||||
58 | RangeToken range = this.firstChar; | 60 | RangeToken range = this.firstChar; | |||||||||||||
59 | if (RegularExpression.isSet(this.options, IGNORE_CASE)) | 61 | if (RegularExpression.isSet(this.options, IGNORE_CASE)) | |||||||||||||
60 | range = this.firstChar.getCaseInsensitiveToken(); | 62 | range = this.firstChar.getCaseInsensitiveToken(); | |||||||||||||
61 | for (matchStart = con.start; matchStart <= limit; matchStart++) | 63 | for (matchStart = con.start; matchStart <= limit; matchStart++) | |||||||||||||
62 | int ch = target[matchStart]; |
| 64 | int ch = target.setIndex(matchStart); | ||||||||||||
63 | if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit) | 65 | if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit) | |||||||||||||
64 | ch = REUtil.composeFromSurrogates(ch, target[matchStart + 1]); |
| 66 | ch = REUtil.composeFromSurrogates(ch, target.setIndex(matchStart + 1)); | ||||||||||||
65 | if (!range.match(ch)) | 67 | if (!range.match(ch)) | |||||||||||||
66 | continue; | 68 | continue; | |||||||||||||
else | else | |||||||||||||||
67 | if (!range.match(ch)) | 69 | if (!range.match(ch)) | |||||||||||||
68 | char ch1 = Character.toUpperCase((char)ch); | 70 | char ch1 = Character.toUpperCase((char)ch); | |||||||||||||
69 | if (!range.match(ch1)) | 71 | if (!range.match(ch1)) | |||||||||||||
70 | if (!range.match(Character.toLowerCase(ch1))) | 72 | if (!range.match(Character.toLowerCase(ch1))) | |||||||||||||
71 | continue; | 73 | continue; | |||||||||||||
72 | if (0 <= (matchEnd = this.matchCharArray(con, this.operations, matchStart, 1, this.options))) |
| 74 | if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options))) | ||||||||||||
73 | break; | 75 | break; | |||||||||||||
else | else | |||||||||||||||
74 | for (matchStart = con.start; matchStart <= limit; matchStart++) | 76 | for (matchStart = con.start; matchStart <= limit; matchStart++) | |||||||||||||
75 | int ch = target[matchStart]; |
| 77 | int ch = target.setIndex(matchStart); | ||||||||||||
76 | if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit) | 78 | if (REUtil.isHighSurrogate(ch) && matchStart + 1 < con.limit) | |||||||||||||
77 | ch = REUtil.composeFromSurrogates(ch, target[matchStart + 1]); |
| 79 | ch = REUtil.composeFromSurrogates(ch, target.setIndex(matchStart + 1)); | ||||||||||||
78 | if (!range.match(ch)) | 80 | if (!range.match(ch)) | |||||||||||||
79 | continue; | 81 | continue; | |||||||||||||
80 | if (0 <= (matchEnd = this.matchCharArray(con, this.operations, matchStart, 1, this.options))) |
| 82 | if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options))) | ||||||||||||
81 | break; | 83 | break; | |||||||||||||
else | else | |||||||||||||||
82 | for (matchStart = con.start; matchStart <= limit; matchStart++) | 84 | for (matchStart = con.start; matchStart <= limit; matchStart++) | |||||||||||||
83 | if (0 <= (matchEnd = this.matchCharArray(con, this.operations, matchStart, 1, this.options))) |
| 85 | if (0 <= (matchEnd = this.matchCharacterIterator(con, this.operations, matchStart, 1, this.options))) | ||||||||||||
84 | break; | 86 | break; | |||||||||||||
85 | if (matchEnd >= 0) | 87 | if (matchEnd >= 0) | |||||||||||||
86 | if (con.match != null) | 88 | if (con.match != null) | |||||||||||||
87 | con.match.setBeginning(0, matchStart); | 89 | con.match.setBeginning(0, matchStart); | |||||||||||||
88 | con.match.setEnd(0, matchEnd); | 90 | con.match.setEnd(0, matchEnd); | |||||||||||||
89 | con.inuse = false; | 91 | con.inuse = false; | |||||||||||||
90 | return true; |
| 92 | return true; | ||||||||||||
else | else | |||||||||||||||
91 | con.inuse = false; | 93 | con.inuse = false; | |||||||||||||
92 | return false; |
| 94 | return false; |
Row | Violation |
---|---|
1 | Type char[] of variable target does not match with type java.text.CharacterIterator of variable target |
2 | Type char[] of variable target does not match with type java.text.CharacterIterator of variable target |
3 | Expression this.matchCharArray(con,this.operations,con.start,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Expression this.matchCharacterIterator(con,this.operations,con.start,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
5 | Expression target[matchStart] cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression target.setIndex(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression this.matchCharArray(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
8 | Expression this.matchCharacterIterator(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
9 | Expression target[matchStart] cannot be parameterized, because it has dependencies to/from statements that will be extracted |
10 | Expression target.setIndex(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression target[matchStart + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Expression target.setIndex(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
13 | Expression this.matchCharArray(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
14 | Expression this.matchCharacterIterator(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
15 | Expression target[matchStart] cannot be parameterized, because it has dependencies to/from statements that will be extracted |
16 | Expression target.setIndex(matchStart) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
17 | Expression target[matchStart + 1] cannot be parameterized, because it has dependencies to/from statements that will be extracted |
18 | Expression target.setIndex(matchStart + 1) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
19 | Expression this.matchCharArray(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
20 | Expression this.matchCharacterIterator(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
21 | Expression this.matchCharArray(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
22 | Expression this.matchCharacterIterator(con,this.operations,matchStart,1,this.options) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
23 | Conditional return true; |
24 | Conditional return true; |
25 | Conditional return false; |
26 | Conditional return false; |
27 | Conditional return false; |
28 | Conditional return false; |
29 | Conditional return false; |
30 | Conditional return false; |
31 | Conditional return true; |
32 | Conditional return true; |