pmd-lang-test / net.sourceforge.pmd.lang.ast.test / BaseParsingHelper

BaseParsingHelper

abstract class BaseParsingHelper<Self : BaseParsingHelper<Self, T>, T : RootNode>

Language-independent base for a parser utils class. Implementations are language-specific.

Types

Params

data class Params

Constructors

<init>

Language-independent base for a parser utils class. Implementations are language-specific.

BaseParsingHelper(langName: String, rootClass: Class<T>, params: Params)

Properties

defaultHandler

val defaultHandler: LanguageVersionHandler

defaultVersion

val defaultVersion: LanguageVersion

langName

val langName: String

params

val params: Params

Functions

clone

abstract fun clone(params: Params): Self

getHandler

fun getHandler(version: String): LanguageVersionHandler

getNodes

fun <R : Node> getNodes(target: Class<R>, source: String, version: String? = null): List<R>

getVersion

Returns the language version with the given version string. If null, this defaults to the default language version for this instance (not necessarily the default language version defined by the language module).

fun getVersion(version: String?): LanguageVersion

parse

Parses the sourceCode with the given version. This may execute additional processing passes if this instance is configured to do so.

open fun parse(sourceCode: String, version: String? = null): T

parseClass

Fetches the source of the given clazz.

open fun parseClass(clazz: Class<*>, version: String? = null): T

parseResource

Fetches and parses the resource using the context defined for this instance (by default uses this class' classloader, but can be configured with withResourceContext).

open fun parseResource(resource: String, version: String? = null): T

readResource

fun readResource(resourceName: String): String

withDefaultVersion

Returns an instance of Self for which all parsing methods default their language version to the provided version If the version is null, then the default language version defined by the language module is used instead.

fun withDefaultVersion(version: String?): Self

withParserOptions

Returns an instance of Self for which the parse methods use the provided parserOptions.

fun withParserOptions(parserOptions: ParserOptions?): Self

withResourceContext

Returns an instance of Self for which parseResource uses the provided contextClass and resourcePrefix to load resources.

fun withResourceContext(contextClass: Class<*>, resourcePrefix: String = ""): Self