Add -hideGenerics option.

This commit is contained in:
Erich Schubert 2018-10-26 21:14:51 +02:00
parent dc18c503e9
commit 7169d40228
2 changed files with 7 additions and 1 deletions

View File

@ -131,6 +131,8 @@ class ClassGraph {
/** Return the class's name, possibly by stripping the leading path */ /** Return the class's name, possibly by stripping the leading path */
private static String qualifiedName(Options opt, String r) { private static String qualifiedName(Options opt, String r) {
if (opt.hideGenerics)
r = removeTemplate(r);
// Nothing to do: // Nothing to do:
if (opt.showQualified && (opt.showQualifiedGenerics || r.indexOf('<') < 0)) if (opt.showQualified && (opt.showQualifiedGenerics || r.indexOf('<') < 0))
return r; return r;
@ -183,7 +185,7 @@ class ClassGraph {
private String type(Options opt, Type t, boolean generics) { private String type(Options opt, Type t, boolean generics) {
return ((generics ? opt.showQualifiedGenerics : opt.showQualified) ? // return ((generics ? opt.showQualifiedGenerics : opt.showQualified) ? //
t.qualifiedTypeName() : t.typeName()) // t.qualifiedTypeName() : t.typeName()) //
+ typeParameters(opt, t.asParameterizedType()); + (opt.hideGenerics ? "" : typeParameters(opt, t.asParameterizedType()));
} }
/** Print the parameters of the parameterized type t */ /** Print the parameters of the parameterized type t */

View File

@ -57,6 +57,7 @@ public class Options implements Cloneable, OptionProvider {
List<Pattern> includePatterns = new ArrayList<Pattern>(); List<Pattern> includePatterns = new ArrayList<Pattern>();
boolean showQualified = false; boolean showQualified = false;
boolean showQualifiedGenerics = false; boolean showQualifiedGenerics = false;
boolean hideGenerics = false;
boolean showAttributes = false; boolean showAttributes = false;
boolean showEnumerations = false; boolean showEnumerations = false;
boolean showEnumConstants = false; boolean showEnumConstants = false;
@ -190,6 +191,7 @@ public class Options implements Cloneable, OptionProvider {
public static int optionLength(String option) { public static int optionLength(String option) {
if(matchOption(option, "qualify", true) || if(matchOption(option, "qualify", true) ||
matchOption(option, "qualifyGenerics", true) || matchOption(option, "qualifyGenerics", true) ||
matchOption(option, "hideGenerics", true) ||
matchOption(option, "horizontal", true) || matchOption(option, "horizontal", true) ||
matchOption(option, "attributes", true) || matchOption(option, "attributes", true) ||
matchOption(option, "enumconstants", true) || matchOption(option, "enumconstants", true) ||
@ -265,6 +267,8 @@ public class Options implements Cloneable, OptionProvider {
showQualified = positive; showQualified = positive;
} else if(matchOption(opt[0], "qualifyGenerics", true)) { } else if(matchOption(opt[0], "qualifyGenerics", true)) {
showQualifiedGenerics = positive; showQualifiedGenerics = positive;
} else if(matchOption(opt[0], "hideGenerics", true)) {
hideGenerics = positive;
} else if(matchOption(opt[0], "horizontal", true)) { } else if(matchOption(opt[0], "horizontal", true)) {
horizontal = positive; horizontal = positive;
} else if(matchOption(opt[0], "attributes", true)) { } else if(matchOption(opt[0], "attributes", true)) {