-
public abstract class BaseParsingHelper<Self extends BaseParsingHelper<Self, T>, T extends RootNode>
Language-independent base for a parser utils class. Implementations are language-specific.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final class
BaseParsingHelper.Params
-
Field Summary
Fields Modifier and Type Field Description private final LanguageVersion
defaultVersion
private final LanguageVersionHandler
defaultHandler
-
Constructor Summary
Constructors Constructor Description BaseParsingHelper(String langName, Class<T> rootClass, BaseParsingHelper.Params params)
-
Method Summary
Modifier and Type Method Description final LanguageVersion
getVersion(String version)
Returns the language version with the given version string. final Self
withDefaultVersion(String version)
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. final Self
withResourceContext(Class<?> contextClass, String resourcePrefix)
Returns an instance of Self for which parseResource uses the provided contextClass and resourcePrefix to load resources. final Self
withParserOptions(ParserOptions parserOptions)
Returns an instance of Self for which the parse methods use the provided parserOptions. final LanguageVersionHandler
getHandler(String version)
final <R extends Node> List<R>
getNodes(Class<R> target, String source, String version)
T
parse(String sourceCode, String version)
Parses the sourceCode with the given version. T
parseResource(String resource, String version)
Fetches and parses the resource using the context defined for this instance (by default uses this class' classloader, but can be configured with withResourceContext). T
parseClass(Class<?> clazz, String version)
Fetches the source of the given clazz. final LanguageVersion
getDefaultVersion()
final LanguageVersionHandler
getDefaultHandler()
-
-
Constructor Detail
-
BaseParsingHelper
BaseParsingHelper(String langName, Class<T> rootClass, BaseParsingHelper.Params params)
-
-
Method Detail
-
getVersion
final LanguageVersion getVersion(String version)
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).
-
withDefaultVersion
final Self withDefaultVersion(String version)
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.
-
withResourceContext
@JvmOverloads() final Self withResourceContext(Class<?> contextClass, String resourcePrefix)
Returns an instance of Self for which parseResource uses the provided contextClass and resourcePrefix to load resources.
-
withParserOptions
final Self withParserOptions(ParserOptions parserOptions)
-
getHandler
final LanguageVersionHandler getHandler(String version)
-
getNodes
@JvmOverloads() final <R extends Node> List<R> getNodes(Class<R> target, String source, String version)
-
parse
@JvmOverloads() T parse(String sourceCode, String version)
Parses the sourceCode with the given version. This may execute additional processing passes if this instance is configured to do so.
-
parseResource
@JvmOverloads() T parseResource(String resource, String version)
Fetches and parses the resource using the context defined for this instance (by default uses this class' classloader, but can be configured with withResourceContext).
-
parseClass
@JvmOverloads() T parseClass(Class<?> clazz, String version)
Fetches the source of the given clazz.
-
getDefaultVersion
final LanguageVersion getDefaultVersion()
-
getDefaultHandler
final LanguageVersionHandler getDefaultHandler()
-
-
-
-