Interface CodeContext
- All Superinterfaces:
AutoCloseable, CodeLoader, CodeNode, CodeProvider, CodeWithContext
A
CodeContext is the main entry point of this API. It allows to retrieve and create instances of
CodePackage, CodeFile, and CodeType.- Since:
- 1.0.0
- Author:
- hohwille
-
Method Summary
Modifier and TypeMethodDescriptiongetBooleanType(boolean primitive) default CodeTypegetOrCreateType(String qualifiedName, boolean add) default StringgetQualifiedName(String simpleName, CodeFile file, boolean omitStandardPackages) default StringgetQualifiedName(String simpleName, CodeType owningType, boolean omitStandardPackages) getQualifiedNameForStandardType(String simpleName, boolean omitStandardPackages) Methods inherited from interface CodeLoader
getType, getType, getTypeMethods inherited from interface CodeProvider
close, getRequiredType, parseNameMethods inherited from interface CodeWithContext
getContext, getSource
-
Method Details
-
getLanguage
CodeLanguage getLanguage()- Returns:
- the
CodeLanguagefor the current programming language.
-
getParent
CodeContext getParent()- Specified by:
getParentin interfaceCodeNode- Returns:
- the parent of this
CodeNode. May only benullfor instances ofCodeContext.
-
getRootType
-
getUnboundedWildcard
CodeTypeWildcard getUnboundedWildcard()- Returns:
- the unbounded instance of
CodeTypeWildcard(that has nobound). This is typically represented by the type "?" (e.g. inList<?>).
-
getRootEnumerationType
CodeType getRootEnumerationType()- Returns:
- the root
enumerationtype (for Java it representsEnumfor TypeScriptany).
-
getVoidType
-
getBooleanType
-
getRootExceptionType
CodeType getRootExceptionType()- Returns:
- the top-level
exceptionCodeType. All sub-types are considered asexceptions. For Java this isThrowable.
-
getQualifiedName
default String getQualifiedName(String simpleName, CodeType owningType, boolean omitStandardPackages) - Parameters:
simpleName- thesimple nameof theCodeTypeto resolve.owningType- the owningCodeTypewhere thesimpleNameorigins from. It is used as context for the resolution.omitStandardPackages-trueto omit standard package(s) (forstandard types),falseotherwise (to enforcequalified namealso for standard types).- Returns:
- the resolved
qualified namecorresponding to the givensimpleName.
-
getQualifiedName
- Parameters:
simpleName- thesimple nameof theCodeTypeto resolve.file- the owningCodeFilewhere thesimpleNameorigins from. It is used as context for the resolution.omitStandardPackages-trueto omit standard package(s) (forstandard types),falseotherwise (to enforcequalified namealso for standard types).- Returns:
- the resolved
qualified namecorresponding to the givensimpleName.
-
getQualifiedNameForStandardType
- Parameters:
simpleName- thesimple nameof theCodeType.omitStandardPackages-trueto omit standard package(s) (forstandard types),falseotherwise (to enforcequalified namealso for standard types).- Returns:
- the corresponding
qualified nameornullif no standard type (import is required).
-
getFactory
CodeFactory getFactory()- Returns:
- the
CodeFactoryto create specificCodeItems.
-
getOrCreateType
- Parameters:
qualifiedName- thequalified nameof the requestedCodeType.add- -trueto also add newly created code elements (requires mutable access),falseotherwise.- Returns:
- the requested existing or newly created
CodeType. - See Also:
-
createChildContext
CodeContext createChildContext()
-