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 buildMap(File, File, String[], FileNameMapper, Hashtable)
|
Method name: Map buildMap(Resource[], File, FileNameMapper)
|
|||
Number of AST nodes: 18 | Number of AST nodes: 18 | |||
1 | String↵ | 1 | HashMap map = new HashMap();↵ | |
2 | [] toCopy = null;↵ | 2 | Resource[] toCopy = null;↵ | |
3 | if (forceOverwrite) {↵ | 3 | if (forceOverwrite) {↵ | |
4 | Vector v = new Vector();↵ | 4 | Vector v = new Vector();↵ | |
5 | for (int i = 0; i < names.length; i++) {↵ | 5 | for (int i = 0; i < fromResources.length; i++) {↵ | |
6 | if (mapper.mapFileName(names[i]) != null) {↵ | 6 | if (mapper.mapFileName(fromResources[i].getName()) != null) {↵ | |
7 | v.addElement(names[i]);↵ | 7 | v.addElement(fromResources[i]);↵ | |
8 | }↵ | 8 | }↵ | |
9 | }↵ | 9 | }↵ | |
10 | toCopy = new String[v.size()];↵ | 10 | toCopy = new Resource[v.size()];↵ | |
11 | v.copyInto(toCopy);↵ | 11 | v.copyInto(toCopy);↵ | |
12 | } else {↵ | 12 | } else {↵ | |
13 | SourceFileScanner ds =↵ | 13 | toCopy =↵ | |
14 | ResourceUtils.selectOutOfDateSources(this, fromResources,↵ | |||
15 | mapper,↵ | |||
14 | new SourceFileScanner(this);↵ | 16 | new ResourceF↵ | |
15 | toCopy = ds.restrict(names, fromDir, toDir, mapper,↵ | 17 | actory() {↵ | |
18 | public Resource getResource(String name) {↵ | |||
19 | return new FileResource(toDir, name);↵ | |||
20 | }↵ | |||
21 | },↵ | |||
16 | granularity);↵ | 22 | granularity);↵ | |
17 | }↵ | 23 | }↵ | |
18 | for (int i = 0; i < toCopy.length; i++) {↵ | 24 | for (int i = 0; i < toCopy.length; i++) {↵ | |
19 | File src = new File(fromDir, toCopy[i]);↵ | |||
20 | String[] mappedFiles = mapper.mapFileName(toCopy[i]);↵ | 25 | String[] mappedFiles = mapper.mapFileName(toCopy[i].getName());↵ | |
21 | if (!enableMultipleMappings) {↵ | 26 | if (!enableMultipleMappings) {↵ | |
22 | map.put(src.getAbsolutePath(),↵ | 27 | map.put(toCopy[i],↵ | |
23 | new String[] {new File(toDir, mappedFiles[0]).getAbsolutePath()});↵ | 28 | new String[] {new File(toDir, mappedFiles[0]).getAbsolutePath()});↵ | |
24 | } else {↵ | 29 | } else {↵ | |
25 | // reuse the array created by the mapper↵ | 30 | // reuse the array created by the mapper↵ | |
26 | for (int k = 0; k < mappedFiles.length; k++) {↵ | 31 | for (int k = 0; k < mappedFiles.length; k++) {↵ | |
27 | mappedFiles[k] = new File(toDir, mappedFiles[k]).getAbsolutePath();↵ | 32 | mappedFiles[k] = new File(toDir, mappedFiles[k]).getAbsolutePath();↵ | |
28 | }↵ | 33 | }↵ | |
29 | map.put(src.getAbsolutePath(), mappedFiles);↵ | 34 | map.put(toCopy[i], mappedFiles);↵ | |
30 | }↵ | 35 | }↵ | |
31 | } | 36 | }↵ | |
37 |
| |||
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.7 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 66 |
Number of mapped statements | 11 |
Number of unmapped statements in the first code fragment | 7 |
Number of unmapped statements in the second code fragment | 7 |
Time elapsed for statement mapping (ms) | 13.7 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | HashMap map = new HashMap(); | ||||||||||||||||
1 | String[] toCopy = null; | | ||||||||||||||||
| 2 | Resource[] toCopy = null; | ||||||||||||||||
2 | if (forceOverwrite) | 3 | if (forceOverwrite) | |||||||||||||||
3 | Vector v = new Vector(); | 4 | Vector v = new Vector(); | |||||||||||||||
4 | for (int i = 0; i < names.length; i++) |
| 5 | for (int i = 0; i < fromResources.length; i++) | ||||||||||||||
5 | if (mapper.mapFileName(names[i]) != null) |
| 6 | if (mapper.mapFileName(fromResources[i].getName()) != null) | ||||||||||||||
6 | v.addElement(names[i]); |
| 7 | v.addElement(fromResources[i]); | ||||||||||||||
7 | toCopy = new String[v.size()]; |
| | |||||||||||||||
|
| 8 | toCopy = new Resource[v.size()]; | |||||||||||||||
8 | v.copyInto(toCopy); |
| 9 | v.copyInto(toCopy); | ||||||||||||||
else | | |||||||||||||||||
9 | SourceFileScanner ds = new SourceFileScanner(this); | | ||||||||||||||||
| 10 | toCopy = ResourceUtils.selectOutOfDateSources(this, fromResources, mapper, new ResourceFactory() {...}, granularity); | ||||||||||||||||
10 | toCopy = ds.restrict(names, fromDir, toDir, mapper, granularity); | | ||||||||||||||||
11 | for (int i = 0; i < toCopy.length; i++) |
| 11 | for (int i = 0; i < toCopy.length; i++) | ||||||||||||||
12 | File src = new File(fromDir, toCopy[i]); |
| | |||||||||||||||
13 | String[] mappedFiles = mapper.mapFileName(toCopy[i]); |
| 12 | String[] mappedFiles = mapper.mapFileName(toCopy[i].getName()); | ||||||||||||||
14 | if (!enableMultipleMappings) | 13 | if (!enableMultipleMappings) | |||||||||||||||
|
| 14 | map.put(toCopy[i], new String[] {new File(toDir, mappedFiles[0]).getAbsolutePath()}); | |||||||||||||||
15 | map.put(src.getAbsolutePath(), new String[] {new File(toDir, mappedFiles[0]).getAbsolutePath()}); |
| | |||||||||||||||
else | else | |||||||||||||||||
16 | for (int k = 0; k < mappedFiles.length; k++) | 15 | for (int k = 0; k < mappedFiles.length; k++) | |||||||||||||||
17 | mappedFiles[k] = new File(toDir, mappedFiles[k]).getAbsolutePath(); | 16 | mappedFiles[k] = new File(toDir, mappedFiles[k]).getAbsolutePath(); | |||||||||||||||
|
| 17 | map.put(toCopy[i], mappedFiles); | |||||||||||||||
18 | map.put(src.getAbsolutePath(), mappedFiles); |
| | |||||||||||||||
|
| 18 | return map; |
Row | Violation |
---|---|
1 | Type java.lang.String[] of variable names does not match with type org.apache.tools.ant.types.Resource[] of variable fromResources |
2 | Expression names[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression fromResources[i].getName() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
4 | Type java.lang.String[] of variable names does not match with type org.apache.tools.ant.types.Resource[] of variable fromResources |
5 | Unmatched statement toCopy=new String[v.size()]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Unmatched statement toCopy=new Resource[v.size()]; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
7 | Type java.lang.String[] of variable toCopy does not match with type org.apache.tools.ant.types.Resource[] of variable toCopy |
8 | Type java.lang.String[] of variable toCopy does not match with type org.apache.tools.ant.types.Resource[] of variable toCopy |
9 | Unmatched statement File src=new File(fromDir,toCopy[i]); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
10 | Expression toCopy[i] cannot be parameterized, because it has dependencies to/from statements that will be extracted |
11 | Expression toCopy[i].getName() cannot be parameterized, because it has dependencies to/from statements that will be extracted |
12 | Unmatched statement map.put(toCopy[i],new String[]{new File(toDir,mappedFiles[0]).getAbsolutePath()}); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
13 | Unmatched statement map.put(src.getAbsolutePath(),new String[]{new File(toDir,mappedFiles[0]).getAbsolutePath()}); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
14 | Unmatched statement map.put(toCopy[i],mappedFiles); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
15 | Unmatched statement map.put(src.getAbsolutePath(),mappedFiles); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
16 | Unmatched return map; |
17 | Clone fragment #1 returns variables v, i, mappedFiles , while Clone fragment #2 returns variables v, i, mappedFiles |