aboutsummaryrefslogtreecommitdiff
path: root/src/delombok
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2013-11-20 00:17:51 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2013-12-11 22:40:48 +0100
commit21415af7b11e2b783ba954a8a504dc6906ff56c9 (patch)
tree63ee0a7290c9f85fc26f3d080f19bd30a6b55b34 /src/delombok
parent91c84ed67b18027ed84bcd8ae0a3bfd91a0a9367 (diff)
downloadlombok-21415af7b11e2b783ba954a8a504dc6906ff56c9.tar.gz
lombok-21415af7b11e2b783ba954a8a504dc6906ff56c9.tar.bz2
lombok-21415af7b11e2b783ba954a8a504dc6906ff56c9.zip
added support for CharSequences
Diffstat (limited to 'src/delombok')
-rw-r--r--src/delombok/lombok/delombok/FormatPreferenceScanner.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/delombok/lombok/delombok/FormatPreferenceScanner.java b/src/delombok/lombok/delombok/FormatPreferenceScanner.java
index 5c388a83..cb9009dc 100644
--- a/src/delombok/lombok/delombok/FormatPreferenceScanner.java
+++ b/src/delombok/lombok/delombok/FormatPreferenceScanner.java
@@ -47,6 +47,34 @@ public class FormatPreferenceScanner {
return null;
}
+ public FormatPreferences scan(Map<String, String> preferences, final CharSequence source) {
+ FormatPreferences fps = tryEasy(preferences);
+ if (fps != null) return fps;
+
+ try {
+ return scan_(preferences, new Reader() {
+ int pos = 0;
+ int max = source.length();
+
+ @Override public void close() throws IOException {
+ }
+
+ @Override public int read(char[] b, int p, int len) throws IOException {
+ int read = 0;
+ if (pos >= max) return -1;
+ for (int i = p; i < p + len; i++) {
+ b[i] = source.charAt(pos++);
+ read++;
+ if (pos == max) return read;
+ }
+ return len;
+ }
+ });
+ } catch (IOException e) {
+ throw new RuntimeException(e); //Can't happen; CAR doesn't throw these.
+ }
+ }
+
public FormatPreferences scan(Map<String, String> preferences, char[] source) {
FormatPreferences fps = tryEasy(preferences);
if (fps != null) return fps;