Class ClassSignature


  • public class ClassSignature
    extends java.lang.Object
    Represents an object-oriented view of a generic class signature. We use ASM's SignatureVisitor to 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.String OBJECT  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addInterface​(java.lang.String iface)
      Add a raw interface declaration to this signature
      protected void addInterface​(org.spongepowered.asm.util.ClassSignature.Token iface)
      Add an interface to this signature
      protected void addRawInterface​(java.lang.String iface)
      Add a raw interface which was previously enqueued
      protected void addTypeVar​(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 exist
      org.objectweb.asm.signature.SignatureVisitor getRemapper()
      Get a remapper for type vars in this signature
      java.lang.String getSuperClass()
      Get the raw superclass type of this signature as a string
      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
      protected org.spongepowered.asm.util.ClassSignature.TypeVar getTypeVar​(java.lang.String varName)
      Get the type var for the specified var name
      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
      void merge​(ClassSignature other)
      Merges another class signature into this one.
      static ClassSignature of​(java.lang.String signature)
      Parse a generic class signature from the supplied string
      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
      static ClassSignature ofLazy​(org.objectweb.asm.tree.ClassNode classNode)
      Returns a lazy-evaluated signature object.
      protected void setSuperClass​(org.spongepowered.asm.util.ClassSignature.Token superClass)
      Set the superclass for this signature
      java.lang.String toString()
      Converts this signature into a string representation compatible with the signature attribute of a Java class
      ClassSignature wake()
      Wake up this signature if it is lazy-loaded
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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.IllegalArgumentException
        Add a type var to this signature, the type var must not exist
        Parameters:
        typeVar - type var to add
        handle - 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:
        toString in class java.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