Class InjectionInfo
java.lang.Object
org.spongepowered.asm.mixin.struct.AnnotatedMethodInfo
org.spongepowered.asm.mixin.struct.SpecialMethodInfo
org.spongepowered.asm.mixin.injection.struct.InjectionInfo
- All Implemented Interfaces:
ISliceContext,IInjectionPointContext,ISelectorContext,IMessageSink
- Direct Known Subclasses:
CallbackInjectionInfo,ModifyArgInjectionInfo,ModifyArgsInjectionInfo,ModifyConstantInjectionInfo,ModifyVariableInjectionInfo,RedirectInjectionInfo
Contructs information about an injection from an
Inject annotation
and allows the injection to be processed.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceDecoration for subclasses which indicates the injector annotation that the subclass handlesstatic @interfaceDecoration for subclasses which specifies the prefix to use when conforming annotated handler methods -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final StringThe key into the annotation which contains the injection pointsstatic final StringDefault conform prefix for handler methodsprotected InjectorGroupInfoInjection groupprotected final List<InjectionPoint>Injection points parsed fromAtannotationsprotected InjectorBytecode injectorprotected final booleanAnnotated method is staticprotected final Set<ITargetSelector>Target selector(s)protected final MethodSlicesMethod slice descriptors parsed from the annotationprotected intNumber of target methods identified by the injection pointsprotected final Map<Target,List<InjectionNodes.InjectionNode>> Map of lists of nodes enumerated by callingprepare()protected final List<org.spongepowered.asm.mixin.injection.struct.InjectionInfo.SelectedTarget>Target method(s)Fields inherited from class org.spongepowered.asm.mixin.struct.SpecialMethodInfo
annotationType, classNode, methodName, mixinFields inherited from class org.spongepowered.asm.mixin.struct.AnnotatedMethodInfo
annotation, method -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInjectionInfo(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method, org.objectweb.asm.tree.AnnotationNode annotation) ctorprotectedInjectionInfo(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method, org.objectweb.asm.tree.AnnotationNode annotation, String atKey) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCallbackInvocation(org.objectweb.asm.tree.MethodNode handler) Notify method, called by injector when adding a callback into a targetvoidaddMessage(String format, Object... args) Notify method, called by injector or injection point when a notable but non-fatal failures occur, for example allows injection points to add notes when they return no results.org.objectweb.asm.tree.MethodNodeInject a method into the target classprotected voidcheckTarget(org.objectweb.asm.tree.MethodNode target) protected voidFind methods in the target class which match the parsed selectorsprotected Stringprotected StringGet info from a decoratingDynamicannotation.intGet the injected callback countstatic org.objectweb.asm.tree.AnnotationNodegetInjectorAnnotation(IMixinInfo mixin, org.objectweb.asm.tree.MethodNode method) Returns any injector annotation found on the specified method.static StringgetInjectorPrefix(org.objectweb.asm.tree.AnnotationNode annotation) Get the conform prefix for an injector handler by typeprotected Stringstatic Set<Class<? extends Annotation>>Get the slice descriptorsgetSliceId(String id) Return the mapped slice id for the specified ID.intGet number of methods being injected intovoidinject()Perform injectionsbooleanisValid()Get whether there is enough valid information in this info to actually perform an injection.voidnotifyInjected(Target target) Callback from injector which notifies us that a callback was injected.static InjectionInfoparse(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method) Parse an injector from the specified method (if an injector annotation is present).protected voidparseInjectionPoints(List<org.objectweb.asm.tree.AnnotationNode> ats) protected abstract InjectorparseInjector(org.objectweb.asm.tree.AnnotationNode injectAnnotation) protected voidprotected voidvoidPerform cleanup and post-injection tasksvoidPerform pre-injection checks and tasksvoidprepare()Discover injection pointsprotected voidParse the info from the supplied annotationprotected List<org.objectweb.asm.tree.AnnotationNode>static voidregister(Class<? extends InjectionInfo> type) Register an injector info class.toString()protected voidPost-search validation that some targets were found, we can fail-fast if no targets were actually identifiedMethods inherited from class org.spongepowered.asm.mixin.struct.SpecialMethodInfo
getClassInfo, getClassNode, getMethodNameMethods inherited from class org.spongepowered.asm.mixin.struct.AnnotatedMethodInfo
getAnnotation, getAnnotationNode, getMethod, getMixin, getParent, getSelectorAnnotation, getSelectorCoordinate, remapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.spongepowered.asm.mixin.injection.IInjectionPointContext
getAnnotationNode, getMethodMethods inherited from interface org.spongepowered.asm.mixin.injection.selectors.ISelectorContext
getAnnotation, getMixin, getParent, getSelectorAnnotation, getSelectorCoordinate, remap
-
Field Details
-
DEFAULT_PREFIX
Default conform prefix for handler methods- See Also:
-
isStatic
protected final boolean isStaticAnnotated method is static -
selectors
Target selector(s) -
targets
protected final List<org.spongepowered.asm.mixin.injection.struct.InjectionInfo.SelectedTarget> targetsTarget method(s) -
slices
Method slice descriptors parsed from the annotation -
atKey
The key into the annotation which contains the injection points -
injectionPoints
Injection points parsed fromAtannotations -
targetNodes
Map of lists of nodes enumerated by callingprepare() -
targetCount
protected int targetCountNumber of target methods identified by the injection points -
injector
Bytecode injector -
group
Injection group
-
-
Constructor Details
-
InjectionInfo
protected InjectionInfo(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method, org.objectweb.asm.tree.AnnotationNode annotation) ctor- Parameters:
mixin- Mixin datamethod- Injector methodannotation- Annotation to parse
-
InjectionInfo
protected InjectionInfo(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method, org.objectweb.asm.tree.AnnotationNode annotation, String atKey)
-
-
Method Details
-
readAnnotation
protected void readAnnotation()Parse the info from the supplied annotation -
parseSelectors
protected void parseSelectors() -
readInjectionPoints
-
parseInjectionPoints
-
parseRequirements
protected void parseRequirements() -
parseInjector
-
isValid
public boolean isValid()Get whether there is enough valid information in this info to actually perform an injection.- Returns:
- true if this InjectionInfo was successfully parsed
-
prepare
public void prepare()Discover injection points -
preInject
public void preInject()Perform pre-injection checks and tasks -
inject
public void inject()Perform injections -
postInject
public void postInject()Perform cleanup and post-injection tasks -
notifyInjected
Callback from injector which notifies us that a callback was injected. No longer used.- Parameters:
target- target into which the injector injected
-
getDescription
-
toString
-
getTargetCount
public int getTargetCount()Get number of methods being injected into- Returns:
- count of methods being injected into
-
getSlice
Get the slice descriptors- Specified by:
getSlicein interfaceISliceContext- Parameters:
id- slice id to fetch- Returns:
- method slice matching query
-
getSliceId
Return the mapped slice id for the specified ID. Injectors which only support use of a single slice will always return the default id (an empty string)- Parameters:
id- slice id- Returns:
- mapped id
-
getInjectedCallbackCount
public int getInjectedCallbackCount()Get the injected callback count- Returns:
- the injected callback count
-
addMethod
Inject a method into the target class- Parameters:
access- Method access flags, synthetic will be automatically addedname- Method namedesc- Method descriptor- Returns:
- new method
-
addCallbackInvocation
public void addCallbackInvocation(org.objectweb.asm.tree.MethodNode handler) Notify method, called by injector when adding a callback into a target- Parameters:
handler- callback handler being invoked
-
addMessage
Notify method, called by injector or injection point when a notable but non-fatal failures occur, for example allows injection points to add notes when they return no results.- Specified by:
addMessagein interfaceIMessageSink- Overrides:
addMessagein classAnnotatedMethodInfo- Parameters:
format- Message formatargs- Format args
-
getMessages
-
findTargets
protected void findTargets()Find methods in the target class which match the parsed selectors -
validateTargets
protected void validateTargets()Post-search validation that some targets were found, we can fail-fast if no targets were actually identified -
checkTarget
protected void checkTarget(org.objectweb.asm.tree.MethodNode target) -
getDynamicInfo
Get info from a decoratingDynamicannotation. If the annotation is present, a descriptive string suitable for inclusion in an error message is returned. If the annotation is not present then an empty string is returned. -
parse
public static InjectionInfo parse(MixinTargetContext mixin, org.objectweb.asm.tree.MethodNode method) Parse an injector from the specified method (if an injector annotation is present). If no injector annotation is present then null is returned.- Parameters:
mixin- contextmethod- mixin method- Returns:
- parsed InjectionInfo or null
-
getInjectorAnnotation
public static org.objectweb.asm.tree.AnnotationNode getInjectorAnnotation(IMixinInfo mixin, org.objectweb.asm.tree.MethodNode method) Returns any injector annotation found on the specified method. If multiple matching annotations are found then an exception is thrown. If no annotations are present then null is returned.- Parameters:
mixin- contextmethod- mixin method- Returns:
- annotation or null
-
getInjectorPrefix
Get the conform prefix for an injector handler by type- Parameters:
annotation- Annotation to inspect- Returns:
- conform prefix
-
register
Register an injector info class. The supplied class must be decorated with anInjectionInfo.AnnotationTypeannotation for registration purposes.- Parameters:
type- injection info subclass to register
-
getRegisteredAnnotations
-