All files / parser/nodes expressionStatement.js

75% Statements 3/4
100% Branches 0/0
66.67% Functions 2/3
75% Lines 3/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                                                      327x     327x                   19x    
import Node from './node';
 
/**
 * Wraps any expression
 * 
 * These include:
 *  - PropertyExpression
 *  - BinaryExpression
 *  - UnaryExpression
 * 
 * Or even primitive nodes:
 *  - Identifier
 *  - Literal
 * 
 * This can be used as a delegate to determine which and how to interpret a
 * given expression. This should be ignored in terms of tree matching
 * 
 */
export default class ExpressionStatement extends Node {
    
    /**
     * Creates a wrapper ExpressionStatement
     * 
     * @param {Expression} expression the expression to wrap
     * @param {Object} position a position from nearley
     */
    constructor (expression: any, position: Object) {
        super(position);
        
        /** @type {Expression} */
        this.expression = expression;
    }
    
    /** @override */
    get children() {
        return ['expression'];
    }
    
    /** @override */
    toString() {
        return this.expression.toString();
    }
}