import { postcss } from "opticss" ; import { IMPLEMENTS } from "../../BlockSyntax" ; import { Block } from "../../BlockTree" ; import { Configuration } from "../../configuration" ; import * as errors from "../../errors" ; import { sourceRange } from "../../SourceLocation" ; param block param sourceFile param rule export function implementBlock ( configuration , rule , block , sourceFile ) { rule . walkDecls ( IMPLEMENTS , ( decl ) => { let refNames = decl . value . split ( /,\s*/ ) ; refNames . forEach ( ( refName ) => { let refBlock = block . getReferencedBlock ( refName ) ; if ( ! refBlock ) { block . addError ( new errors . InvalidBlockSyntax ( `No Block named "${ refName }" found in scope.` , sourceRange ( configuration , block . stylesheet , sourceFile , decl ) ) ) ; } else { block . addImplementation ( refBlock ) ; } } ) ; } ) ; block . checkImplementations ( ) ; }