File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/depend/bcel/AncestorAnalyzer.java | File path: /apache-ant-1.7.0/src/org/apache/tools/ant/util/depend/bcel/FullAnalyzer.java | |||
Method name: void determineDependencies(Vector, Vector)
|
Method name: void determineDependencies(Vector, Vector)
|
|||
Number of AST nodes: 22 | Number of AST nodes: 23 | |||
1 | while (toAnalyze.size() != 0 && count++ < maxCount) {↵ | |||
2 | DependencyVisitor dependencyVisitor = new DependencyVisitor();↵ | |||
1 | for (Enumeration e = toAnalyze.keys(); e.hasMoreElements();) {↵ | 3 | for (Enumeration e = toAnalyze.keys(); e.hasMoreElements();) {↵ | |
2 | String classname = (String) e.nextElement();↵ | 4 | String classname = (String) e.nextElement();↵ | |
3 | dependencies.put(classname, classname);↵ | 5 | dependencies.put(classname, classname);↵ | |
4 | try {↵ | 6 | try {↵ | |
5 | File container = getClassContainer(classname);↵ | 7 | File container = getClassContainer(classname);↵ | |
6 | if (container == null) {↵ | 8 | if (container == null) {↵ | |
7 | continue;↵ | 9 | continue;↵ | |
8 | }↵ | 10 | }↵ | |
9 | containers.put(container, container);↵ | 11 | containers.put(container, container);↵ | |
10 | ClassParser parser = null;↵ | 12 | ClassParser parser = null;↵ | |
11 | if (container.getName().endsWith(".class")) {↵ | 13 | if (container.getName().endsWith(".class")) {↵ | |
12 | parser = new ClassParser(container.getPath());↵ | 14 | parser = new ClassParser(container.getPath());↵ | |
13 | } else {↵ | 15 | } else {↵ | |
14 | parser = new ClassParser(container.getPath(),↵ | 16 | parser = new ClassParser(container.getPath(),↵ | |
15 | classname.replace('.', '/') + ".class");↵ | 17 | classname.replace('.', '/') + ".class");↵ | |
16 | }↵ | 18 | }↵ | |
17 | JavaClass javaClass = parser.parse();↵ | 19 | JavaClass javaClass = parser.parse();↵ | |
18 | String[] interfaces = javaClass.getInterfaceNames();↵ | 20 | ↵ | |
19 | for (int i = 0; i < interfaces.length; ++i) {↵ | |||
20 | String interfaceName = interfaces[i];↵ | |||
21 | if (!dependencies.containsKey(interfaceName)) {↵ | 21 | DescendingVisitor traverser↵ | |
22 | = new DescendingVisitor(javaClass, dependencyVisitor);↵ | |||
23 | traverser.visit();↵ | |||
24 | } catch (IOException ioe) {↵ | |||
25 | // ignore↵ | |||
22 | ↵ | 26 | }↵ | |
23 | nextAnalyze.put(interfaceName, interfaceName↵ | 27 | }↵ | |
24 | );↵ | 28 | toAnalyze.clear();↵ | |
25 | }↵ | 29 | ↵ | |
26 | }↵ | |||
27 | if (javaClass.isClas↵ | 30 | // now recover all the dependencies collected and add to the list.↵ | |
31 | Enumeration depsEnum = dependencyVisitor.getDependencies();↵ | |||
28 | s()) {↵ | 32 | while (depsEnum.hasMoreElements()) {↵ | |
29 | String superClass = javaClass.getSuperclassName();↵ | 33 | ↵ | |
30 | ↵ | 34 | String className = (String) depsEnum.nextElement();↵ | |
31 | if (!dependencies.containsKey(superClass)) {↵ | 35 | if (!dependencies.containsKey(↵ | |
32 | ↵ | 36 | className)) {↵ | |
33 | nextAnalyze.put(superClass, superClass);↵ | 37 | toAnalyze.put(↵ | |
34 | ↵ | 38 | className, className);↵ | |
35 | }↵ | 39 | ↵ | |
36 | ↵ | 40 | }↵ | |
37 | }↵ | 41 | }↵ | |
38 | } catch (IOException ioe) {↵ | |||
39 | // ignore↵ | |||
40 | }↵ | |||
41 | } | 42 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 2 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 2 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.6 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 24 |
Number of mapped statements | 1 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 7 |
Time elapsed for statement mapping (ms) | 1.7 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 17 | continue; | |||||||||||
27 | String interfaceName = interfaces[i]; |
| | |||||||||||
28 | if (!dependencies.containsKey(interfaceName)) |
| 20 | if (container.getName().endsWith(".class")) | ||||||||||
|
| 21 | parser = new ClassParser(container.getPath()); | |||||||||||
| else | |||||||||||||
|
| 22 | parser = new ClassParser(container.getPath(), classname.replace('.', '/') + ".class"); | |||||||||||
29 | nextAnalyze.put(interfaceName, interfaceName); | |
Row | Violation |
---|---|
1 | Unmatched continue; |
2 | Unmatched statement String interfaceName=interfaces[i]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement parser=new ClassParser(container.getPath()); cannot be moved, because it updates a variable modified in other unmapped statements |
4 | Unmatched statement parser=new ClassParser(container.getPath(),classname.replace('.','/') + ".class"); cannot be moved, because it updates a variable modified in other unmapped statements |
Number of mapped statements | 1 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 7 |
Time elapsed for statement mapping (ms) | 2.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 17 | continue; | |||||||||||
31 | String superClass = javaClass.getSuperclassName(); |
| | |||||||||||
32 | if (!dependencies.containsKey(superClass)) |
| 20 | if (container.getName().endsWith(".class")) | ||||||||||
|
| 21 | parser = new ClassParser(container.getPath()); | |||||||||||
| else | |||||||||||||
|
| 22 | parser = new ClassParser(container.getPath(), classname.replace('.', '/') + ".class"); | |||||||||||
33 | nextAnalyze.put(superClass, superClass); | |
Row | Violation |
---|---|
1 | Unmatched continue; |
2 | Unmatched statement String superClass=javaClass.getSuperclassName(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement parser=new ClassParser(container.getPath()); cannot be moved, because it updates a variable modified in other unmapped statements |
4 | Unmatched statement parser=new ClassParser(container.getPath(),classname.replace('.','/') + ".class"); cannot be moved, because it updates a variable modified in other unmapped statements |