Package org.codehaus.groovy.ast.tools
Class WideningCategories.LowestUpperBoundClassNode
java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.ClassNode
org.codehaus.groovy.ast.tools.WideningCategories.LowestUpperBoundClassNode
- All Implemented Interfaces:
GroovydocHolder<AnnotatedNode>,NodeMetaDataHandler
- Enclosing class:
- WideningCategories
This
ClassNode specialization is used when the lowest upper bound
of two types cannot be represented by an existing type. For example, if B
extends A, C extends A and both C and B implement a common interface not
implemented by A, then we use this class to represent the bound.
At compile time, some classes like AsmClassGenerator
need to know about a real class node, so we compute a "compile time" node
which will be used to return a name and a type class.
-
Field Summary
Fields inherited from class org.codehaus.groovy.ast.ClassNode
clazz, EMPTY_ARRAY, isPrimaryNode, lazyInitLock, SUPER, THISFields inherited from interface groovy.lang.groovydoc.GroovydocHolder
DOC_COMMENT -
Constructor Summary
ConstructorsConstructorDescriptionLowestUpperBoundClassNode(String name, ClassNode upper, ClassNode... interfaces) Builds a public final type namednamewhose superclass isupperand whose interfaces areinterfaces. -
Method Summary
Modifier and TypeMethodDescriptionViews this node as a generic type argument.Returns the internal name passed to the constructor.getName()Returns the fully-qualified name of this class after following any redirects.Returns a non-primary proxy that redirects toClassNode.redirect(), so generics or type annotations can be added without mutating the canonical class.getText()Returns a human-readable text representation of this AST node.Returns the concrete class this classnode relates to.toString(boolean x) Returns a string representation of this ClassNode with optional redirect information.Methods inherited from class org.codehaus.groovy.ast.ClassNode
addConstructor, addConstructor, addField, addField, addFieldFirst, addFieldFirst, addInterface, addMethod, addMethod, addMixin, addObjectInitializerStatements, addProperty, addProperty, addStaticInitializerStatements, addSyntheticMethod, addTransform, addTypeAnnotation, addTypeAnnotations, declaresAnyInterfaces, declaresInterface, equals, getAbstractMethods, getAllDeclaredMethods, getAllInterfaces, getAnnotations, getAnnotations, getCompileUnit, getComponentType, getDeclaredConstructor, getDeclaredConstructors, getDeclaredField, getDeclaredMethod, getDeclaredMethods, getDeclaredMethodsMap, getEnclosingMethod, getField, getFieldIndex, getFields, getGenericsTypes, getGetterMethod, getGetterMethod, getInnerClasses, getInterfaces, getMethod, getMethods, getMethods, getMixins, getModifiers, getModule, getNameWithoutPackage, getObjectInitializerStatements, getOuterClass, getOuterClasses, getOuterClassType, getOuterField, getPackage, getPackageName, getPermittedSubclasses, getPlainNodeReference, getProperties, getProperty, getRecordComponents, getSetterMethod, getSetterMethod, getSuperClass, getTransforms, getTypeAnnotations, getTypeAnnotations, getUnresolvedInterfaces, getUnresolvedInterfaces, getUnresolvedName, getUnresolvedSuperClass, getUnresolvedSuperClass, hasDeclaredMethod, hashCode, hasMethod, hasPackageName, hasPossibleMethod, hasPossibleStaticMethod, hasProperty, implementsAnyInterfaces, implementsInterface, isAbstract, isAnnotated, isAnnotationDefinition, isArray, isDerivedFrom, isDerivedFromGroovyObject, isEnum, isGenericsPlaceHolder, isInterface, isPrimaryClassNode, isRecord, isRedirectNode, isResolved, isScript, isScriptBody, isSealed, isStatic, isStaticClass, isSyntheticPublic, isUsingGenerics, makeArray, parametersEqual, positionStmtsAfterEnumInitStmts, redirect, removeConstructor, removeField, removeMethod, renameField, setAnnotated, setCompileUnit, setEnclosingMethod, setGenericsPlaceHolder, setGenericsTypes, setInterfaces, setMixins, setModifiers, setModule, setName, setOuterClassType, setPermittedSubclasses, setRecordComponents, setRedirect, setScript, setScriptBody, setStaticClass, setSuperClass, setSyntheticPublic, setUnresolvedSuperClass, setUsingGenerics, toString, tryFindPossibleMethod, visitContentsMethods inherited from class org.codehaus.groovy.ast.AnnotatedNode
addAnnotation, addAnnotation, addAnnotations, getDeclaringClass, getGroovydoc, getInstance, hasNoRealSourcePosition, isSynthetic, setDeclaringClass, setHasNoRealSourcePosition, setSyntheticMethods inherited from class org.codehaus.groovy.ast.ASTNode
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visitMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler
copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData
-
Constructor Details
-
LowestUpperBoundClassNode
Builds a public final type namednamewhose superclass isupperand whose interfaces areinterfaces. The interfaces are sorted by name. The printed form joins the upper type and the interfaces with&, omittingObject. WhenupperisObjectand at least one interface is present, the compile-time stand-in is the first interface after that sort; otherwise it isupper. Generics from the upper type and the interfaces are copied here when this node uses generics.- Parameters:
name- internal name of the synthetic boundupper- superclass of the boundinterfaces- interfaces of the bound
-
-
Method Details
-
getLubName
Returns the internal name passed to the constructor.- Returns:
- the unresolved name of this bound
-
getText
Description copied from class:ASTNodeReturns a human-readable text representation of this AST node. Used for debugging and error messages. Default implementation returns a message indicating the representation is not yet implemented for this node type. -
getName
Description copied from class:ClassNodeReturns the fully-qualified name of this class after following any redirects. If this ClassNode is a proxy for another ClassNode, the name of the target is returned. The name remains consistent across all compilation phases for the redirected type. -
getTypeClass
Description copied from class:ClassNodeReturns the concrete class this classnode relates to. However, this method is inherently unsafe as it may return null depending on the compile phase you are using. AST transformations should never use this method directly, but rather obtain a new class node usingClassNode.getPlainNodeReference().- Overrides:
getTypeClassin classClassNode- Returns:
- the class this classnode relates to. May return null.
-
toString
Description copied from class:ClassNodeReturns a string representation of this ClassNode with optional redirect information. For array types, appends "[]" to the component type's string representation. For generic types, includes generic type parameters (e.g., "List"). If showRedirectistrueand this is a redirect node, includes arrow notation showing the redirect target; otherwise the redirect information is omitted. -
asGenericsType
Description copied from class:ClassNodeViews this node as a generic type argument. A node that is not a type-variable placeholder becomes a generics type with no bounds. A placeholder whose stored generics type already has upper bounds returns that same object. Otherwise a new generics type is built with this node as the type variable and the redirect, or this node when there is no redirect, as its upper bound. A generic declaration already stored on the placeholder is copied onto that new type.- Overrides:
asGenericsTypein classClassNode- Returns:
- a generics type representing this node
-
getPlainNodeReference
Description copied from class:ClassNodeReturns a non-primary proxy that redirects toClassNode.redirect(), so generics or type annotations can be added without mutating the canonical class. A primitive is returned asthis. UseClassNode.getPlainNodeReference(boolean)to force a proxy for a primitive.- Overrides:
getPlainNodeReferencein classClassNode- Returns:
- this node when it is a primitive, otherwise a new redirecting proxy
-