Klasse TranspilerTypeScriptPlugin
java.lang.Object
de.svws_nrw.transpiler.TranspilerLanguagePlugin
de.svws_nrw.transpiler.typescript.TranspilerTypeScriptPlugin
This is the transpiler language plugin for Type Script.
-
Feldübersicht
Modifizierer und TypFeldBeschreibungint
the indentation state used during transpilationEin Set mit allen im Transpiler umbenannten interfacesVon Klasse geerbte Felder de.svws_nrw.transpiler.TranspilerLanguagePlugin
outputFiles, outputFilesTypeOnly, transpiler
-
Konstruktorübersicht
KonstruktorBeschreibungTranspilerTypeScriptPlugin
(Transpiler transpiler, String outputDir, boolean includeTSJavaCore) Create a Type Script transpiler language plugin -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
appendCast
(StringBuilder sb, ClassTree node) Appends a function to cast an object to the class type.Appends the attribute class specifying the objects class for simulating part of Javas refelction API.Appends a method to the transpiled class code for simulating the Java instanceof operator.Appends a method that returns the classes canonical name for simulating part of Javas refelction API.Appends a method for creating a TS object from JSON to the transpiled class code.Appends a method for creating JSON from the TS object to the transpiled classAppends a method for creating a JSON Patch from the TS object to the transpiled classTranspiles the array access expression.Transpiles the simple assignment.convertAttribute
(VariableTree node, String enumName) Transpiles the attribute of a class.Transpiles the binary operation.convertBlock
(BlockTree node, boolean ignoreFirst, String yieldVar) Transpiles the statement block.Transpiles the variable declared in a statement block.static String
convertBreak
(BreakTree node) Transpiles the break statement.convertCatch
(CatchTree node) Transpiles the catch clause.Transpiles the compound assignment.Transpiles the conditional expression.static String
convertContinue
(ContinueTree node) Transpiles the continue statement.convertDefaultMethodParameters
(ExecutableElement method, Map<String, TypeMirror> resolved) Konvertiert die Parameter des übergebenen Methode nach TypescriptTranspiles the do while loop.Transpiles the for each loop.Transpiles the expression.Transpiles the expression statement.convertForLoop
(ForLoopTree node) Transpiles the for loop.Transpiles the identifier.Transpiles the if statement.Transpiles the instance of expression.Transpiles the lambda expression.static String
convertLiteral
(LiteralTree node) Transpiles the literal.Transpiles the member select statement.Transpiles the method invocation expression.convertMethodInvocationParameters
(List<? extends ExpressionTree> expressions, String enumValueName, Integer enumOrdinal, boolean noParentheses) Transpiles the list of method invocation parameters.convertNewArray
(NewArrayTree node) Transpiles the new array expression node.convertNewClass
(NewClassTree node) Transpiles the new class expression.Transpiles the parenthesized node.convertReturn
(ReturnTree node) Transpiles the return statement.convertStatement
(StatementTree node, boolean noIndent) Transpiles the statement.convertSwitch
(SwitchTree node, boolean noIndent) Transpiles the switch statement.convertSwitchExpression
(SwitchExpressionTree node, String switchVarName) Transpiles the switch expression.convertThrow
(ThrowTree node) Transpiles the throw expression.convertTry
(TryTree node) Transpiles the try statement.convertTypeCast
(TypeCastTree node) Transpiles the type cast expression.convertTypeParameter
(TypeParameterTree node, boolean withBounds) Transpiles the type parameter node.convertTypeParameters
(List<? extends TypeParameterTree> nodes, boolean withBounds) Transpiles the type parameters nodes.Transpiles the unary operation.Transpiles the while loop.convertYield
(YieldTree node, String yieldVar) Transpiles the yield statement.getCastFunctionName
(ClassTree node) Determines the cast function name for the specified class tree nodestatic String
Returns the default value for primitive types.static String
getDefaultValueForType
(Tree node) Returns the default value for the specified type node.static String
getImportName
(String className, String packageName) Bestimmt anhand der Namen der Klasse und des Packages den Klassennamen für das Schreiben des transpilierten Codes.static String
getImportPackageName
(String className, String packageName) Bestimmt anhand der Namen der Klasse und des Packages den Packagenamen für das Schreiben des transpilierten Codes.getImports
(TranspilerUnit unit, String strIgnoreJavaPackagePrefix, String body) Prints the import information of the transpiler unitReturns the current indentation string used during transpilationstatic void
pruefeBezeichner
(String bezeichner) Prüft, ob der übergebene Bezeichner ein Schlüsselwort in Type-Script ist, welches nicht auch in Java ein Schlüsselwortd er Sprache ist.void
setIgnoreJavaPackagePrefix
(String prefix) Sets the configuration parameter for the prefix part of the java packages to be ignored while creating the sub directories for the Type Script output.void
This method is invoked by the transpiler to start the transpiling process for this language plugin.void
transpileClass
(StringBuilder sb, ClassTree node) Transpiles the class.void
transpileClassMethods
(StringBuilder sb, ClassTree node, List<MethodTree> methodNodes) Transpiles the class methods.void
Erzeugt den Code für die Verwendung von Default-Methoden innerhalb der Klassevoid
transpileEnum
(StringBuilder sb, ClassTree node) Transpiles the enumeration.void
transpileInterface
(StringBuilder sb, ClassTree node) Transpiles the interface.Von Klasse geerbte Methoden de.svws_nrw.transpiler.TranspilerLanguagePlugin
getOutputFiles, getOutputFilesTypeOnly, getTranspiler
-
Felddetails
-
indentC
public int indentCthe indentation state used during transpilation -
renamedInterfaces
Ein Set mit allen im Transpiler umbenannten interfaces
-
-
Konstruktordetails
-
TranspilerTypeScriptPlugin
public TranspilerTypeScriptPlugin(Transpiler transpiler, String outputDir, boolean includeTSJavaCore) Create a Type Script transpiler language plugin- Parameter:
transpiler
- the transpiler that uses this pluginoutputDir
- the output directory where all generated files should be placedincludeTSJavaCore
- gibt an, ob auch der Typescript-Code für die grundlegenden Java-Bibliotheken mit eingebunden werden sollen
-
-
Methodendetails
-
setIgnoreJavaPackagePrefix
Sets the configuration parameter for the prefix part of the java packages to be ignored while creating the sub directories for the Type Script output.- Parameter:
prefix
- the prefix part of the java package to be ignored
-
getIndent
Returns the current indentation string used during transpilation- Gibt zurück:
- the current indentation string
-
pruefeBezeichner
Prüft, ob der übergebene Bezeichner ein Schlüsselwort in Type-Script ist, welches nicht auch in Java ein Schlüsselwortd er Sprache ist.- Parameter:
bezeichner
- der zu prüfende Bezeichner
-
convertTypeParameter
Transpiles the type parameter node.- Parameter:
node
- the type parameter node to be transpiledwithBounds
- specifies whether the bounds of the type parametes should be transpiled or not- Gibt zurück:
- the type parameter string
-
convertTypeParameters
Transpiles the type parameters nodes.- Parameter:
nodes
- the type parameter nodes to be transpiledwithBounds
- specifies whether the bounds of the type parametes should be transpiled or not- Gibt zurück:
- the type parameters string
-
convertBlockVariable
Transpiles the variable declared in a statement block.- Parameter:
node
- the variable declaration- Gibt zurück:
- the transpiled statement block
-
convertEnhancedForLoop
Transpiles the for each loop.- Parameter:
node
- the enhanced for loop statement- Gibt zurück:
- the transpiled for each loop
-
convertForLoop
Transpiles the for loop.- Parameter:
node
- the for loop statement- Gibt zurück:
- the transpiled for loop
-
convertWhileLoop
Transpiles the while loop.- Parameter:
node
- the while loop statement- Gibt zurück:
- the transpiled while loop
-
convertDoWhileLoop
Transpiles the do while loop.- Parameter:
node
- the do while loop statement- Gibt zurück:
- the transpiled do while loop
-
convertIdentifier
Transpiles the identifier.- Parameter:
node
- the identifier- Gibt zurück:
- the transpiled identifier
-
convertMemberSelect
Transpiles the member select statement.- Parameter:
node
- the member select statement- Gibt zurück:
- the transpiled member select statement
-
convertParenthesized
Transpiles the parenthesized node.- Parameter:
node
- the parenthesized node- Gibt zurück:
- the transpiled parenthesized statement
-
convertBinaryOperator
Transpiles the binary operation.- Parameter:
node
- the binary operation node- Gibt zurück:
- the transpiled binary operation
-
convertUnaryOperator
Transpiles the unary operation.- Parameter:
node
- the unary operation node- Gibt zurück:
- the transpiled unary operation
-
convertCompoundAssignment
Transpiles the compound assignment.- Parameter:
node
- the compound assignment- Gibt zurück:
- the transpiled compound assignment
-
convertArrayAccess
Transpiles the array access expression.- Parameter:
node
- the array access expression- Gibt zurück:
- the transpiled array access expression
-
convertTypeCast
Transpiles the type cast expression.- Parameter:
node
- the type cast expression tree node- Gibt zurück:
- the transpiled type cast expression
-
convertInstanceOf
Transpiles the instance of expression.- Parameter:
node
- the instance of expression tree node- Gibt zurück:
- the transpiled instance of expression
-
convertLambdaExpression
Transpiles the lambda expression.- Parameter:
node
- the lambda expression tree node- Gibt zurück:
- the transpiled lambda expression
-
convertSwitchExpression
Transpiles the switch expression.- Parameter:
node
- the switch expression tree nodeswitchVarName
- der Variablenname, welcher im switch verwendet werden soll- Gibt zurück:
- the transpiled switch expression
-
convertExpression
Transpiles the expression.- Parameter:
node
- the expression- Gibt zurück:
- the transpiled string if the expression was transpiled successfully and null otherwise
-
convertConditionalExpression
Transpiles the conditional expression.- Parameter:
node
- the conditional expression- Gibt zurück:
- the transpiled conditional expression
-
convertLiteral
Transpiles the literal.- Parameter:
node
- the literal- Gibt zurück:
- the transpiled literal
-
getDefaultValueForPrimitiveType
Returns the default value for primitive types.- Parameter:
node
- the primitive type tree node- Gibt zurück:
- the default value as String
-
getDefaultValueForType
Returns the default value for the specified type node.- Parameter:
node
- the type tree node- Gibt zurück:
- the default value as String
-
convertNewArray
Transpiles the new array expression node.- Parameter:
node
- the new array expression to be transpiled- Gibt zurück:
- the transpiled new array expression
-
convertAssignment
Transpiles the simple assignment.- Parameter:
node
- the assignment- Gibt zurück:
- the transpiled simple assignment
-
convertExpressionStatement
Transpiles the expression statement.- Parameter:
node
- the expression statement- Gibt zurück:
- the transpiled expression if the statement was transpiled successfully and null otherwise
-
convertThrow
Transpiles the throw expression.- Parameter:
node
- the expression- Gibt zurück:
- the transpiled expression if the statement was transpiled successfully and null otherwise
-
convertStatement
Transpiles the statement.- Parameter:
node
- the statementnoIndent
- true if no indentation should be used- Gibt zurück:
- the transpiled statement
-
convertIf
Transpiles the if statement.- Parameter:
node
- the if statement- Gibt zurück:
- the transpiled if statement
-
convertSwitch
Transpiles the switch statement.- Parameter:
node
- the switch statementnoIndent
- true if no indentation should be used- Gibt zurück:
- the transpiled switch statement
-
convertReturn
Transpiles the return statement.- Parameter:
node
- the return statement- Gibt zurück:
- the transpiled return statement
-
convertYield
Transpiles the yield statement.- Parameter:
node
- the yield statementyieldVar
- the temporary variable for the switch-yield-expression- Gibt zurück:
- the transpiled yield statement
-
convertBreak
Transpiles the break statement.- Parameter:
node
- the break statement- Gibt zurück:
- the transpiled break statement
-
convertContinue
Transpiles the continue statement.- Parameter:
node
- the continue statement- Gibt zurück:
- the transpiled continue statement
-
convertCatch
Transpiles the catch clause.- Parameter:
node
- the catch clause- Gibt zurück:
- the transpiled catch clause
-
convertTry
Transpiles the try statement.- Parameter:
node
- the try statement- Gibt zurück:
- the transpiled try statement
-
convertBlock
Transpiles the statement block.- Parameter:
node
- the statement blockignoreFirst
- if set, the first statement is ignored (sometimes super constructor calls must be ignored)yieldVar
- the name of the temporary yield variable if yield is used- Gibt zurück:
- the transpiled block
-
convertMethodInvocationParameters
public String convertMethodInvocationParameters(List<? extends ExpressionTree> expressions, String enumValueName, Integer enumOrdinal, boolean noParentheses) Transpiles the list of method invocation parameters.- Parameter:
expressions
- the list of method invocation parametersenumValueName
- the name of the enum value as first method invocation parameter, if the method is the constructor of an enum valueenumOrdinal
- the ordinal as second method invocation parameter, if the method is the constructor of an enum valuenoParentheses
- defines whether the parameters should be surrounded by parentheses- Gibt zurück:
- the transpiled method invocation parameters
-
convertNewClass
Transpiles the new class expression.- Parameter:
node
- the new class expression- Gibt zurück:
- the transpiled new class expression
-
convertMethodInvocation
Transpiles the method invocation expression.- Parameter:
node
- the method invocation expression- Gibt zurück:
- the transpiled method invocation expression and null if the method invocation was skipped to prevent typescript errors
-
convertAttribute
Transpiles the attribute of a class.- Parameter:
node
- the attribute to be transpiledenumName
- specifies the name of the enum if the attribute belongs to an enum- Gibt zurück:
- the transpiled attribute
-
getCastFunctionName
Determines the cast function name for the specified class tree node- Parameter:
node
- the class tree node- Gibt zurück:
- the name of the cast function fpr the specified class tree object
-
appendCast
Appends a function to cast an object to the class type. The function is appended after the class definition.- Parameter:
sb
- the StringBuilder where the output is written tonode
- the class to be transpiled
-
appendTranspilerCanonicalName
Appends a method that returns the classes canonical name for simulating part of Javas refelction API.- Parameter:
node
- the class tree node- Gibt zurück:
- the transpilerCanonicalName method code as a String
-
appendClassAttribute
Appends the attribute class specifying the objects class for simulating part of Javas refelction API.- Parameter:
node
- the class tree node- Gibt zurück:
- the class attribute code as a string
-
appendIsTranspiledInstanceOf
Appends a method to the transpiled class code for simulating the Java instanceof operator. This is required to support instanceof checks on interfaces that are not available in typescript since the underlying javascript does not support interfaces.- Parameter:
node
- the class tree node- Gibt zurück:
- the isTranspiledInstanceOf method code as a String
-
appendTranspilerFromJSON
Appends a method for creating a TS object from JSON to the transpiled class code.- Parameter:
node
- the class tree node- Gibt zurück:
- the transpilerFromJSON method code as a String
-
appendTranspilerToJSON
Appends a method for creating JSON from the TS object to the transpiled class- Parameter:
node
- the class tree node- Gibt zurück:
- the transpilerToJSON method code as a String
-
appendTranspilerToJSONPatch
Appends a method for creating a JSON Patch from the TS object to the transpiled class- Parameter:
node
- the class tree node- Gibt zurück:
- the transpilerToJSON method code as a String
-
transpileClassMethods
Transpiles the class methods.- Parameter:
sb
- the StringBuilder where the output is written tonode
- the class to be transpiledmethodNodes
- the class methods to be transpiled
-
convertDefaultMethodParameters
public String convertDefaultMethodParameters(ExecutableElement method, Map<String, TypeMirror> resolved) Konvertiert die Parameter des übergebenen Methode nach Typescript- Parameter:
method
- die zu konvertierende Methoderesolved
- eine Map mit den Typen von aufgelösten Typ-Variablen- Gibt zurück:
- die Methoden-Parameter als String
-
transpileDefaultMethodImplementations
Erzeugt den Code für die Verwendung von Default-Methoden innerhalb der Klasse- Parameter:
sb
- the StringBuilder where the output is written tonode
- the class or enum to be transpiled
-
transpileClass
Transpiles the class.- Parameter:
sb
- the StringBuilder where the output is written tonode
- the class to be transpiled
-
transpileEnum
Transpiles the enumeration.- Parameter:
sb
- the StringBuilder where the output is written tonode
- the enumeration class to be transpiled
-
transpileInterface
Transpiles the interface.- Parameter:
sb
- the StringBuilder where the output is written tonode
- the class to be transpiled
-
getImportName
Bestimmt anhand der Namen der Klasse und des Packages den Klassennamen für das Schreiben des transpilierten Codes. Hierbei finden Umbenennungen statt, falls in Typescript identische Bezeichner vorkommen.- Parameter:
className
- der Name der Java-KlassepackageName
- der Name des Java-Packages- Gibt zurück:
- der Typescript-Klassenname
-
getImportPackageName
Bestimmt anhand der Namen der Klasse und des Packages den Packagenamen für das Schreiben des transpilierten Codes. Hierbei finden ggf. Umbenennungen statt.- Parameter:
className
- der Name der Java-KlassepackageName
- der Name des Java-Packages- Gibt zurück:
- der Typescript-Packagename
-
getImports
Prints the import information of the transpiler unit- Parameter:
unit
- the transpiler unit containing the import informationstrIgnoreJavaPackagePrefix
- the package prefix to be ignoredbody
- the file body of the transpiled class- Gibt zurück:
- the imports for the transpiled typescript class
-
transpile
public void transpile()Beschreibung aus Klasse kopiert:TranspilerLanguagePlugin
This method is invoked by the transpiler to start the transpiling process for this language plugin. It must be implemented by the language plugin.- Angegeben von:
transpile
in KlasseTranspilerLanguagePlugin
-