Package org.spongepowered.asm.util
Class ClassSignature
- java.lang.Object
-
- org.spongepowered.asm.util.ClassSignature
-
public class ClassSignature extends java.lang.ObjectRepresents an object-oriented view of a generic class signature. We use ASM'sSignatureVisitorto walk over an incoming signature in order to parse out our internal tree. This is done so that incoming signatures from mixins can be merged into the target class.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringOBJECT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInterface(java.lang.String iface)Add a raw interface declaration to this signatureprotected voidaddInterface(org.spongepowered.asm.util.ClassSignature.Token iface)Add an interface to this signatureprotected voidaddRawInterface(java.lang.String iface)Add a raw interface which was previously enqueuedprotected voidaddTypeVar(org.spongepowered.asm.util.ClassSignature.TypeVar typeVar, org.spongepowered.asm.util.ClassSignature.TokenHandle handle)Add a type var to this signature, the type var must not existorg.objectweb.asm.signature.SignatureVisitorgetRemapper()Get a remapper for type vars in this signaturejava.lang.StringgetSuperClass()Get the raw superclass type of this signature as a stringprotected org.spongepowered.asm.util.ClassSignature.TokenHandlegetType(java.lang.String varName)Get the token for the specified type var name, creating it if necessaryprotected org.spongepowered.asm.util.ClassSignature.TypeVargetTypeVar(java.lang.String varName)Get the type var for the specified var nameprotected java.lang.StringgetTypeVar(org.spongepowered.asm.util.ClassSignature.TokenHandle handle)Get the type var matching the supplied type token, or the raw token type if no mapping exists for the supplied token handlevoidmerge(ClassSignature other)Merges another class signature into this one.static ClassSignatureof(java.lang.String signature)Parse a generic class signature from the supplied stringstatic ClassSignatureof(org.objectweb.asm.tree.ClassNode classNode)Parse a generic class signature from the supplied class node, uses the declared signature if present, else falls back to generating a raw signature from the class itselfstatic ClassSignatureofLazy(org.objectweb.asm.tree.ClassNode classNode)Returns a lazy-evaluated signature object.protected voidsetSuperClass(org.spongepowered.asm.util.ClassSignature.Token superClass)Set the superclass for this signaturejava.lang.StringtoString()Converts this signature into a string representation compatible with the signature attribute of a Java classClassSignaturewake()Wake up this signature if it is lazy-loaded
-
-
-
Field Detail
-
OBJECT
protected static final java.lang.String OBJECT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getTypeVar
protected org.spongepowered.asm.util.ClassSignature.TypeVar getTypeVar(java.lang.String varName)
Get the type var for the specified var name- Parameters:
varName- type var to lookup- Returns:
- type var for the supplied type var name
-
getType
protected org.spongepowered.asm.util.ClassSignature.TokenHandle getType(java.lang.String varName)
Get the token for the specified type var name, creating it if necessary- Parameters:
varName- type var to lookup- Returns:
- type token for the supplied type var name
-
getTypeVar
protected java.lang.String getTypeVar(org.spongepowered.asm.util.ClassSignature.TokenHandle handle)
Get the type var matching the supplied type token, or the raw token type if no mapping exists for the supplied token handle- Parameters:
handle- type token handle to lookup- Returns:
- type var (with prefix and suffix) or raw type name
-
addTypeVar
protected void addTypeVar(org.spongepowered.asm.util.ClassSignature.TypeVar typeVar, org.spongepowered.asm.util.ClassSignature.TokenHandle handle) throws java.lang.IllegalArgumentExceptionAdd a type var to this signature, the type var must not exist- Parameters:
typeVar- type var to addhandle- type var's type token- Throws:
java.lang.IllegalArgumentException- if the specified type var already exists
-
setSuperClass
protected void setSuperClass(org.spongepowered.asm.util.ClassSignature.Token superClass)
Set the superclass for this signature- Parameters:
superClass- super class to set
-
getSuperClass
public java.lang.String getSuperClass()
Get the raw superclass type of this signature as a string- Returns:
- superclass type as a string
-
addInterface
protected void addInterface(org.spongepowered.asm.util.ClassSignature.Token iface)
Add an interface to this signature- Parameters:
iface- interface to add
-
addInterface
public void addInterface(java.lang.String iface)
Add a raw interface declaration to this signature- Parameters:
iface- interface name to add (bin format)
-
addRawInterface
protected void addRawInterface(java.lang.String iface)
Add a raw interface which was previously enqueued- Parameters:
iface- interface to add
-
merge
public void merge(ClassSignature other)
Merges another class signature into this one. The other signature is first conformed so that no formal type parameters overlap with formal type parameters defined on this signature. No attempt is made to combine formal type parameters, this method merely ensures that parameters do not overlap.- Parameters:
other- Class signature to merge into this one
-
getRemapper
public org.objectweb.asm.signature.SignatureVisitor getRemapper()
Get a remapper for type vars in this signature- Returns:
- signature visitor
-
toString
public java.lang.String toString()
Converts this signature into a string representation compatible with the signature attribute of a Java class- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
wake
public ClassSignature wake()
Wake up this signature if it is lazy-loaded
-
of
public static ClassSignature of(java.lang.String signature)
Parse a generic class signature from the supplied string- Parameters:
signature- signature string to parse- Returns:
- parsed signature object
-
of
public static ClassSignature of(org.objectweb.asm.tree.ClassNode classNode)
Parse a generic class signature from the supplied class node, uses the declared signature if present, else falls back to generating a raw signature from the class itself- Parameters:
classNode- class node to parse- Returns:
- parsed signature
-
ofLazy
public static ClassSignature ofLazy(org.objectweb.asm.tree.ClassNode classNode)
Returns a lazy-evaluated signature object. For classes with a signature present this saves having to do the parse until we actually need it. For classes with no signature we just go ahead and generate it from the supplied ClassNode while we have it- Parameters:
classNode- class node to parse- Returns:
- parsed signature or lazy-load handle
-
-