author | mcimadamore |
Sat, 06 Oct 2012 10:35:38 +0100 | |
changeset 14062 | b7439971a094 |
parent 6926 | f0beafc94c59 |
child 36526 | 3b41f1c69604 |
permissions | -rw-r--r-- |
6149
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
1 |
/* |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
4 |
* |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
8 |
* |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
13 |
* accompanied this code). |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
14 |
* |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
18 |
* |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
21 |
* questions. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
22 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
23 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
24 |
import java.io.File; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
25 |
import java.io.IOException; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
26 |
import java.io.InputStream; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
27 |
import java.io.OutputStream; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
28 |
import java.io.Reader; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
29 |
import java.io.Writer; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
30 |
import java.net.URI; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
31 |
import java.util.ArrayList; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
32 |
import java.util.Collections; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
33 |
import java.util.List; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
34 |
import java.util.regex.Pattern; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
35 |
import javax.lang.model.element.Modifier; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
36 |
import javax.lang.model.element.NestingKind; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
37 |
import javax.tools.JavaFileManager.Location; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
38 |
import javax.tools.JavaFileObject; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
39 |
import javax.tools.StandardJavaFileManager; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
40 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
41 |
import com.sun.tools.javac.api.WrappingJavaFileManager; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
42 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
43 |
/** |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
44 |
* A JavaFileManager that can throw IOException on attempting to read or write |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
45 |
* selected files that match a regular expression. |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
46 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
47 |
public class FileManager |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
48 |
extends WrappingJavaFileManager<StandardJavaFileManager> |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
49 |
implements StandardJavaFileManager { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
50 |
private static final String CANT_READ = "cantRead:"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
51 |
private static final String CANT_WRITE = "cantWrite:"; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
52 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
53 |
private Pattern cantRead; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
54 |
private Pattern cantWrite; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
55 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
56 |
public FileManager(StandardJavaFileManager fm, List<String> opts) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
57 |
super(fm); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
58 |
for (String opt: opts) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
59 |
if (opt.startsWith(CANT_READ)) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
60 |
cantRead = Pattern.compile(opt.substring(CANT_READ.length())); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
61 |
else if (opt.startsWith(CANT_WRITE)) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
62 |
cantWrite = Pattern.compile(opt.substring(CANT_WRITE.length())); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
63 |
else |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
64 |
throw new IllegalArgumentException(opt); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
65 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
66 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
67 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
68 |
@Override |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
69 |
protected JavaFileObject wrap(JavaFileObject fo) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
70 |
return new WrappedFileObject(fo); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
71 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
72 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
73 |
@Override |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
74 |
protected JavaFileObject unwrap(JavaFileObject fo) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
75 |
if (fo instanceof WrappedFileObject) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
76 |
return ((WrappedFileObject) fo).delegate; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
77 |
else |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
78 |
return fo; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
79 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
80 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
81 |
public Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles(Iterable<? extends File> files) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
82 |
return wrap2(fileManager.getJavaFileObjectsFromFiles(files)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
83 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
84 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
85 |
public Iterable<? extends JavaFileObject> getJavaFileObjects(File... files) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
86 |
return wrap2(fileManager.getJavaFileObjects(files)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
87 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
88 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
89 |
public Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings(Iterable<String> names) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
90 |
return wrap2(fileManager.getJavaFileObjectsFromStrings(names)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
91 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
92 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
93 |
public Iterable<? extends JavaFileObject> getJavaFileObjects(String... names) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
94 |
return wrap2(fileManager.getJavaFileObjects(names)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
95 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
96 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
97 |
/* This method is regrettably necessary because WrappingJavaFileManager.wrap takes |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
98 |
* Iterable<JavaFileObject> fileObjects |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
99 |
* instead of |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
100 |
* Iterable<? extends JavaFileObject> fileObjects |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
101 |
*/ |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
102 |
protected Iterable<JavaFileObject> wrap2(Iterable<? extends JavaFileObject> fileObjects) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
103 |
List<JavaFileObject> mapped = new ArrayList<JavaFileObject>(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
104 |
for (JavaFileObject fileObject : fileObjects) |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
105 |
mapped.add(wrap(fileObject)); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
106 |
return Collections.unmodifiableList(mapped); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
107 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
108 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
109 |
public void setLocation(Location location, Iterable<? extends File> path) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
110 |
fileManager.setLocation(location, path); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
111 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
112 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
113 |
public Iterable<? extends File> getLocation(Location location) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
114 |
return fileManager.getLocation(location); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
115 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
116 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
117 |
class WrappedFileObject implements JavaFileObject { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
118 |
WrappedFileObject(JavaFileObject fileObject) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
119 |
delegate = fileObject; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
120 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
121 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
122 |
public Kind getKind() { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
123 |
return delegate.getKind(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
124 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
125 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
126 |
public boolean isNameCompatible(String simpleName, Kind kind) { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
127 |
return delegate.isNameCompatible(simpleName, kind); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
128 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
129 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
130 |
public NestingKind getNestingKind() { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
131 |
return delegate.getNestingKind(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
132 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
133 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
134 |
public Modifier getAccessLevel() { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
135 |
return delegate.getAccessLevel(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
136 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
137 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
138 |
public URI toUri() { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
139 |
return delegate.toUri(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
140 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
141 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
142 |
public String getName() { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
143 |
return delegate.getName(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
144 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
145 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
146 |
public InputStream openInputStream() throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
147 |
checkRead(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
148 |
return delegate.openInputStream(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
149 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
150 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
151 |
public OutputStream openOutputStream() throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
152 |
checkWrite(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
153 |
return delegate.openOutputStream(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
154 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
155 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
156 |
public Reader openReader(boolean ignoreEncodingErrors) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
157 |
checkRead(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
158 |
return delegate.openReader(ignoreEncodingErrors); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
159 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
160 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
161 |
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
162 |
checkRead(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
163 |
return delegate.getCharContent(ignoreEncodingErrors); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
164 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
165 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
166 |
public Writer openWriter() throws IOException { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
167 |
checkWrite(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
168 |
return delegate.openWriter(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
169 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
170 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
171 |
public long getLastModified() { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
172 |
return delegate.getLastModified(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
173 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
174 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
175 |
public boolean delete() { |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
176 |
return delegate.delete(); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
177 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
178 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
179 |
void checkRead() throws IOException { |
6926
f0beafc94c59
6990379: two examples fail under CheckExamples on Windows
jjg
parents:
6149
diff
changeset
|
180 |
String canonName = getName().replace(File.separatorChar, '/'); |
f0beafc94c59
6990379: two examples fail under CheckExamples on Windows
jjg
parents:
6149
diff
changeset
|
181 |
if (cantRead != null && cantRead.matcher(canonName).matches()) |
6149
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
182 |
throw new IOException("FileManager: Can't read"); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
183 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
184 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
185 |
void checkWrite() throws IOException { |
6926
f0beafc94c59
6990379: two examples fail under CheckExamples on Windows
jjg
parents:
6149
diff
changeset
|
186 |
String canonName = getName().replace(File.separatorChar, '/'); |
f0beafc94c59
6990379: two examples fail under CheckExamples on Windows
jjg
parents:
6149
diff
changeset
|
187 |
if (cantWrite != null && cantWrite.matcher(canonName).matches()) |
6149
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
188 |
throw new IOException("FileManager: Can't write"); |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
189 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
190 |
|
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
191 |
JavaFileObject delegate; |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
192 |
} |
48de3564aa13
6968063: provide examples of code that generate diagnostics
jjg
parents:
diff
changeset
|
193 |
} |