Class ReferenceSourceType
- java.lang.Object
-
- com.tonic.analysis.source.ast.type.ReferenceSourceType
-
- All Implemented Interfaces:
ASTNode,SourceType
public final class ReferenceSourceType extends Object implements SourceType
Represents a reference type (class or interface) in the source AST.
-
-
Field Summary
Fields Modifier and Type Field Description static ReferenceSourceTypeCLASSstatic ReferenceSourceTypeOBJECTstatic ReferenceSourceTypeSTRING
-
Constructor Summary
Constructors Constructor Description ReferenceSourceType(String internalName)Creates a raw reference type printed by its simple name.ReferenceSourceType(String internalName, List<SourceType> typeArguments)Creates a parameterized reference type printed by its simple name.ReferenceSourceType(String internalName, List<SourceType> typeArguments, boolean useSimpleName)Creates a reference type, choosing how the name is printed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(SourceVisitor<T> visitor)Accepts a visitor for this node.booleanequals(Object obj)StringgetFullyQualifiedName()Gets the fully qualified name in Java format (e.g., "java.lang.String", or "Outer.Inner" for a nested class).StringgetInternalName()StringgetPackageName()Gets the package name (e.g., "java.lang").StringgetSimpleName()Gets the simple class name (e.g., "String").List<SourceType>getTypeArguments()inthashCode()booleanhasTypeArguments()Checks if this type has generic type arguments.booleanisUseSimpleName()IRTypetoIRType()Converts this source type to the equivalent IR type.StringtoJavaSource()Converts this source type to Java source code representation.StringtoString()ReferenceSourceTypewithTypeArguments(List<SourceType> typeArgs)Creates a copy of this type carrying different type arguments.-
Methods inherited from interface com.tonic.analysis.source.ast.ASTNode
deepClone, findAll, findAll, findAncestor, findFirst, findFirst, getChildren, getRoot, isDescendantOf, remove, replaceWith, stream, stream, walk
-
Methods inherited from interface com.tonic.analysis.source.ast.type.SourceType
getLocation, getParent, isArray, isPrimitive, isReference, isVoid, setParent
-
-
-
-
Field Detail
-
OBJECT
public static final ReferenceSourceType OBJECT
-
STRING
public static final ReferenceSourceType STRING
-
CLASS
public static final ReferenceSourceType CLASS
-
-
Constructor Detail
-
ReferenceSourceType
public ReferenceSourceType(String internalName)
Creates a raw reference type printed by its simple name.- Parameters:
internalName- the class name in internal format- Throws:
NullPointerException- if internalName is null
-
ReferenceSourceType
public ReferenceSourceType(String internalName, List<SourceType> typeArguments)
Creates a parameterized reference type printed by its simple name.- Parameters:
internalName- the class name in internal formattypeArguments- the generic arguments, or null for none- Throws:
NullPointerException- if internalName is null
-
ReferenceSourceType
public ReferenceSourceType(String internalName, List<SourceType> typeArguments, boolean useSimpleName)
Creates a reference type, choosing how the name is printed.- Parameters:
internalName- the class name in internal formattypeArguments- the generic arguments, or null for noneuseSimpleName- true to print the simple name, false for the qualified one- Throws:
NullPointerException- if internalName is null
-
-
Method Detail
-
getInternalName
public String getInternalName()
- Returns:
- the internal name
-
getTypeArguments
public List<SourceType> getTypeArguments()
- Returns:
- the type arguments
-
isUseSimpleName
public boolean isUseSimpleName()
- Returns:
- whether use simple name
-
getFullyQualifiedName
public String getFullyQualifiedName()
Gets the fully qualified name in Java format (e.g., "java.lang.String", or "Outer.Inner" for a nested class).- Returns:
- the dotted source-form name
-
getSimpleName
public String getSimpleName()
Gets the simple class name (e.g., "String").- Returns:
- the name with the package stripped
-
getPackageName
public String getPackageName()
Gets the package name (e.g., "java.lang").- Returns:
- the dotted package name, empty for the default package
-
hasTypeArguments
public boolean hasTypeArguments()
Checks if this type has generic type arguments.- Returns:
- true when at least one type argument is present
-
withTypeArguments
public ReferenceSourceType withTypeArguments(List<SourceType> typeArgs)
Creates a copy of this type carrying different type arguments.- Parameters:
typeArgs- the type arguments for the copy- Returns:
- a new type with the same internal name and simple-name preference
-
toJavaSource
public String toJavaSource()
Description copied from interface:SourceTypeConverts this source type to Java source code representation.- Specified by:
toJavaSourcein interfaceSourceType- Returns:
- the Java source representation (e.g., "int", "String", "int[]")
-
toIRType
public IRType toIRType()
Description copied from interface:SourceTypeConverts this source type to the equivalent IR type.- Specified by:
toIRTypein interfaceSourceType- Returns:
- the corresponding IRType
-
accept
public <T> T accept(SourceVisitor<T> visitor)
Description copied from interface:ASTNodeAccepts a visitor for this node.
-
-