Allow warning about targets in the default package to be suppressed

Fixes #338
This commit is contained in:
Mumfrey committed 2019-10-24 18:34:42 +01:00
1 parent 887354154c
commit 10af60bb26
2 files changed
+22 -8

No files matched your search

@@ -215,21 +215,22 @@ class AnnotatedMixin {
// Private targets, referenced by name
try {
for (String privateTarget : this.annotation.<String>getList("targets")) {
TypeHandle type = this.typeProvider.getTypeHandle(privateTarget);
for (String softTarget : this.annotation.<String>getList("targets")) {
TypeHandle type = this.typeProvider.getTypeHandle(softTarget);
if (this.targets.contains(type)) {
continue;
}
if (this.virtual) {
type = this.typeProvider.getSimulatedHandle(privateTarget, this.mixin.asType());
type = this.typeProvider.getSimulatedHandle(softTarget, this.mixin.asType());
} else if (type == null) {
this.printMessage(Kind.ERROR, "Mixin target " + privateTarget + " could not be found", this);
this.printMessage(Kind.ERROR, "Mixin target " + softTarget + " could not be found", this);
return null;
} else if (type.isPublic()) {
this.printMessage(Kind.WARNING, "Mixin target " + privateTarget + " is public and must be specified in value", this);
SuppressedBy suppressedBy = (type.getPackage().isUnnamed()) ? SuppressedBy.DEFAULT_PACKAGE : null;
this.printMessage(Kind.WARNING, "Mixin target " + softTarget + " is public and must be specified in value", this, suppressedBy);
return null;
}
this.addSoftTarget(type, privateTarget);
this.addSoftTarget(type, softTarget);
if (primaryTarget == null) {
primaryTarget = type;
}
@@ -251,6 +252,13 @@ class AnnotatedMixin {
private void printMessage(Kind kind, CharSequence msg, AnnotatedMixin mixin) {
this.messager.printMessage(kind, msg, this.mixin, this.annotation.asMirror());
}
/**
* Print a suppressible message to the AP messager
*/
private void printMessage(Kind kind, CharSequence msg, AnnotatedMixin mixin, SuppressedBy suppressedBy) {
this.messager.printMessage(kind, msg, this.mixin, this.annotation.asMirror(), suppressedBy);
}
private void addSoftTarget(TypeHandle type, String reference) {
ObfuscationData<String> obfClassData = this.obf.getDataProvider().getObfClass(type);
@@ -43,7 +43,7 @@ public enum SuppressedBy {
VISIBILITY("visibility"),
/**
* Suppress warnings when an injector target cannot be found
* Suppress warnings when an injector target cannot be found
*/
TARGET("target"),
@@ -56,7 +56,13 @@ public enum SuppressedBy {
* Suppress warnings for when an <tt>&#064;Overwrite</tt> method is missing
* javadoc, or author or reason tags
*/
OVERWRITE("overwrite");
OVERWRITE("overwrite"),
/**
* Suppress warnings when a mixin target specified by name is located in the
* default package
*/
DEFAULT_PACKAGE("default-package");
private final String token;