UNPKG

ts-budgie

Version:

Converts TypeScript code to Budgie.

25 lines (19 loc) 919 B
import { CommandNames } from "budgie"; import * as ts from "typescript"; import { BudgieLine } from "../../../output/budgieLine"; import { Transformation } from "../../../output/transformation"; import { PropertyAccessChecker } from "./propertyAccessChecker"; export class ConsoleLogAccessChecker extends PropertyAccessChecker { public visit(node: ts.PropertyAccessExpression): Transformation[] | undefined { if ( node.parent === undefined || !ts.isCallExpression(node.parent) || node.expression.getText(this.sourceFile) !== "console" || node.name.getText(this.sourceFile) !== "log" ) { return undefined; } const args = this.router.recurseIntoValues(node.parent.arguments); return [Transformation.fromNode(node, this.sourceFile, [new BudgieLine(CommandNames.Print, ...args)])]; } }