ExpressionNode.js 463 B

1234567891011121314151617181920212223242526272829303132
  1. import Node from './Node.js';
  2. class ExpressionNode extends Node {
  3. constructor( snipped = '', nodeType = 'void' ) {
  4. super( nodeType );
  5. this.snipped = snipped;
  6. }
  7. generate( builder, output ) {
  8. const type = this.getNodeType( builder );
  9. const snipped = this.snipped;
  10. if ( type === 'void' ) {
  11. builder.addFlowCode( snipped );
  12. } else {
  13. return builder.format( `( ${ snipped } )`, type, output );
  14. }
  15. }
  16. }
  17. export default ExpressionNode;