From 0293e13fedd45d0dee03773c4d1ffa17c957ddc5 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Thu, 23 Jan 2014 23:07:59 +0100 Subject: [configuration] Small improvements to the command line app --- src/core/lombok/ConfigurationKeys.java | 8 +++--- .../core/configuration/ConfigurationApp.java | 31 +++++++++++----------- .../core/configuration/ConfigurationParser.java | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) (limited to 'src/core/lombok') 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> ACCESSORS_PREFIX = new ConfigurationKey>("lombok.Accessors.prefix", "Specify field prefixes, like 'f' or 'm_', to be stipped when generating getters and setters.") {}; + public static final ConfigurationKey> ACCESSORS_PREFIX = new ConfigurationKey>("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 ACCESSORS_CHAIN = new ConfigurationKey("lombok.Accessors.chain", "Generated setters should return 'this' instead if 'void'.") {}; + public static final ConfigurationKey ACCESSORS_CHAIN = new ConfigurationKey("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 ACCESSORS_FLUENT = new ConfigurationKey("lombok.Accessors.fluent", "The name for generated getters and setters will only be the field name (no get/set prefix).") {}; + public static final ConfigurationKey ACCESSORS_FLUENT = new ConfigurationKey("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 WITHER_FLAG_USAGE = new ConfigurationKey("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 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, ? extends Collection> traces = trace(keys, directory, verbose); + Map, ? extends Collection> 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 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, ? extends Collection> trace(Collection> keys, URI directory, boolean verbose) throws Exception { - if (!verbose) return Collections.emptyMap(); - + private Map, ? extends Collection> trace(Collection> keys, URI directory) throws Exception { Map, List> result = new HashMap, List>(); for (ConfigurationKey key : keys) result.put(key, new ArrayList()); + Set> used = new HashSet>(); boolean stopBubbling = false; String previousFileName = null; @@ -257,6 +252,8 @@ public class ConfigurationApp extends LombokApp { if (modifications == null) { modifications = new ArrayList(); 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.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; } -- cgit