TypeScriptLanguageFrontend

This language frontend adds experimental support for TypeScript. It is definitely not feature complete, but can be used to parse simple typescript snippets through the official typescript parser written in TypeScript / nodejs. It includes a simple nodejs script that invokes this parser in src/main/nodejs. It basically dumps the AST in a JSON structure on stdout and this input is parsed by this frontend.

Because TypeScript is a strict super-set of JavaScript, this frontend can also be used to parse JavaScript. However, this is not properly tested. Furthermore, the official TypeScript parser also has built-in support for React dialects TSX and JSX.

Constructors

Link copied to clipboard

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
override var ctx: TranslationContext
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val namespace: Name?
Link copied to clipboard
open override val scope: Scope?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
open fun cleanup()
Link copied to clipboard
Link copied to clipboard
open override fun codeOf(astNode: TypeScriptNode): String?
Link copied to clipboard
fun getRegionFromStartEnd(file: File, start: Int, end: Int): Region?
Link copied to clipboard
fun handleComments(file: File, translationUnit: TranslationUnitDeclaration)

Extracts comments from the file with a regular expression and calls a best effort approach function that matches them to the closes ast node in the cpg.

Link copied to clipboard
open override fun locationOf(astNode: TypeScriptNode): PhysicalLocation
Link copied to clipboard
open override fun parse(file: File): TranslationUnitDeclaration
Link copied to clipboard
Link copied to clipboard
open fun process(from: Any, to: Node)
Link copied to clipboard
Link copied to clipboard
open fun registerObjectListener(from: Any, biConsumer: BiConsumer<Any, Node>)
Link copied to clipboard
open fun registerPredicateListener(predicate: BiPredicate<Any, Node>, biConsumer: BiConsumer<Any, Node>)
Link copied to clipboard
open override fun setComment(node: Node, astNode: TypeScriptNode)
Link copied to clipboard
open override fun typeOf(type: TypeScriptNode): Type