private void addExportMethod ( Map < String , Node > exports , String export , Node context ) { // We can export as a property if any of the following conditions holds: // a) ES6 class members, which the above `addExportForEs6Method` handles // b) this is a property on a name which is also being exported // c) this is a prototype property String methodOwnerName = null ; // the object this method is on, null for exported names. boolean isEs5StylePrototypeAssignment = false ; // If this is a prototype property String propertyName = null ; if ( context . getFirstChild ( ) . isGetProp ( ) ) { // e.g. `/** @export */ a.prototype.b = obj;` Node node = context . getFirstChild ( ) ; // e.g. get `a.prototype.b` Node ownerNode = node . getFirstChild ( ) ; // e.g. get `a.prototype` methodOwnerName = ownerNode . getQualifiedName ( ) ; // e.g. get the string "a.prototype" if ( ownerNode . isGetProp ( ) && ownerNode . getLastChild ( ) . getString ( ) . equals ( PROTOTYPE_PROPERTY ) ) { // e.g. true if ownerNode is `a.prototype` // false if this export were `/** @export */ a.b = obj;` instead isEs5StylePrototypeAssignment = true ; } propertyName = node . getSecondChild ( ) . getString ( ) ; } boolean useExportSymbol = true ; if ( isEs5StylePrototypeAssignment ) { useExportSymbol = false ; } else if ( methodOwnerName != null && exports . containsKey ( methodOwnerName ) ) { useExportSymbol = false ; } if ( useExportSymbol ) { addExportSymbolCall ( export , context ) ; } else { addExportPropertyCall ( methodOwnerName , context , export , propertyName ) ; } }
Emits a call to either goog . exportProperty or goog . exportSymbol .