File path: /jEdit-4.2/src/gnu/regexp/REFilterInputStream.java | File path: /jEdit-4.2/src/gnu/regexp/REFilterReader.java | |||
Method name: int read()
|
Method name: int read()
|
|||
Number of AST nodes: 20 | Number of AST nodes: 20 | |||
1 | if ((buffer != null) && (bufpos < buffer.length())) {↵ | 1 | if ((buffer != null) && (bufpos < buffer.length())) {↵ | |
2 | return (int) buffer.charAt(bufpos++);↵ | 2 | return (int) buffer.charAt(bufpos++);↵ | |
3 | }↵ | 3 | }↵ | |
4 | // check if input is at a valid position↵ | 4 | // check if input is at a valid position↵ | |
5 | if (!stream.isValid()) return -1;↵ | 5 | if (!stream.isValid()) return -1;↵ | |
6 | REMatch mymatch = new REMatch(expr.getNumSubs(),offset,0);↵ | 6 | REMatch mymatch = new REMatch(expr.getNumSubs(),offset,0);↵ | |
7 | if (expr.match(stream, mymatch)) {↵ | 7 | if (expr.match(stream,mymatch)) {↵ | |
8 | mymatch.end[0] = mymatch.index;↵ | 8 | mymatch.end[0] = mymatch.index;↵ | |
9 | mymatch.finish(stream);↵ | 9 | mymatch.finish(stream);↵ | |
10 | stream.move(mymatch.toString().length());↵ | 10 | stream.move(mymatch.toString().length());↵ | |
11 | offset += mymatch.toString().length();↵ | 11 | offset += mymatch.toString().length();↵ | |
12 | buffer = mymatch.substituteInto(replace);↵ | 12 | buffer = mymatch.substituteInto(replace);↵ | |
13 | bufpos = 1;↵ | 13 | bufpos = 1;↵ | |
14 | // This is prone to infinite loops if replace string turns out empty.↵ | |||
15 | if (buffer.length() > 0) {↵ | 14 | if (buffer.length() > 0) {↵ | |
16 | return buffer.charAt(0);↵ | 15 | return buffer.charAt(0);↵ | |
17 | }↵ | 16 | }↵ | |
18 | }↵ | 17 | }↵ | |
19 | char ch = stream.charAt(0);↵ | 18 | char ch = stream.charAt(0);↵ | |
20 | if (ch == CharIndexed.OUT_OF_BOUNDS) return -1;↵ | 19 | if (ch == CharIndexed.OUT_OF_BOUNDS) return -1;↵ | |
21 | stream.move(1);↵ | 20 | stream.move(1);↵ | |
22 | offset++;↵ | 21 | offset++;↵ | |
23 | return ch; | 22 |
| |
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) | 1.3 |
Clones location | Clones are in different classes |
Number of node comparisons | 83 |
Number of mapped statements | 20 |
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) | 29.0 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | if ((buffer != null) && (bufpos < buffer.length())) | 1 | if ((buffer != null) && (bufpos < buffer.length())) | |||||||||||
2 | return (int)buffer.charAt(bufpos++); | 2 | return (int)buffer.charAt(bufpos++); | |||||||||||
3 | if (!stream.isValid()) |
| 3 | if (!stream.isValid()) | ||||||||||
4 | return -1; | 4 | return -1; | |||||||||||
5 | REMatch mymatch = new REMatch(expr.getNumSubs(), offset, 0); | 5 | REMatch mymatch = new REMatch(expr.getNumSubs(), offset, 0); | |||||||||||
6 | if (expr.match(stream, mymatch)) |
| 6 | if (expr.match(stream, mymatch)) | ||||||||||
7 | mymatch.end[0] = mymatch.index; | 7 | mymatch.end[0] = mymatch.index; | |||||||||||
8 | mymatch.finish(stream); |
| 8 | mymatch.finish(stream); | ||||||||||
9 | stream.move(mymatch.toString().length()); |
| 9 | stream.move(mymatch.toString().length()); | ||||||||||
10 | offset += mymatch.toString().length(); | 10 | offset += mymatch.toString().length(); | |||||||||||
11 | buffer = mymatch.substituteInto(replace); | 11 | buffer = mymatch.substituteInto(replace); | |||||||||||
12 | bufpos = 1; | 12 | bufpos = 1; | |||||||||||
13 | if (buffer.length() > 0) | 13 | if (buffer.length() > 0) | |||||||||||
14 | return buffer.charAt(0); | 14 | return buffer.charAt(0); | |||||||||||
15 | char ch = stream.charAt(0); |
| 15 | char ch = stream.charAt(0); | ||||||||||
16 | if (ch == CharIndexed.OUT_OF_BOUNDS) | 16 | if (ch == CharIndexed.OUT_OF_BOUNDS) | |||||||||||
17 | return -1; | 17 | return -1; | |||||||||||
18 | stream.move(1); |
| 18 | stream.move(1); | ||||||||||
19 | offset++; | 19 | offset++; | |||||||||||
20 | return ch; | 20 | return ch; |
Row | Violation |
---|---|
1 | The refactoring of the clones is infeasible, because classes gnu.regexp.REFilterInputStream and gnu.regexp.REFilterReader do not have a common superclass |