aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2013-11-20 00:34:21 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2013-12-11 22:40:48 +0100
commitf865fe5fa2d34ed8f7ac022b448a4542b0b649e2 (patch)
tree4c7d07c1d7378436f177c5de885af1de9995696c /src
parent21415af7b11e2b783ba954a8a504dc6906ff56c9 (diff)
downloadlombok-f865fe5fa2d34ed8f7ac022b448a4542b0b649e2.tar.gz
lombok-f865fe5fa2d34ed8f7ac022b448a4542b0b649e2.tar.bz2
lombok-f865fe5fa2d34ed8f7ac022b448a4542b0b649e2.zip
added contingency case in format pref scanning if there is no input
Diffstat (limited to 'src')
-rw-r--r--src/delombok/lombok/delombok/FormatPreferenceScanner.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/delombok/lombok/delombok/FormatPreferenceScanner.java b/src/delombok/lombok/delombok/FormatPreferenceScanner.java
index cb9009dc..fc823ccb 100644
--- a/src/delombok/lombok/delombok/FormatPreferenceScanner.java
+++ b/src/delombok/lombok/delombok/FormatPreferenceScanner.java
@@ -37,18 +37,18 @@ import java.util.Map;
*/
public class FormatPreferenceScanner {
/** Checks validity of preferences, and returns with a non-null value if ALL format keys are available, thus negating the need for a scan. */
- private FormatPreferences tryEasy(Map<String, String> preferences) {
+ private FormatPreferences tryEasy(Map<String, String> preferences, boolean force) {
int count = 0;
for (Map.Entry<String, String> e : preferences.entrySet()) {
if (!FormatPreferences.KEYS.containsKey(e.getKey())) throw new IllegalArgumentException("Unknown format key: " + e.getKey());
if (!"scan".equalsIgnoreCase(e.getValue())) count++;
}
- if (count >= FormatPreferences.KEYS.size()) return new FormatPreferences(preferences, "\t", false);
+ if (force || count >= FormatPreferences.KEYS.size()) return new FormatPreferences(preferences, "\t", false);
return null;
}
public FormatPreferences scan(Map<String, String> preferences, final CharSequence source) {
- FormatPreferences fps = tryEasy(preferences);
+ FormatPreferences fps = tryEasy(preferences, source == null);
if (fps != null) return fps;
try {
@@ -76,7 +76,7 @@ public class FormatPreferenceScanner {
}
public FormatPreferences scan(Map<String, String> preferences, char[] source) {
- FormatPreferences fps = tryEasy(preferences);
+ FormatPreferences fps = tryEasy(preferences, source == null);
if (fps != null) return fps;
try {
@@ -87,7 +87,7 @@ public class FormatPreferenceScanner {
}
public FormatPreferences scan(Map<String, String> preferences, Reader in) throws IOException {
- FormatPreferences fps = tryEasy(preferences);
+ FormatPreferences fps = tryEasy(preferences, in == null);
if (fps != null) return fps;
return scan_(preferences, in);