ConfigurationApp: hide not-mentioned by default, add parameter to show them anyway.

This commit is contained in:
Roel Spilker committed 2020-01-20 14:11:29 +01:00
1 parent 04523763df
commit 8b2d4ca67c
5 files changed
+23 -56

No files matched your search

@@ -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
@@ -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
@@ -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<String> key = new ArrayList<String>();
@@ -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<ConfigurationKey<?>> keys, boolean verbose, Collection<String> argsPaths, boolean explicitKeys) throws Exception {
public int display(Collection<ConfigurationKey<?>> keys, boolean verbose, Collection<String> argsPaths, boolean explicitKeys, boolean notMentioned) throws Exception {
TreeMap<URI, Set<String>> 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<ConfigurationKey<?>, ? extends Collection<String>> traces = trace(keys, directory);
Map<ConfigurationKey<?>, ? extends Collection<String>> 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<ConfigurationKey<?>, ? extends Collection<String>> trace(Collection<ConfigurationKey<?>> keys, URI directory) throws Exception {
private Map<ConfigurationKey<?>, ? extends Collection<String>> trace(Collection<ConfigurationKey<?>> keys, URI directory, boolean notMentioned) 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<?>>();
@@ -273,12 +281,16 @@ public class ConfigurationApp extends LombokApp {
List<String> modifications = traces.get(key);
if (modifications == null) {
modifications = new ArrayList<String>();
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);
}
}
@@ -27,45 +27,12 @@ Configuration for:
lombok.accessors.flagUsage = ERROR
# BASE/d1/d11/lombok.config (stopped bubbling):
# 4: lombok.accessors.flagUsage = ERROR
#
# BASE/archives/a1.jar!d2/include.config (imported from BASE/archives/a1.jar!d1/include.config:1):
# <'lombok.accessors.flagUsage' not mentioned>
#
# BASE/archives/a1.jar!d1/include.config (imported from BASE/archives/a1.jar!lombok.config:1):
# <'lombok.accessors.flagUsage' not mentioned>
#
# BASE/archives/a1.jar!lombok.config (imported from BASE/d1/d11/d111/import1.config:4):
# <'lombok.accessors.flagUsage' not mentioned>
#
# BASE/d1/d11/d111/import1.config (imported from BASE/d1/d11/d111/lombok.config:1):
# <'lombok.accessors.flagUsage' not mentioned>
#
# BASE/archives/a2.zip!reset.config (imported from BASE/d1/d11/d111/lombok.config:2):
# <'lombok.accessors.flagUsage' not mentioned>
#
# BASE/d1/d11/d111/lombok.config:
# <'lombok.accessors.flagUsage' not mentioned>
# Generate setters that return 'this' instead of 'void' (default: false).
clear lombok.accessors.chain
# BASE/d1/d11/lombok.config (stopped bubbling):
# 3: lombok.accessors.chain = false
#
# BASE/archives/a1.jar!d2/include.config (imported from BASE/archives/a1.jar!d1/include.config:1):
# <'lombok.accessors.chain' not mentioned>
#
# BASE/archives/a1.jar!d1/include.config (imported from BASE/archives/a1.jar!lombok.config:1):
# <'lombok.accessors.chain' not mentioned>
#
# BASE/archives/a1.jar!lombok.config (imported from BASE/d1/d11/d111/import1.config:4):
# <'lombok.accessors.chain' not mentioned>
#
# BASE/d1/d11/d111/import1.config (imported from BASE/d1/d11/d111/lombok.config:1):
# <'lombok.accessors.chain' not mentioned>
#
# BASE/archives/a2.zip!reset.config (imported from BASE/d1/d11/d111/lombok.config:2):
# <'lombok.accessors.chain' not mentioned>
#
# BASE/d1/d11/d111/lombok.config:
# 3: clear lombok.accessors.chain
@@ -76,22 +43,10 @@ lombok.accessors.prefix += m_
# BASE/d1/d11/lombok.config (stopped bubbling):
# 5: lombok.accessors.prefix += f
#
# BASE/archives/a1.jar!d2/include.config (imported from BASE/archives/a1.jar!d1/include.config:1):
# <'lombok.accessors.prefix' not mentioned>
#
# BASE/archives/a1.jar!d1/include.config (imported from BASE/archives/a1.jar!lombok.config:1):
# <'lombok.accessors.prefix' not mentioned>
#
# BASE/archives/a1.jar!lombok.config (imported from BASE/d1/d11/d111/import1.config:4):
# <'lombok.accessors.prefix' not mentioned>
#
# BASE/d1/d11/d111/import1.config (imported from BASE/d1/d11/d111/lombok.config:1):
# 5: lombok.accessors.prefix += z_
# 6: lombok.accessors.prefix += f
#
# BASE/archives/a2.zip!reset.config (imported from BASE/d1/d11/d111/lombok.config:2):
# <'lombok.accessors.prefix' not mentioned>
#
# BASE/d1/d11/d111/lombok.config:
# 4: lombok.accessors.prefix += m_
@@ -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
@@ -52,7 +52,7 @@ public class TestConfiguration {
PrintStream outStream = new PrintStream(rawOut);
PrintStream errStream = new PrintStream(rawErr);
int result = new ConfigurationApp().redirectOutput(outStream, errStream).display(keys, true, paths, true);
int result = new ConfigurationApp().redirectOutput(outStream, errStream).display(keys, true, paths, true, false);
outStream.flush();
errStream.flush();