StringLiteralNode.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { injectable, inject } from 'inversify';
  2. import { ServiceIdentifiers } from '../../container/ServiceIdentifiers';
  3. import { TStatement } from '../../types/node/TStatement';
  4. import { IOptions } from '../../interfaces/options/IOptions';
  5. import { initializable } from '../../decorators/Initializable';
  6. import { AbstractCustomNode } from '../AbstractCustomNode';
  7. import { Nodes } from '../../node/Nodes';
  8. @injectable()
  9. export class StringLiteralNode extends AbstractCustomNode {
  10. /**
  11. * @type {string}
  12. */
  13. @initializable()
  14. private literalValue: string;
  15. /**
  16. * @param options
  17. */
  18. constructor (
  19. @inject(ServiceIdentifiers.IOptions) options: IOptions
  20. ) {
  21. super(options);
  22. }
  23. /**
  24. * @param literalValue
  25. */
  26. public initialize (literalValue: string): void {
  27. this.literalValue = literalValue;
  28. }
  29. /**
  30. * @returns {TStatement[]}
  31. */
  32. protected getNodeStructure (): TStatement[] {
  33. const structure: TStatement = <any>Nodes.getLiteralNode(this.literalValue);
  34. return [structure];
  35. }
  36. }