private ImmutableList<Require> getAllRequiresFromDestructuring(
      Node objectPattern, String namespace) {
    ImmutableList.Builder<Require> requireBuilder = ImmutableList.builder();
    for (Node key : objectPattern.children()) {
      if (!key.isStringKey()) {
        // Bad code, just ignore. We warn elsewhere.
        continue;
      }
      Node lhs = key.getOnlyChild();
      if (!lhs.isName()) {
        // Bad code ( e.g. `const {a = 0} = goog.require(...)`). We warn elsewhere.
        continue;
      }

      requireBuilder.add(
          Require.create(
              lhs.getString(),
              Import.builder()
                  .moduleRequest(namespace)
                  .localName(lhs.getString())
                  .importName(key.getString())
                  .importNode(nameDeclaration)
                  .nameNode(lhs)
                  .build(),
              requireKind));
    }
    return requireBuilder.build();
  }
private ImmutableList < Require > getAllRequiresFromDestructuring ( Node objectPattern , String namespace ) { ImmutableList . Builder < Require > requireBuilder = ImmutableList . builder ( ) ; for ( Node key : objectPattern . children ( ) ) { if ( ! key . isStringKey ( ) ) { continue ; } Node lhs = key . getOnlyChild ( ) ; if ( ! lhs . isName ( ) ) { continue ; } requireBuilder . add ( Require . create ( lhs . getString ( ) , Import . builder ( ) . moduleRequest ( namespace ) . localName ( lhs . getString ( ) ) . importName ( key . getString ( ) ) . importNode ( nameDeclaration ) . nameNode ( lhs ) . build ( ) , requireKind ) ) ; } return requireBuilder . build ( ) ; }
Returns all requires from destructruring, like `const {x, y, z} = goog.require('a');`