refactor(ivy): move type from LNode to TNode (#24113)

PR Close #24113
This commit is contained in:
Kara Erickson
2018-05-17 12:54:57 -07:00
committed by Matias Niemelä
parent 8216657681
commit 68bf8c36c6
7 changed files with 95 additions and 91 deletions

View File

@ -7,23 +7,23 @@
*/
import {assertEqual, assertNotNull} from './assert';
import {LNode, LNodeType} from './interfaces/node';
import {LNode, TNodeType} from './interfaces/node';
export function assertNodeType(node: LNode, type: LNodeType) {
export function assertNodeType(node: LNode, type: TNodeType) {
assertNotNull(node, 'should be called with a node');
assertEqual(node.type, type, `should be a ${typeName(type)}`);
assertEqual(node.tNode.type, type, `should be a ${typeName(type)}`);
}
export function assertNodeOfPossibleTypes(node: LNode, ...types: LNodeType[]) {
export function assertNodeOfPossibleTypes(node: LNode, ...types: TNodeType[]) {
assertNotNull(node, 'should be called with a node');
const found = types.some(type => node.type === type);
const found = types.some(type => node.tNode.type === type);
assertEqual(found, true, `Should be one of ${types.map(typeName).join(', ')}`);
}
function typeName(type: LNodeType): string {
if (type == LNodeType.Projection) return 'Projection';
if (type == LNodeType.Container) return 'Container';
if (type == LNodeType.View) return 'View';
if (type == LNodeType.Element) return 'Element';
function typeName(type: TNodeType): string {
if (type == TNodeType.Projection) return 'Projection';
if (type == TNodeType.Container) return 'Container';
if (type == TNodeType.View) return 'View';
if (type == TNodeType.Element) return 'Element';
return '<unknown>';
}