File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Copy.java | File path: /apache-ant-1.7.0/src/org/apache/tools/ant/taskdefs/Copy.java | |||
Method name: void doFileOperations()
|
Method name: void doResourceOperations(Map)
|
|||
Number of AST nodes: 17 | Number of AST nodes: 16 | |||
1 | Enumeration e = fileCopyMap.keys↵ | 1 | if (map.size() > 0) {↵ | |
2 | log("Copying " + map.size()↵ | |||
3 | + " resource" + (map.size() == 1 ? "" : "s")↵ | |||
4 | + " to " + destDir.getAbsolutePath());↵ | |||
2 | ();↵ | 5 | Iterator iter = map.keySet().iterator();↵ | |
3 | while (e.hasMoreElements()) {↵ | 6 | while (iter.hasNext()) {↵ | |
4 | String fromFile = (String) e.nextElement();↵ | 7 | Resource fromResource = (Resource) iter.next();↵ | |
5 | String[] toFiles = (String[]) fileCopyMap.get(fromFile);↵ | 8 | String[] toFiles = (String[]) map.get(fromResource);↵ | |
6 | for (int i = 0; i < toFiles.length; i++) {↵ | 9 | for (int i = 0; i < toFiles.length; i++) {↵ | |
7 | String toFile = toFiles[i];↵ | 10 | String toFile = toFiles[i];↵ | |
8 | if (fromFile.equals(toFile)) {↵ | 11 | try {↵ | |
9 | log("Skipping self-copy of " + fromFile, verbosity);↵ | 12 | log("↵ | |
10 | continue;↵ | |||
11 | }↵ | |||
12 | try {↵ | |||
13 | log("Copying " + fromFile + " to " + toFile,↵ | 13 | Copying " + fromResource + " to " + toFile,↵ | |
14 | verbosity);↵ | 14 | verbosity);↵ | |
15 | FilterSetCollection executionFilters =↵ | 15 | FilterSetCollection executionFilters =↵ | |
16 | new FilterSetCollection();↵ | 16 | new FilterSetCollection();↵ | |
17 | if (filtering) {↵ | 17 | if (filtering) {↵ | |
18 | executionFilters↵ | 18 | executionFilters↵ | |
19 | .addFilterSet(getProject().getGlobalFilterSet());↵ | 19 | .addFilterSet(getProject().getGlobalFilterSet());↵ | |
20 | }↵ | 20 | }↵ | |
21 | for (Enumeration filterEnum = filterSets.elements();↵ | 21 | for (Enumeration filterEnum = filterSets.elements();↵ | |
22 | filterEnum.hasMoreElements();) {↵ | 22 | filterEnum.hasMoreElements();) {↵ | |
23 | executionFilters↵ | 23 | executionFilters↵ | |
24 | .addFilterSet((FilterSet) filterEnum.nextElement());↵ | 24 | .addFilterSet((FilterSet) filterEnum.nextElement());↵ | |
25 | }↵ | 25 | }↵ | |
26 | fileUtils.copyFile(fromFile, toFile,↵ | 26 | ResourceUtils.copyResource(fromResource,↵ | |
27 | new FileResource(destDir,↵ | |||
28 | toFile),↵ | |||
27 | executionFilters,↵ | 29 | executionFilters,↵ | |
28 | filterChains,↵ | 30 | filterChains,↵ | |
29 | forceOverwrite,↵ | 31 | forceOverwrite,↵ | |
30 | preserveLastModified,↵ | 32 | preserveLastModified,↵ | |
31 | inputEncoding,↵ | 33 | inputEncoding,↵ | |
32 | outputEncoding,↵ | 34 | outputEncoding,↵ | |
33 | getProject());↵ | 35 | getProject());↵ | |
34 | } catch (IOException ioe) {↵ | 36 | } catch (IOException ioe) {↵ | |
35 | String msg = "Failed to copy " + fromFile↵ | 37 | String msg = "Failed to copy " + fromResource↵ | |
36 | + " to " + toFile↵ | 38 | + " to " + toFile↵ | |
37 | + " due to " + getDueTo(ioe);↵ | 39 | + " due to " + getDueTo(ioe);↵ | |
38 | File targetFile = new File(toFile);↵ | 40 | File targetFile = new File(toFile);↵ | |
39 | if (targetFile.exists() && !targetFile.delete()) {↵ | 41 | if (targetFile.exists() && !targetFile.delete()) {↵ | |
40 | msg += " and I couldn't delete the corrupt " + toFile;↵ | 42 | msg += " and I couldn't delete the corrupt " + toFile;↵ | |
41 | }↵ | 43 | }↵ | |
42 | if (failonerror) {↵ | 44 | if (failonerror) {↵ | |
43 | throw new BuildException(msg, ioe, getLocation());↵ | 45 | throw new BuildException(msg, ioe, getLocation());↵ | |
44 | }↵ | 46 | }↵ | |
45 | log(msg, Project.MSG_ERR);↵ | 47 | log(msg, Project.MSG_ERR);↵ | |
46 | }↵ | 48 | }↵ | |
47 | }↵ | 49 | }↵ | |
48 | } | 50 | }↵ | |
51 |
| |||
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) | 2.0 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 41 |
Number of mapped statements | 10 |
Number of unmapped statements in the first code fragment | 5 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 11.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| 5 | Resource fromResource = (Resource)iter.next(); | ||||||||||||||||||||||
5 | String fromFile = (String)e.nextElement(); |
| | ||||||||||||||||||||||
6 | String[] toFiles = (String[])fileCopyMap.get(fromFile); |
| 6 | String[] toFiles = (String[])map.get(fromResource); | |||||||||||||||||||||
7 | for (int i = 0; i < toFiles.length; i++) | 7 | for (int i = 0; i < toFiles.length; i++) | ||||||||||||||||||||||
8 | String toFile = toFiles[i]; | 8 | String toFile = toFiles[i]; | ||||||||||||||||||||||
9 | if (fromFile.equals(toFile)) |
| | ||||||||||||||||||||||
10 | log("Skipping self-copy of " + fromFile, verbosity); | | |||||||||||||||||||||||
11 | continue; |
| | ||||||||||||||||||||||
12 | try |
| 9 | try | |||||||||||||||||||||
13 | log("Copying " + fromFile + " to " + toFile, verbosity); |
| 10 | log("Copying " + fromResource + " to " + toFile, verbosity); | |||||||||||||||||||||
14 | FilterSetCollection executionFilters = new FilterSetCollection(); | 11 | FilterSetCollection executionFilters = new FilterSetCollection(); | ||||||||||||||||||||||
15 | if (filtering) | 12 | if (filtering) | ||||||||||||||||||||||
16 | executionFilters.addFilterSet(getProject().getGlobalFilterSet()); | 13 | executionFilters.addFilterSet(getProject().getGlobalFilterSet()); | ||||||||||||||||||||||
17 | for (Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements(); ) | 14 | for (Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements(); ) | ||||||||||||||||||||||
18 | executionFilters.addFilterSet((FilterSet)filterEnum.nextElement()); | 15 | executionFilters.addFilterSet((FilterSet)filterEnum.nextElement()); | ||||||||||||||||||||||
|
| 16 | ResourceUtils.copyResource(fromResource, new FileResource(destDir, toFile), executionFilters, filterChains, forceOverwrite, preserveLastModified, inputEncoding, outputEncoding, getProject()); | ||||||||||||||||||||||
19 | fileUtils.copyFile(fromFile, toFile, executionFilters, filterChains, forceOverwrite, preserveLastModified, inputEncoding, outputEncoding, getProject()); |
| |
Row | Violation |
---|---|
1 | Unmatched statement Resource fromResource=(Resource)iter.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement String fromFile=(String)e.nextElement(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Type java.lang.String of variable fromFile does not match with type org.apache.tools.ant.types.Resource of variable fromResource |
4 | Type java.util.Hashtable of variable fileCopyMap does not match with type java.util.Map of variable map |
5 | Unmatched statement if(fromFile.equals(toFile)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched continue; |
7 | Type java.lang.String of variable fromFile does not match with type org.apache.tools.ant.types.Resource of variable fromResource |
8 | Type java.lang.String of variable fromFile does not match with type org.apache.tools.ant.types.Resource of variable fromResource |
9 | Unmatched statement ResourceUtils.copyResource(fromResource,new FileResource(destDir,toFile),executionFilters,filterChains,forceOverwrite,preserveLastModified,inputEncoding,outputEncoding,getProject()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
10 | Unmatched statement ResourceUtils.copyResource(fromResource,new FileResource(destDir,toFile),executionFilters,filterChains,forceOverwrite,preserveLastModified,inputEncoding,outputEncoding,getProject()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
11 | Unmatched statement fileUtils.copyFile(fromFile,toFile,executionFilters,filterChains,forceOverwrite,preserveLastModified,inputEncoding,outputEncoding,getProject()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
12 | Unmatched statement fileUtils.copyFile(fromFile,toFile,executionFilters,filterChains,forceOverwrite,preserveLastModified,inputEncoding,outputEncoding,getProject()); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted |
13 | Clone fragment #1 returns variables toFile, executionFilters , while Clone fragment #2 returns variables toFile, executionFilters |