import { ASTNode , IApplicableSchema , ISchemaCollector } from "./ast-node" ; export class SchemaCollector implements ISchemaCollector { schemas : IApplicableSchema [ ] = [ ] ; private focusOffset : number ; private exclude : ASTNode ; constructor ( focusOffset = - 1 , exclude = null ) { this . focusOffset = focusOffset ; this . exclude = exclude ; } add ( schema ) { this . schemas . push ( schema ) ; } merge ( other ) { this . schemas . push ( ... other . schemas ) ; } include ( node ) { return ( ( this . focusOffset === - 1 || node . contains ( this . focusOffset ) ) && node !== this . exclude ) ; } newSub ( ) { return new SchemaCollector ( - 1 , this . exclude ) ; } } export class NoOpSchemaCollector implements ISchemaCollector { get schemas ( ) { return [ ] ; } add ( ) { return ; } merge ( ) { return ; } include ( ) { return true ; } newSub ( ) { return this ; } }