Class KotlinNodeTypeData
java.lang.Object
net.sourceforge.pmd.lang.kotlin.types.KotlinNodeTypeData
Stores and retrieves type-mapper data on Kotlin AST nodes via
DataMap keys.
DataKeys are private to this class. The kotlin-type-mapper library
uses the set* methods (via InternalApiBridge) to populate
values during its pre-analysis pass; rule code uses the get* methods
to read them.
- Experimental Status:
- Provides the initial API to access type information on Kotlin AST nodes.
- Since:
- 7.27.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.sourceforge.pmd.lang.kotlin.rule.internal.KotlinTypeAnalysisContextgetAnalysisContext(KotlinParser.KtKotlinFile rootNode) Returns theKotlinTypeAnalysisContextstored on this root node, orKotlinTypeAnalysisContext.empty()when not set.Returns an unmodifiable list of fully-qualified annotation class names for a declaration node, or an empty list if none are present or type analysis has not been run.static @Nullable StringgetReturnTypeName(KotlinNode node) Returns the resolved return type name for a function declaration node, ornullwhen type analysis has not been run.static @Nullable StringgetTypeName(KotlinNode node) Returns the resolved type name stored on this node, ornullwhen type analysis has not been run or the node has no type.static booleanisTypeInfoAvailable(KotlinParser.KtKotlinFile rootNode) Returnstruewhen the kotlin-type-mapper pre-analysis ran successfully for the file represented by this root node,falseotherwise.
-
Method Details
-
getTypeName
Returns the resolved type name stored on this node, ornullwhen type analysis has not been run or the node has no type. Used on variable declarations, function parameters, annotation nodes, catch blocks, delegation specifiers, and for-loop variables. -
getReturnTypeName
Returns the resolved return type name for a function declaration node, ornullwhen type analysis has not been run. -
getAnnotationFqNames
Returns an unmodifiable list of fully-qualified annotation class names for a declaration node, or an empty list if none are present or type analysis has not been run. -
isTypeInfoAvailable
Returnstruewhen the kotlin-type-mapper pre-analysis ran successfully for the file represented by this root node,falseotherwise. -
getAnalysisContext
public static net.sourceforge.pmd.lang.kotlin.rule.internal.KotlinTypeAnalysisContext getAnalysisContext(KotlinParser.KtKotlinFile rootNode) Returns theKotlinTypeAnalysisContextstored on this root node, orKotlinTypeAnalysisContext.empty()when not set. XPath functions use this to retrieve per-run type data from the context node's root.
-