Package de.svws_nrw.transpiler
Klasse Transpiler
java.lang.Object
javax.annotation.processing.AbstractProcessor
de.svws_nrw.transpiler.Transpiler
- Alle implementierten Schnittstellen:
Processor
@SupportedSourceVersion(RELEASE_21)
@SupportedAnnotationTypes("*")
public final class Transpiler
extends AbstractProcessor
This class provides a transpiler for transpiling java source code
into another programming language that is supported by implementing
the
TranspilerLanguagePlugin
class. Therefore the
Java Compiler API (module java.compiler) and its abstract syntax tress
(AST, module jdk.compiler) are used.-
Feldübersicht
Von Klasse geerbte Felder javax.annotation.processing.AbstractProcessor
processingEnv
-
Konstruktorübersicht
KonstruktorBeschreibungTranspiler
(String classdir, File... sources) Creates a new transpiler object for transpiling the specified java sources -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
Add a language plugin to this transpiler for transpiling into a specific languageint
checkForSuperclass
(ExpressionType classType, ExpressionType superType) Checks whether the specified class type has the specified super type, either a class type or an interface typeint
checkForSuperclass
(TypeElement te, String superFullQualified) Checks whether the type element has the specified super type, either a class type or an interface typegetAccessModifier
(Tree node) Returns the access modifier associated with the tree node as a string.Returns all classes to be transpiled - nested and non nested classes.static List
<MethodTree> getAllMethods
(ClassTree node) Returns the list of all methods - including constructors - of the class tree node.getAnnotation
(String annotationType, Tree tree) Returns the annotation of the annotation list which has specified type.getAnnotationList
(String annotationType, Tree tree) Returns all annotation of the annotation list which has specified type.static Map
<String, ExpressionTree> getArguments
(AnnotationTree annotation) Returns for the specifiedAnnotationTree
a mapping of all variable names to their assignedExpressionTree
.static VariableTree
getAttribute
(ClassTree node, String name) Returns the attribute of the class tree node with the specified namestatic List
<VariableTree> getAttributes
(ClassTree node) Returns the list of attributes of the class tree nodestatic List
<VariableElement> getAttributes
(TypeElement typeElement) Returns the list of attributes of the TypeElement, e.g. a class.Returns the list of attributes of the class tree node as VariableElementReturns the list of attributes of the class tree nodeReturns the class or enum that is the ancestor of this tree node.getClassTree
(String qualifiedName) Gibt den zugehörigen ClassTree für den übergebenen Klassennamen zurück, sofern diese Klasse auch von Transpiler transpiliert wird.getComment
(Tree node) Retrieves the comment for the specified tree node or null if none exists.getCompilationUnit
(Tree node) Retrieves the compilation unit for the specified tree node.static List
<MethodTree> getConstructors
(ClassTree node) Returns the list of constructors of the class tree node.getDeclaration
(ExpressionTree node) Returns the variable declaration for the specified identifier or null if a variable declaration is not found.getDeclaration
(IdentifierTree node) Returns the variable declaration for the specified identifier or null if a variable declaration is not found.static List
<MethodTree> getDefaultMethods
(ClassTree node) Returns the list of default methods of the specified class tree node of kind INTERFACE.getElement
(Tree node) Retrieves the java compiler element for the tree node or null if none exists.Gets the type object associated with specified expression tree node.getFullClassName
(ClassTree node) Returns the full class name of the specified class tree, i.e. with the package and in case of a nested class with its parent class(es).Checks whether the java full qualified name is the name of a functional interface or not and returns the name of the abstract method name for the specified functional interface.getMethod
(ReturnTree node) Retrieves the method that belongs to the specified return tree.static List
<MethodTree> getMethods
(ClassTree node) Returns the list of methods - excluding constructors - of the class tree node.static List
<MethodTree> getMethods
(ClassTree node, String name) Returns the methods of the class tree node with the specified name.static List
<MethodTree> Returns the list of non default methods of the specified class tree node of kind INTERFACE.getPackageOf
(Element elem) Retrieves the PackageElement of the specified ElementReturns the parent tree object for the specified tree objectgetTranspilerUnit
(Tree node) Returns the transpiler unit for the specified tree node.getTranspilerUnit
(String packageName, String className) Returns whether a transpiler unit exists for the class represented by the specified package and class name.getTreePath
(Element element) Returns the tree path for the specified element or null if the element ist not foundgetTypeElement
(String name) Returns the type element for the specified canonical namegetTypeMirror
(Tree node) Return the type mirror for the specified tree nodeReturns the type utility class from the java compiler (seeTypes
).boolean
hasAbstractModifier
(Tree node) Returns whether the tree node has an abstract modifier or not.boolean
hasAllowNullAnnotation
(Tree node) Checks whether the tree node has a AllowNull annotation assigned.static boolean
hasAllowNullAnnotation
(List<? extends AnnotationTree> annotations, TranspilerUnit tu) Checks whether the annotation list contains a AllowNull annotation.static boolean
hasAllowNullAnnotation
(List<? extends AnnotationMirror> annotations) Checks whether the annotation list contains a AllowNull annotation.static boolean
Checks whether the element has a AllowNull annotation assigned.static boolean
Checks whether the type mirror has a AllowNull annotation assigned.boolean
hasDefaultModifier
(Tree node) Returns whether a default modifier is associated with the tree node.boolean
hasFinalModifier
(Tree node) Returns whether a final modifier is associated with the tree node.boolean
hasNotNullAnnotation
(Tree node) Checks whether the tree node has a Not Null annotation from the jakartax.validation package assigned.static boolean
hasNotNullAnnotation
(List<? extends AnnotationTree> annotations, TranspilerUnit tu) Checks whether the annotation list contains a Not Null annotation from the jakartax.validation package.static boolean
hasNotNullAnnotation
(List<? extends AnnotationMirror> annotations) Checks whether the annotation list contains a Not Null annotation from the jakartax.validation package.static boolean
hasNotNullAnnotation
(Element elem) Checks whether the element has a Not Null annotation from the jakartax.validation package assigned.static boolean
Checks whether the type mirror has a Not Null annotation from the jakartax.validation package assigned.boolean
hasStaticModifier
(Tree node) Returns whether a static modifier is associated with the tree node.boolean
Checks whether the class tree node has a TranspilerDTO annotation.static boolean
hasTranspilerDTOAnnotation
(List<? extends AnnotationTree> annotations, TranspilerUnit tu) Checks whether the annotation list contains a TranspilerDTO annotation.boolean
hasTranspilerUnit
(String packageName, String className) Returns whether a transpiler unit exists for the class represented by the specified package and class name.static boolean
hasTsObjectAnnotation
(List<? extends AnnotationTree> annotations, TranspilerUnit tu) Checks whether the annotation list contains a TsObject annotation.void
init
(ProcessingEnvironment processingEnv) boolean
Checks whether the specified identifier tree node is part of an annotation tree but not the type of an annotation.boolean
isAnnotationType
(String annotationType, AnnotationTree annotation) Returns whether the specified annotation has the specified typeboolean
isClassMember
(IdentifierTree node) Checks whether the identifier is a class member if not access with "this.".static boolean
Prüft, ob die Variable mit dem Schlüsselwort var für den Typ deklariert wurde oder nicht.boolean
Checks whether the specified class tree node is a nested class or not.boolean
Checks whether the specified identifier tree node is part of an annotation.boolean
Checks whether the identifier is a static class member if not accessed by a member select with its class name.void
Prints the paths of all Java input files on the command line.boolean
process
(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) void
Starts the compilation process for all Java sources passed to the transpiler and aggregates information about the Java sources for the transpiling process.Von Klasse geerbte Methoden javax.annotation.processing.AbstractProcessor
getCompletions, getSupportedAnnotationTypes, getSupportedOptions, getSupportedSourceVersion, isInitialized
-
Konstruktordetails
-
Transpiler
Creates a new transpiler object for transpiling the specified java sources- Parameter:
classdir
- the directory where to place the compiler class output filessources
- theFile
-Objects for all Java-Sources
-
-
Methodendetails
-
printSourceFiles
public void printSourceFiles()Prints the paths of all Java input files on the command line. -
transpile
public void transpile()Starts the compilation process for all Java sources passed to the transpiler and aggregates information about the Java sources for the transpiling process. -
addLanguagePlugin
Add a language plugin to this transpiler for transpiling into a specific language- Parameter:
plugin
- the language plugin for the transpiler
-
getTypeUtils
Returns the type utility class from the java compiler (seeTypes
).- Gibt zurück:
- the type utility class
-
getAllClasses
Returns all classes to be transpiled - nested and non nested classes.- Gibt zurück:
- a list containing all classes to be transpiled
-
getTranspilerUnit
Returns the transpiler unit for the specified tree node.- Parameter:
node
- the tree node- Gibt zurück:
- the transpiler unit
-
getTreePath
Returns the tree path for the specified element or null if the element ist not found- Parameter:
element
- the element- Gibt zurück:
- the tree path or null
-
getParent
Returns the parent tree object for the specified tree object- Parameter:
node
- the tree object- Gibt zurück:
- the parent tree object
-
isNested
Checks whether the specified class tree node is a nested class or not.- Parameter:
node
- the class tree node- Gibt zurück:
- true if the class is nested and false otherwise
-
hasTranspilerUnit
Returns whether a transpiler unit exists for the class represented by the specified package and class name.- Parameter:
packageName
- the package nameclassName
- the class name- Gibt zurück:
- true if the class exists and false otherwise
-
getTranspilerUnit
Returns whether a transpiler unit exists for the class represented by the specified package and class name.- Parameter:
packageName
- the package nameclassName
- the class name- Gibt zurück:
- true if the class exists and false otherwise
-
getClassTree
Gibt den zugehörigen ClassTree für den übergebenen Klassennamen zurück, sofern diese Klasse auch von Transpiler transpiliert wird.- Parameter:
qualifiedName
- der voll qualifizirte Name der Klasse- Gibt zurück:
- das ClassTree-Objekt oder null
-
getFullClassName
Returns the full class name of the specified class tree, i.e. with the package and in case of a nested class with its parent class(es).- Parameter:
node
- the class tree node- Gibt zurück:
- the full class name
-
getAttributes
Returns the list of attributes of the TypeElement, e.g. a class.- Parameter:
typeElement
- the type element- Gibt zurück:
- the list of attributes of the type element
-
getAttributesFromClassTree
Returns the list of attributes of the class tree node as VariableElement- Parameter:
node
- the class tree node- Gibt zurück:
- the list of attributes of the class tree node as VariableElement
-
getAttributes
Returns the list of attributes of the class tree node- Parameter:
node
- the class tree node- Gibt zurück:
- the list of attributes of the class tree node
-
getAttributesWithSuperclassAttributes
Returns the list of attributes of the class tree node- Parameter:
node
- the class tree node- Gibt zurück:
- the list of attributes of the class tree node
-
getAttribute
Returns the attribute of the class tree node with the specified name- Parameter:
node
- the class tree nodename
- the attributes name- Gibt zurück:
- the attribute of the class tree node
-
getConstructors
Returns the list of constructors of the class tree node.- Parameter:
node
- the class tree node- Gibt zurück:
- the list of methods of the class tree node
-
getMethods
Returns the list of methods - excluding constructors - of the class tree node.- Parameter:
node
- the class tree node- Gibt zurück:
- the list of methods of the class tree node
-
getDefaultMethods
Returns the list of default methods of the specified class tree node of kind INTERFACE.- Parameter:
node
- the class tree node of kind INTERFACE- Gibt zurück:
- the list of default methods of the class tree node
-
getNonDefaultMethods
Returns the list of non default methods of the specified class tree node of kind INTERFACE.- Parameter:
node
- the class tree node of kind INTERFACE- Gibt zurück:
- the list of non-default methods of the class tree node
-
getAllMethods
Returns the list of all methods - including constructors - of the class tree node.- Parameter:
node
- the class tree node- Gibt zurück:
- the list of methods of the class tree node
-
getMethods
Returns the methods of the class tree node with the specified name.- Parameter:
node
- the class tree nodename
- the method name- Gibt zurück:
- the list of methods of the class tree node with the specified name
-
isClassMember
Checks whether the identifier is a class member if not access with "this.".- Parameter:
node
- the identifier node to be checked- Gibt zurück:
- true if the identifier is a class member in this scope and false otherwise
-
isStaticClassMember
Checks whether the identifier is a static class member if not accessed by a member select with its class name.- Parameter:
node
- the identifier node to be checked- Gibt zurück:
- true if the identifier is a static class member in this scope and false otherwise
-
getDeclaration
Returns the variable declaration for the specified identifier or null if a variable declaration is not found.- Parameter:
node
- the identifier- Gibt zurück:
- the variable declaration or null
-
getDeclaration
Returns the variable declaration for the specified identifier or null if a variable declaration is not found.- Parameter:
node
- the expression to be evaluated- Gibt zurück:
- the variable declaration or null
-
getClass
Returns the class or enum that is the ancestor of this tree node. This may be an inner class.- Parameter:
node
- the tree node- Gibt zurück:
- the parent class tree node
-
hasTsObjectAnnotation
public static boolean hasTsObjectAnnotation(List<? extends AnnotationTree> annotations, TranspilerUnit tu) Checks whether the annotation list contains a TsObject annotation.- Parameter:
annotations
- the list of annotation nodestu
- the transpiler unit- Gibt zurück:
- true if the list contains a TsObject annotation
-
hasAllowNullAnnotation
public static boolean hasAllowNullAnnotation(List<? extends AnnotationTree> annotations, TranspilerUnit tu) Checks whether the annotation list contains a AllowNull annotation.- Parameter:
annotations
- the list of annotation nodestu
- the transpiler unit- Gibt zurück:
- true if the list contains a AllowNull annotation
-
hasAllowNullAnnotation
Checks whether the annotation list contains a AllowNull annotation.- Parameter:
annotations
- the list of annotation nodes- Gibt zurück:
- true if the list contains a AllowNull annotation
-
hasAllowNullAnnotation
Checks whether the type mirror has a AllowNull annotation assigned.- Parameter:
type
- the type mirror- Gibt zurück:
- true if is has a AllowNull annotation assigned
-
hasAllowNullAnnotation
Checks whether the element has a AllowNull annotation assigned.- Parameter:
elem
- the element- Gibt zurück:
- true if is has a AllowNull annotation assigned
-
hasAllowNullAnnotation
Checks whether the tree node has a AllowNull annotation assigned.- Parameter:
node
- the tree node- Gibt zurück:
- true if is has a AllowNull annotation assigned
-
hasNotNullAnnotation
public static boolean hasNotNullAnnotation(List<? extends AnnotationTree> annotations, TranspilerUnit tu) Checks whether the annotation list contains a Not Null annotation from the jakartax.validation package.- Parameter:
annotations
- the list of annotation nodestu
- the transpiler unit- Gibt zurück:
- true if the list contains a not null annotation
-
hasNotNullAnnotation
Checks whether the annotation list contains a Not Null annotation from the jakartax.validation package.- Parameter:
annotations
- the list of annotation nodes- Gibt zurück:
- true if the list contains a not null annotation
-
hasNotNullAnnotation
Checks whether the type mirror has a Not Null annotation from the jakartax.validation package assigned.- Parameter:
type
- the type mirror- Gibt zurück:
- true if is has a not null annotation assigned
-
hasNotNullAnnotation
Checks whether the element has a Not Null annotation from the jakartax.validation package assigned.- Parameter:
elem
- the element- Gibt zurück:
- true if is has a not null annotation assigned
-
hasNotNullAnnotation
Checks whether the tree node has a Not Null annotation from the jakartax.validation package assigned.- Parameter:
node
- the tree node- Gibt zurück:
- true if is has a not null annotation assigned
-
isDeclaredUsingVar
Prüft, ob die Variable mit dem Schlüsselwort var für den Typ deklariert wurde oder nicht.- Parameter:
node
- die Variablendeklaration- Gibt zurück:
- true, falls das Schlüsselwort var verwendet wurde.
-
hasTranspilerDTOAnnotation
public static boolean hasTranspilerDTOAnnotation(List<? extends AnnotationTree> annotations, TranspilerUnit tu) Checks whether the annotation list contains a TranspilerDTO annotation.- Parameter:
annotations
- the list of annotation nodestu
- the transpiler unit- Gibt zurück:
- true if the list contains a TranspilerDTO annotation
-
hasTranspilerDTOAnnotation
Checks whether the class tree node has a TranspilerDTO annotation.- Parameter:
node
- the class tree node- Gibt zurück:
- true if the class has a TranspilerDTO annotation
-
getAnnotation
Returns the annotation of the annotation list which has specified type.- Parameter:
annotationType
- the name of the annotation type (e.g. )tree
- the class or method where to check for the annotation- Gibt zurück:
- the annotation if an annotation of the specified type exists
-
isAnnotationType
Returns whether the specified annotation has the specified type- Parameter:
annotationType
- the annotation types fully qualified nameannotation
- the annotation to be checked- Gibt zurück:
- true if the annotation has the specified type
-
getAnnotationList
Returns all annotation of the annotation list which has specified type.- Parameter:
annotationType
- the name of the annotation type (e.g. )tree
- the class or method where to check for the annotation- Gibt zurück:
- the list of all annotations of the specified type
-
getArguments
Returns for the specifiedAnnotationTree
a mapping of all variable names to their assignedExpressionTree
.- Parameter:
annotation
- the annotation tree- Gibt zurück:
- the mapping
-
getFunctionInterfaceMethodName
Checks whether the java full qualified name is the name of a functional interface or not and returns the name of the abstract method name for the specified functional interface.- Parameter:
name
- the full qualified name of the interface- Gibt zurück:
- the method name or null if name is not the name of a functional interface
-
isAnnotationArgument
Checks whether the specified identifier tree node is part of an annotation tree but not the type of an annotation.- Parameter:
node
- the identifier tree node- Gibt zurück:
- true, if the specified identifier tree node is part of an annotation tree, and false otherwise
-
isParentAnnotationType
Checks whether the specified identifier tree node is part of an annotation.- Parameter:
node
- the identifier tree node- Gibt zurück:
- true, if the specified identifier tree node is part of an annotation, and false otherwise
-
getExpressionType
Gets the type object associated with specified expression tree node.- Parameter:
node
- the expression tree node- Gibt zurück:
- the type object
-
getAccessModifier
Returns the access modifier associated with the tree node as a string. If there is none an empty string is returned.- Parameter:
node
- the tree node- Gibt zurück:
- the access modifier string or an empty string.
-
getMethod
Retrieves the method that belongs to the specified return tree.- Parameter:
node
- the return tree node- Gibt zurück:
- the tree of the method or the lambda.
-
hasAbstractModifier
Returns whether the tree node has an abstract modifier or not.- Parameter:
node
- the tree node- Gibt zurück:
- true if the tree node has an abstract modifier and false otherwise
-
hasFinalModifier
Returns whether a final modifier is associated with the tree node.- Parameter:
node
- the tree node- Gibt zurück:
- true if the tree node has a final modifier and false otherwise
-
hasStaticModifier
Returns whether a static modifier is associated with the tree node.- Parameter:
node
- the tree node- Gibt zurück:
- true if the tree node has a static modifier and false otherwise
-
hasDefaultModifier
Returns whether a default modifier is associated with the tree node.- Parameter:
node
- the tree node- Gibt zurück:
- true if the tree node has a default modifier and false otherwise
-
getElement
Retrieves the java compiler element for the tree node or null if none exists.- Parameter:
node
- the tree node- Gibt zurück:
- the java compiler element
-
getPackageOf
Retrieves the PackageElement of the specified Element- Parameter:
elem
- the element- Gibt zurück:
- the package element
-
getTypeMirror
Return the type mirror for the specified tree node- Parameter:
node
- the tree node- Gibt zurück:
- the type mirror
-
getTypeElement
Returns the type element for the specified canonical name- Parameter:
name
- the canonical name- Gibt zurück:
- the type element
-
checkForSuperclass
Checks whether the specified class type has the specified super type, either a class type or an interface type- Parameter:
classType
- the class typesuperType
- the super type- Gibt zurück:
- -1 on error or a positive value signaling the depth in the super class / interface tree
-
checkForSuperclass
Checks whether the type element has the specified super type, either a class type or an interface type- Parameter:
te
- the type elementsuperFullQualified
- the full qualified name of the super type- Gibt zurück:
- -1 on error or a positive value signaling the depth in the super class / interface tree
-
getComment
Retrieves the comment for the specified tree node or null if none exists.- Parameter:
node
- the tree node- Gibt zurück:
- the comment or null
-
getCompilationUnit
Retrieves the compilation unit for the specified tree node.- Parameter:
node
- the tree node- Gibt zurück:
- the compilation units tree node
-
init
- Angegeben von:
init
in SchnittstelleProcessor
- Setzt außer Kraft:
init
in KlasseAbstractProcessor
-
process
- Angegeben von:
process
in SchnittstelleProcessor
- Angegeben von:
process
in KlasseAbstractProcessor
-