int position = finder.find();
if(position>=0) {
// mark found pattern
//text.grabFocus();
mark(position,position + findTextField.getText().length());
} else
// delete marks
{
mark(0, 0);
JOptionPane.showMessageDialog(this, "String was not found!");
}
int position = finder.findnext();
if(position>=0) {
// mark found pattern (select)
//text.grabFocus();
mark(position,position + findTextField.getText().length());
} else
// delete marks (unselect)
{
mark(0, 0);
JOptionPane.showMessageDialog(this, "String was not found!");
}
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/core/src/main/java/org/columba/core/gui/util/FindDialog.java
|
|
File path: /columba-1.4-src/core/src/main/java/org/columba/core/gui/util/FindDialog.java
|
Method name: void actionPerformed(ActionEvent)
|
|
Method name: void actionPerformed(ActionEvent)
|
Number of AST nodes: 5
|
|
Number of AST nodes: 5
|
|
1 | int position = finder.find();↵ | | 1 | int position = finder.findnext();↵
|
| | | 2 | ↵
|
2 | if(position>=0) {↵ | | 3 | if(position>=0) {↵
|
3 | // mark found pattern↵ | | 4 | // mark found pattern (select)↵
|
4 | //text.grabFocus();↵ | | 5 | //text.grabFocus(); ↵
|
5 | mark(position,position + findTextField.getText().length());↵ | | 6 | mark(position,position + findTextField.getText().length());↵
|
6 | } else↵ | | 7 | } else↵
|
7 | // delete marks↵ | | 8 | // delete marks (unselect)↵
|
8 | {↵ | | 9 | {↵
|
9 | mark(0, 0);↵ | | 10 | mark(0, 0);↵
|
10 | JOptionPane.showMessageDialog(this, "String was not found!");↵ | | 11 | JOptionPane.showMessageDialog(this, "String was not found!");↵
|
11 | } | | 12 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2 |
Clones location | Clones are in the same method |
Number of node comparisons | 18 |
-
{Refactorable}
Mapping Summary
Number of mapped statements | 5 |
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) | 5.1 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
11 | int position = finder.find(); | | 17 | int position = finder.findnext(); |
12 | if (position >= 0) | | 18 | if (position >= 0) |
13 | mark(position, position + findTextField.getText().length()); | | 19 | mark(position, position + findTextField.getText().length()); |
| | | | |
14 | | | 20 | |
15 | JOptionPane.showMessageDialog(this, "String was not found!"); | | 21 | JOptionPane.showMessageDialog(this, "String was not found!"); |
Precondition Violations (2)
Row |
Violation |
1 | Expression finder.find() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression finder.findnext() cannot be parameterized, because it has dependencies to/from statements that will be extracted |