From f865fe5fa2d34ed8f7ac022b448a4542b0b649e2 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Wed, 20 Nov 2013 00:34:21 +0100 Subject: added contingency case in format pref scanning if there is no input --- src/delombok/lombok/delombok/FormatPreferenceScanner.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') 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 preferences) { + private FormatPreferences tryEasy(Map preferences, boolean force) { int count = 0; for (Map.Entry 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 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 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 preferences, Reader in) throws IOException { - FormatPreferences fps = tryEasy(preferences); + FormatPreferences fps = tryEasy(preferences, in == null); if (fps != null) return fps; return scan_(preferences, in); -- cgit