mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-27 00:23:07 +00:00
Improve detection and suppressibility of target warnings, fixes #372
This commit is contained in:
1 parent
ee74e82012
commit
d45be25395
3 files changed
+17
-2
No files matched your search
@@ -226,7 +226,7 @@ class AnnotatedMixin {
|
||||
this.printMessage(Kind.ERROR, "Mixin target " + softTarget + " could not be found", this);
|
||||
return null;
|
||||
} else if (type.isPublic()) {
|
||||
SuppressedBy suppressedBy = (type.getPackage().isUnnamed()) ? SuppressedBy.DEFAULT_PACKAGE : null;
|
||||
SuppressedBy suppressedBy = (type.getPackage().isUnnamed()) ? SuppressedBy.DEFAULT_PACKAGE : SuppressedBy.PUBLIC_TARGET;
|
||||
this.printMessage(Kind.WARNING, "Mixin target " + softTarget + " is public and must be specified in value", this, suppressedBy);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,12 @@ public enum SuppressedBy {
|
||||
*/
|
||||
DEFAULT_PACKAGE("default-package"),
|
||||
|
||||
/**
|
||||
* Suppress warnings when a mixin target is resolved by the AP as visible
|
||||
* but cannot be referenced with a class literal for some reason
|
||||
*/
|
||||
PUBLIC_TARGET("public-target"),
|
||||
|
||||
/**
|
||||
* The default java "raw types" suppressions
|
||||
*/
|
||||
|
||||
@@ -226,7 +226,16 @@ public class TypeHandle {
|
||||
* Get whether the element is probably public
|
||||
*/
|
||||
public boolean isPublic() {
|
||||
return this.getTargetElement() != null && this.getTargetElement().getModifiers().contains(Modifier.PUBLIC);
|
||||
TypeElement targetElement = this.getTargetElement();
|
||||
if (targetElement == null || !targetElement.getModifiers().contains(Modifier.PUBLIC)) {
|
||||
return false;
|
||||
}
|
||||
for (Element e = targetElement.getEnclosingElement(); e != null && e.getKind() != ElementKind.PACKAGE; e = e.getEnclosingElement()) {
|
||||
if (!e.getModifiers().contains(Modifier.PUBLIC)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user