private void appendPolymerElementExterns ( final PolymerClassDefinition def ) { if ( ! nativeExternsAdded . add ( def . nativeBaseElement ) ) { return ; } Node block = IR . block ( ) ; Node baseExterns = polymerElementExterns . cloneTree ( ) ; String polymerElementType = PolymerPassStaticUtils . getPolymerElementType ( def ) ; baseExterns . getFirstChild ( ) . setString ( polymerElementType ) ; String elementType = tagNameMap . get ( def . nativeBaseElement ) ; if ( elementType == null ) { compiler . report ( JSError . make ( def . descriptor , POLYMER_INVALID_EXTENDS , def . nativeBaseElement ) ) ; return ; } JSTypeExpression elementBaseType = new JSTypeExpression ( new Node ( Token . BANG , IR . string ( elementType ) ) , VIRTUAL_FILE ) ; JSDocInfoBuilder baseDocs = JSDocInfoBuilder . copyFrom ( baseExterns . getJSDocInfo ( ) ) ; baseDocs . changeBaseType ( elementBaseType ) ; baseExterns . setJSDocInfo ( baseDocs . build ( ) ) ; block . addChildToBack ( baseExterns ) ; for ( Node baseProp : polymerElementProps ) { Node newProp = baseProp . cloneTree ( ) ; Node newPropRootName = NodeUtil . getRootOfQualifiedName ( newProp . getFirstFirstChild ( ) ) ; newPropRootName . setString ( polymerElementType ) ; block . addChildToBack ( newProp ) ; } block . useSourceInfoIfMissingFromForTree ( polymerElementExterns ) ; Node parent = polymerElementExterns . getParent ( ) ; Node stmts = block . removeChildren ( ) ; parent . addChildrenAfter ( stmts , polymerElementExterns ) ; compiler . reportChangeToEnclosingScope ( stmts ) ; }
Duplicates the PolymerElement externs with a different element base class if needed . For example if the base class is HTMLInputElement then a class PolymerInputElement will be added . If the element does not extend a native HTML element this method is a no - op .