Class KotlinNodeTypeData

java.lang.Object
net.sourceforge.pmd.lang.kotlin.types.KotlinNodeTypeData

@Experimental public final class KotlinNodeTypeData extends Object
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 Details

    • getTypeName

      public static @Nullable String getTypeName(KotlinNode node)
      Returns the resolved type name stored on this node, or null when 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

      public static @Nullable String getReturnTypeName(KotlinNode node)
      Returns the resolved return type name for a function declaration node, or null when type analysis has not been run.
    • getAnnotationFqNames

      public static List<String> getAnnotationFqNames(KotlinNode node)
      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

      public static boolean isTypeInfoAvailable(KotlinParser.KtKotlinFile rootNode)
      Returns true when the kotlin-type-mapper pre-analysis ran successfully for the file represented by this root node, false otherwise.
    • getAnalysisContext

      public static net.sourceforge.pmd.lang.kotlin.rule.internal.KotlinTypeAnalysisContext getAnalysisContext(KotlinParser.KtKotlinFile rootNode)
      Returns the KotlinTypeAnalysisContext stored on this root node, or KotlinTypeAnalysisContext.empty() when not set. XPath functions use this to retrieve per-run type data from the context node's root.