From 8b2d4ca67c2077d7812ba4fec93d94094df0faa8 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Fri, 17 Jan 2020 15:58:55 +0100 Subject: ConfigurationApp: hide not-mentioned by default, add parameter to show them anyway. --- .../BubblingConfigurationResolver.java | 2 +- .../configuration/CheckerFrameworkVersion.java | 2 +- .../core/configuration/ConfigurationApp.java | 26 ++++++++++++++++------ 3 files changed, 21 insertions(+), 9 deletions(-) (limited to 'src/core') diff --git a/src/core/lombok/core/configuration/BubblingConfigurationResolver.java b/src/core/lombok/core/configuration/BubblingConfigurationResolver.java index 7085e2ca..45a45fdc 100644 --- a/src/core/lombok/core/configuration/BubblingConfigurationResolver.java +++ b/src/core/lombok/core/configuration/BubblingConfigurationResolver.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 The Project Lombok Authors. + * Copyright (C) 2014-2020 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/core/lombok/core/configuration/CheckerFrameworkVersion.java b/src/core/lombok/core/configuration/CheckerFrameworkVersion.java index 39d95071..587c5fec 100644 --- a/src/core/lombok/core/configuration/CheckerFrameworkVersion.java +++ b/src/core/lombok/core/configuration/CheckerFrameworkVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 The Project Lombok Authors. + * Copyright (C) 2019-2020 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/core/lombok/core/configuration/ConfigurationApp.java b/src/core/lombok/core/configuration/ConfigurationApp.java index 0b9ba078..9c225fdb 100644 --- a/src/core/lombok/core/configuration/ConfigurationApp.java +++ b/src/core/lombok/core/configuration/ConfigurationApp.java @@ -46,8 +46,10 @@ import org.mangosdk.spi.ProviderFor; import com.zwitserloot.cmdreader.CmdReader; import com.zwitserloot.cmdreader.Description; import com.zwitserloot.cmdreader.Excludes; +import com.zwitserloot.cmdreader.FullName; import com.zwitserloot.cmdreader.InvalidCommandLineException; import com.zwitserloot.cmdreader.Mandatory; +import com.zwitserloot.cmdreader.Requires; import com.zwitserloot.cmdreader.Sequential; import com.zwitserloot.cmdreader.Shorthand; @@ -89,6 +91,12 @@ public class ConfigurationApp extends LombokApp { @Description("Displays more information.") boolean verbose = false; + @Shorthand("n") + @FullName("not-mentioned") + @Requires("verbose") + @Description("Also display files that don't mention the key.") + boolean notMentioned = false; + @Shorthand("k") @Description("Limit the result to these keys.") private List key = new ArrayList(); @@ -122,7 +130,7 @@ public class ConfigurationApp extends LombokApp { return generate(keys, verbose, !args.key.isEmpty()); } - return display(keys, verbose, args.paths, !args.key.isEmpty()); + return display(keys, verbose, args.paths, !args.key.isEmpty(), args.notMentioned); } public ConfigurationApp redirectOutput(PrintStream out, PrintStream err) { @@ -168,7 +176,7 @@ public class ConfigurationApp extends LombokApp { return 0; } - public int display(Collection> keys, boolean verbose, Collection argsPaths, boolean explicitKeys) throws Exception { + public int display(Collection> keys, boolean verbose, Collection argsPaths, boolean explicitKeys, boolean notMentioned) throws Exception { TreeMap> sharedDirectories = findSharedDirectories(argsPaths); if (sharedDirectories == null) return 1; @@ -207,7 +215,7 @@ public class ConfigurationApp extends LombokApp { } URI directory = entry.getKey(); ConfigurationResolver resolver = new BubblingConfigurationResolver(cache.forUri(directory), cache.fileToSource(parser)); - Map, ? extends Collection> traces = trace(keys, directory); + Map, ? extends Collection> traces = trace(keys, directory, notMentioned); boolean printed = false; for (ConfigurationKey key : keys) { Object value = resolver.resolve(key); @@ -249,7 +257,7 @@ 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) throws Exception { + private Map, ? extends Collection> trace(Collection> keys, URI directory, boolean notMentioned) throws Exception { Map, List> result = new HashMap, List>(); for (ConfigurationKey key : keys) result.put(key, new ArrayList()); Set> used = new HashSet>(); @@ -273,12 +281,16 @@ public class ConfigurationApp extends LombokApp { List modifications = traces.get(key); if (modifications == null) { modifications = new ArrayList(); - modifications.add(" <'" + key.getKeyName() + "' not mentioned>"); + if (notMentioned) { + modifications.add(""); + modifications.add(current.description + ":"); + modifications.add(" <'" + key.getKeyName() + "' not mentioned>"); + } } else { used.add(key); + modifications.add(0, current.description + ":"); + modifications.add(0, ""); } - modifications.add(0, current.description + ":"); - modifications.add(0, ""); result.get(key).addAll(0, modifications); } } -- cgit