import { postcss } from "opticss" ; import { EXTENDS } from "../../BlockSyntax" ; import { Block } from "../../BlockTree" ; import { Configuration } from "../../configuration" ; import * as errors from "../../errors" ; import { sourceRange } from "../../SourceLocation" ; param block param sourceFile param root export function extendBlock ( configuration , root , block , sourceFile ) { root . walkDecls ( EXTENDS , ( decl ) => { if ( block . base ) { block . addError ( new errors . InvalidBlockSyntax ( `A block can only be extended once.` , sourceRange ( configuration , root , sourceFile , decl ) ) ) ; } let baseBlock = block . getReferencedBlock ( decl . value ) ; if ( ! baseBlock ) { block . addError ( new errors . InvalidBlockSyntax ( `No Block named "${ decl . value }" found in scope.` , sourceRange ( configuration , root , sourceFile , decl ) ) ) ; } else { block . setBase ( baseBlock ) ; } } ) ; }