Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Harley2008-09-28 02:17:55 +0000
committerWalter Harley2008-09-28 02:17:55 +0000
commit33487cc981d428d38caef48b42bdb5a92d78e5bf (patch)
tree027961d5530a952712f8b97cb7dd0d1a18613bc9 /org.eclipse.jdt.apt.pluggable.core
parent9fba4e7dd11006e339abd70df0a4cf770da6d0e9 (diff)
downloadeclipse.jdt.core-33487cc981d428d38caef48b42bdb5a92d78e5bf.tar.gz
eclipse.jdt.core-33487cc981d428d38caef48b42bdb5a92d78e5bf.tar.xz
eclipse.jdt.core-33487cc981d428d38caef48b42bdb5a92d78e5bf.zip
Bug 246089 - implement Filer.getCharContent using jdt.core utility method
Diffstat (limited to 'org.eclipse.jdt.apt.pluggable.core')
-rw-r--r--org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeInputFileObject.java25
1 files changed, 8 insertions, 17 deletions
diff --git a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeInputFileObject.java b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeInputFileObject.java
index c1693a6541..5224376e36 100644
--- a/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeInputFileObject.java
+++ b/org.eclipse.jdt.apt.pluggable.core/src/org/eclipse/jdt/internal/apt/pluggable/core/filer/IdeInputFileObject.java
@@ -18,7 +18,6 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
-import java.io.StringWriter;
import java.io.Writer;
import java.net.URI;
@@ -26,6 +25,7 @@ import javax.tools.FileObject;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.internal.core.util.Util;
/**
* Implementation of a FileObject returned by Filer.getResource().
@@ -47,27 +47,18 @@ public class IdeInputFileObject implements FileObject {
throw new IllegalStateException("An annotation processor is not permitted to delete resources");
}
- /* (non-Javadoc)
+ /**
* @see javax.tools.FileObject#getCharContent(boolean)
*/
@Override
- public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
- // Use buffer size at least as big as the default size of the
- // BufferedReader returned by openReader(), to reduce redundant
- // copying. See BufferedReader.read1() for details.
- char[] buffer = new char[8192];
- StringWriter w = new StringWriter();
- Reader r = openReader(ignoreEncodingErrors);
+ public CharSequence getCharContent(boolean ignoreEncodingErrors)
+ throws IOException {
try {
- int read = -1;
- while ((read = r.read(buffer)) != -1) {
- w.write(buffer, 0, read);
- }
- }
- finally {
- r.close();
+ char[] chars = Util.getResourceContentsAsCharArray(this._file);
+ return new String(chars);
+ } catch (CoreException e) {
+ throw new IOException(e);
}
- return w.getBuffer();
}
/* (non-Javadoc)

Back to the top