diff options
author | Roel Spilker <r.spilker@gmail.com> | 2014-01-23 23:07:59 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2014-01-23 23:07:59 +0100 |
commit | 0293e13fedd45d0dee03773c4d1ffa17c957ddc5 (patch) | |
tree | a46428a9bd28c2232eca68b71ef1a4c5646e89fa /src/core/lombok | |
parent | ed061712f556161d8a6eb1400fffbaace8dd1ac0 (diff) | |
download | lombok-0293e13fedd45d0dee03773c4d1ffa17c957ddc5.tar.gz lombok-0293e13fedd45d0dee03773c4d1ffa17c957ddc5.tar.bz2 lombok-0293e13fedd45d0dee03773c4d1ffa17c957ddc5.zip |
[configuration] Small improvements to the command line app
Diffstat (limited to 'src/core/lombok')
-rw-r--r-- | src/core/lombok/ConfigurationKeys.java | 8 | ||||
-rw-r--r-- | src/core/lombok/core/configuration/ConfigurationApp.java | 31 | ||||
-rw-r--r-- | src/core/lombok/core/configuration/ConfigurationParser.java | 2 |
3 files changed, 22 insertions, 19 deletions
diff --git a/src/core/lombok/ConfigurationKeys.java b/src/core/lombok/ConfigurationKeys.java index 54d8f941..44e5b43f 100644 --- a/src/core/lombok/ConfigurationKeys.java +++ b/src/core/lombok/ConfigurationKeys.java @@ -269,21 +269,21 @@ public class ConfigurationKeys { * * For any class without an {@code @Accessors} that explicitly defines the {@code prefix} option, this list of prefixes is used. */ - public static final ConfigurationKey<List<String>> ACCESSORS_PREFIX = new ConfigurationKey<List<String>>("lombok.Accessors.prefix", "Specify field prefixes, like 'f' or 'm_', to be stipped when generating getters and setters.") {}; + public static final ConfigurationKey<List<String>> ACCESSORS_PREFIX = new ConfigurationKey<List<String>>("lombok.Accessors.prefix", "Strip this field prefix, like 'f' or 'm_', from the names of generated getters and setters.") {}; /** * lombok configuration: {@code lombok.Accessors.chain} = {@code true} | {@code false}. * * For any class without an {@code @Accessors} that explicitly defines the {@code chain} option, this value is used. */ - public static final ConfigurationKey<Boolean> ACCESSORS_CHAIN = new ConfigurationKey<Boolean>("lombok.Accessors.chain", "Generated setters should return 'this' instead if 'void'.") {}; + public static final ConfigurationKey<Boolean> ACCESSORS_CHAIN = new ConfigurationKey<Boolean>("lombok.Accessors.chain", "Generate setters that return 'this' instead of 'void'.") {}; /** * lombok configuration: {@code lombok.Accessors.fluent} = {@code true} | {@code false}. * * For any class without an {@code @Accessors} that explicitly defines the {@code fluent} option, this value is used. */ - public static final ConfigurationKey<Boolean> ACCESSORS_FLUENT = new ConfigurationKey<Boolean>("lombok.Accessors.fluent", "The name for generated getters and setters will only be the field name (no get/set prefix).") {}; + public static final ConfigurationKey<Boolean> ACCESSORS_FLUENT = new ConfigurationKey<Boolean>("lombok.Accessors.fluent", "Generate getters and setters using only the field name (no get/set prefix).") {}; // ----- Builder ----- @@ -322,6 +322,8 @@ public class ConfigurationKeys { public static final ConfigurationKey<FlagUsageType> WITHER_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.Wither.flagUsage", "Emit a warning or error if @Wither is used.") {}; + // ----- Configuration System ----- + /** * lombok configuration: {@code stop-bubbling} = {@code true} | {@code false}. * diff --git a/src/core/lombok/core/configuration/ConfigurationApp.java b/src/core/lombok/core/configuration/ConfigurationApp.java index fe7f7ad4..70701adf 100644 --- a/src/core/lombok/core/configuration/ConfigurationApp.java +++ b/src/core/lombok/core/configuration/ConfigurationApp.java @@ -32,6 +32,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -58,7 +59,7 @@ public class ConfigurationApp extends LombokApp { private static final URI NO_CONFIG = URI.create(""); @Override public String getAppName() { - return "configuration"; + return "config"; } @Override public String getAppDescription() { @@ -66,7 +67,7 @@ public class ConfigurationApp extends LombokApp { } @Override public List<String> getAppAliases() { - return Arrays.asList("configuration", "config"); + return Arrays.asList("configuration", "config", "conf", "settings"); } public static class CmdArgs { @@ -192,19 +193,14 @@ public class ConfigurationApp extends LombokApp { } URI directory = entry.getKey(); ConfigurationResolver resolver = new BubblingConfigurationResolver(cache.sourcesForDirectory(directory, reporter)); - Map<ConfigurationKey<?>, ? extends Collection<String>> traces = trace(keys, directory, verbose); + Map<ConfigurationKey<?>, ? extends Collection<String>> traces = trace(keys, directory); boolean printed = false; for (ConfigurationKey<?> key : keys) { Object value = resolver.resolve(key); - if (value == null || (value instanceof List<?> && ((List<?>)value).isEmpty())) { - if (explicitKeys) { - if (printed && verbose) out.println(); - printValue(out, key, value, verbose, traces.get(key)); - printed = true; - } - } else { + Collection<String> modifications = traces.get(key); + if (!modifications.isEmpty() || explicitKeys) { if (printed && verbose) out.println(); - printValue(out, key, value, verbose, traces.get(key)); + printValue(out, key, value, verbose, modifications); printed = true; } } @@ -237,11 +233,10 @@ public class ConfigurationApp extends LombokApp { @Override public void report(String sourceDescription, String problem, int lineNumber, CharSequence line) {} }; - private Map<ConfigurationKey<?>, ? extends Collection<String>> trace(Collection<ConfigurationKey<?>> keys, URI directory, boolean verbose) throws Exception { - if (!verbose) return Collections.emptyMap(); - + private Map<ConfigurationKey<?>, ? extends Collection<String>> trace(Collection<ConfigurationKey<?>> keys, URI directory) throws Exception { Map<ConfigurationKey<?>, List<String>> result = new HashMap<ConfigurationKey<?>, List<String>>(); for (ConfigurationKey<?> key : keys) result.put(key, new ArrayList<String>()); + Set<ConfigurationKey<?>> used = new HashSet<ConfigurationKey<?>>(); boolean stopBubbling = false; String previousFileName = null; @@ -257,6 +252,8 @@ public class ConfigurationApp extends LombokApp { if (modifications == null) { modifications = new ArrayList<String>(); modifications.add(" <'" + key.getKeyName() + "' not mentioned>"); + } else { + used.add(key); } if (previousFileName != null) { modifications.add(""); @@ -267,7 +264,11 @@ public class ConfigurationApp extends LombokApp { previousFileName = configFile.getAbsolutePath(); } for (ConfigurationKey<?> key : keys) { - result.get(key).add(0, previousFileName + (stopBubbling ? " (stop bubbling):" : " (highest found):")); + if (used.contains(key)) { + result.get(key).add(0, previousFileName + (stopBubbling ? " (stopped bubbling):" : ":")); + } else { + result.put(key, Collections.<String>emptyList()); + } } return result; } diff --git a/src/core/lombok/core/configuration/ConfigurationParser.java b/src/core/lombok/core/configuration/ConfigurationParser.java index e11802ca..f0a9e142 100644 --- a/src/core/lombok/core/configuration/ConfigurationParser.java +++ b/src/core/lombok/core/configuration/ConfigurationParser.java @@ -84,7 +84,7 @@ public class ConfigurationParser { if (stringValue != null) try { value = type.getParser().parse(stringValue); } catch (Exception e) { - reporter.report(contentDescription, "Error while parsing the value for '" + keyName + "' value '" + stringValue + "' (should be a " + type.getParser().description() + ")", lineNumber, line); + reporter.report(contentDescription, "Error while parsing the value for '" + keyName + "' value '" + stringValue + "' (should be " + type.getParser().exampleValue() + ")", lineNumber, line); continue; } |