Skip to content

Commit

Permalink
Improve option handling (Fixes #3528) (#3537)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmdietl committed Jul 31, 2020
1 parent 50baa53 commit b117399
Showing 1 changed file with 10 additions and 10 deletions.
Expand Up @@ -1534,35 +1534,35 @@ private Map<String, String> createActiveOptions(Map<String, String> options) {

String[] split = key.split(OPTION_SEPARATOR);

splitlengthswitch:
switch (split.length) {
case 1:
// No separator, option always active
// No separator, option always active.
activeOpts.put(key, value);
break;
case 2:
// Valid class-option pair
Class<?> clazz = this.getClass();

do {
if (clazz.getCanonicalName().equals(split[0])
|| clazz.getSimpleName().equals(split[0])) {
// Valid class-option pair.
activeOpts.put(split[1], value);
break splitlengthswitch;
}

clazz = clazz.getSuperclass();
} while (clazz != null
&& !clazz.getName()
.equals(AbstractTypeProcessor.class.getCanonicalName()));
// Didn't find a matching class. Option might be for another processor. Add
// option anyways. javac will warn if no processor supports the option.
activeOpts.put(key, value);
break;
default:
throw new UserError(
"Invalid option name: "
+ key
+ " At most one separator "
+ OPTION_SEPARATOR
+ " expected, but found "
+ (split.length - 1)
+ ".");
// Too many separators. Option might be for another processor. Add option
// anyways. javac will warn if no processor supports the option.
activeOpts.put(key, value);
}
}
return Collections.unmodifiableMap(activeOpts);
Expand Down

0 comments on commit b117399

Please sign in to comment.