All files / src/ast/reference type-reference.ts

100% Statements 20/20
100% Branches 5/5
100% Functions 5/5
100% Lines 20/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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  1x 1x 1x         1x 28x   28x 28x 28x 28x   28x 9x 9x   28x 16x 16x 16x   28x 1x 1x 28x  
import type { ExpressionState } from '../../expression-state.js';
import { TypedValue } from '../../typed-value.js';
import { SpelNodeImpl } from '../spel-node.js';
import { NodeType } from '../../language/node-type.js';
 
/**
 * Type reference node — parallels Spring TypeReference
 */
export class TypeReference extends SpelNodeImpl {
  private readonly typeName: string;
 
  constructor(startPos: number, endPos: number, typeName: string) {
    super(NodeType.TYPE_REFERENCE, startPos, endPos);
    this.typeName = typeName;
  }
 
  public getTypeName(): string {
    return this.typeName;
  }
 
  public getValueInternal(state: ExpressionState): TypedValue {
    const typeDesc = state.findType(this.typeName);
    return new TypedValue(typeDesc);
  }
 
  public toStringAST(): string {
    return `T(${this.typeName})`;
  }
}