import { immutable } from '../../decorators';
import { ExpressionNode, LOGIC_TYPE } from '../LogicItem';

/**
 * 标识符
 * @TODO: 当前类目前主要用于生成文档
 */
export class Identifier extends ExpressionNode {
    /**
     * 逻辑节点类型
     */
    @immutable()
    public readonly type: LOGIC_TYPE = LOGIC_TYPE.Identifier;
    /**
     * 标识符名称
     */
    @immutable()
    public readonly name: string = undefined;
    /**
     * 标识符代码
     * @example ID_c7019c2dfcfb4efba65a5ae98b1c8d8b
     */
    @immutable()
    public readonly code: string = undefined;
    /**
     * 变量引用
     */
    @immutable()
    public readonly schemaRef: string = undefined;
    /**
     * 生成 JS 脚本
     */
    toScript() {
        return this.code || this.name;
    }
}
