equal
deleted
inserted
replaced
52 * or deletion without notice.</b></p> |
52 * or deletion without notice.</b></p> |
53 */ |
53 */ |
54 public class SmartFileManager extends ForwardingJavaFileManager<JavaFileManager> { |
54 public class SmartFileManager extends ForwardingJavaFileManager<JavaFileManager> { |
55 |
55 |
56 // Set of sources that can be seen by javac. |
56 // Set of sources that can be seen by javac. |
57 Set<URI> visibleSources = new HashSet<URI>(); |
57 Set<URI> visibleSources = new HashSet<>(); |
58 // Map from modulename:packagename to artifacts. |
58 // Map from modulename:packagename to artifacts. |
59 Map<String,Set<URI>> packageArtifacts = new HashMap<String,Set<URI>>(); |
59 Map<String,Set<URI>> packageArtifacts = new HashMap<>(); |
60 // Where to print informational messages. |
60 // Where to print informational messages. |
61 PrintWriter stdout; |
61 PrintWriter stdout; |
62 |
62 |
63 public SmartFileManager(JavaFileManager fileManager) { |
63 public SmartFileManager(JavaFileManager fileManager) { |
64 super(fileManager); |
64 super(fileManager); |
67 public void setVisibleSources(Set<URI> s) { |
67 public void setVisibleSources(Set<URI> s) { |
68 visibleSources = s; |
68 visibleSources = s; |
69 } |
69 } |
70 |
70 |
71 public void cleanArtifacts() { |
71 public void cleanArtifacts() { |
72 packageArtifacts = new HashMap<String,Set<URI>>(); |
72 packageArtifacts = new HashMap<>(); |
73 } |
73 } |
74 |
74 |
75 public void setLog(PrintWriter pw) { |
75 public void setLog(PrintWriter pw) { |
76 stdout = pw; |
76 stdout = pw; |
77 } |
77 } |
91 Iterable<JavaFileObject> files = super.list(location, packageName, kinds, recurse); |
91 Iterable<JavaFileObject> files = super.list(location, packageName, kinds, recurse); |
92 if (visibleSources.isEmpty()) { |
92 if (visibleSources.isEmpty()) { |
93 return files; |
93 return files; |
94 } |
94 } |
95 // Now filter! |
95 // Now filter! |
96 ListBuffer<JavaFileObject> filteredFiles = new ListBuffer<JavaFileObject>(); |
96 ListBuffer<JavaFileObject> filteredFiles = new ListBuffer<>(); |
97 for (JavaFileObject f : files) { |
97 for (JavaFileObject f : files) { |
98 URI uri = f.toUri(); |
98 URI uri = f.toUri(); |
99 String t = uri.toString(); |
99 String t = uri.toString(); |
100 if (t.startsWith("jar:") |
100 if (t.startsWith("jar:") |
101 || t.endsWith(".class") |
101 || t.endsWith(".class") |
211 } |
211 } |
212 |
212 |
213 void addArtifact(String pkgName, URI art) { |
213 void addArtifact(String pkgName, URI art) { |
214 Set<URI> s = packageArtifacts.get(pkgName); |
214 Set<URI> s = packageArtifacts.get(pkgName); |
215 if (s == null) { |
215 if (s == null) { |
216 s = new HashSet<URI>(); |
216 s = new HashSet<>(); |
217 packageArtifacts.put(pkgName, s); |
217 packageArtifacts.put(pkgName, s); |
218 } |
218 } |
219 s.add(art); |
219 s.add(art); |
220 } |
220 } |
221 } |
221 } |