Source:
<code>void walkInnerSymbols(ObjectType type, String innerNamespace) { for (String propName : type.getPropertyNames()) { JSType pType = type.getPropertyType(propName); if (pType.isEnumType() && isPrivate(type.getOwnPropertyJSDocInfo(propName))) { privateEnums.add(innerNamespace + '.' + propName); } } boolean nonEmpty = false; for (String propName : getSortedPublicPropertyNames(type)) { String qualifiedName = innerNamespace + '.' + propName; if (provides.contains(qualifiedName)) continue; JSType pType = type.getPropertyType(propName); if (pType.isEnumType()) { if (!nonEmpty) { <START> emitNamespaceBegin(innerNamespace); <END> nonEmpty = true; } visitEnumType(propName, (EnumType) pType); } else if (isClassLike(pType)) { if (!nonEmpty) { emitNamespaceBegin(innerNamespace); nonEmpty = true; } visitClassOrInterface(propName, (FunctionType) pType); } else if (isTypedef(pType)) { if (!nonEmpty) { emitNamespaceBegin(innerNamespace); nonEmpty = true; } JSType registryType = typeRegistry.getType(qualifiedName); visitTypeAlias(registryType, propName); } else if (type.isInterface()) { if (pType.isFunctionType()) { FunctionType ftype = (FunctionType) pType; if (isOrdinaryFunction(ftype)) { if (!nonEmpty) { emitNamespaceBegin(innerNamespace); nonEmpty = true; } visitFunctionExpression(propName, ftype); } } else if (!pType.isNoType() && !pType.isFunctionPrototypeType()) { if (!nonEmpty) { emitNamespaceBegin(innerNamespace); nonEmpty = true; } visitVarDeclaration(propName, pType); } } } if (nonEmpty) emitNamespaceEnd(); }</code><technical_language>some function check hasAnyNamespaceMembers(type), inspect that? duplicates logic a bit, terribly so? In case, call boolean foundNamespaceMembers invert logic. if (!foundNamespaceMembers) { emitNamespace(); foundNamespaceMembers = true; } this a lot more readable</technical_language>

Target:
void walkInnerSymbols(ObjectType type, String innerNamespace) { for (String propName : type.getPropertyNames()) { JSType pType = type.getPropertyType(propName); if (pType.isEnumType() && isPrivate(type.getOwnPropertyJSDocInfo(propName))) { privateEnums.add(innerNamespace + '.' + propName); } } boolean foundNamespaceMembers = false; for (String propName : getSortedPublicPropertyNames(type)) { String qualifiedName = innerNamespace + '.' + propName; if (provides.contains(qualifiedName)) continue; JSType pType = type.getPropertyType(propName); if (pType.isEnumType()) { if (!foundNamespaceMembers) { emitNamespaceBegin(innerNamespace); foundNamespaceMembers = true; } visitEnumType(propName, (EnumType) pType); } else if (isClassLike(pType)) { if (!foundNamespaceMembers) { emitNamespaceBegin(innerNamespace); foundNamespaceMembers = true; } visitClassOrInterface(propName, (FunctionType) pType); } else if (isTypedef(pType)) { if (!foundNamespaceMembers) { emitNamespaceBegin(innerNamespace); foundNamespaceMembers = true; } JSType registryType = typeRegistry.getType(qualifiedName); visitTypeAlias(registryType, propName); } else if (type.isInterface() && isOrdinaryFunction(pType)) { if (!foundNamespaceMembers) { emitNamespaceBegin(innerNamespace); foundNamespaceMembers = true; } visitFunctionExpression(propName, (FunctionType) pType); } else if (type.isInterface() && !pType.isNoType() && !pType.isFunctionPrototypeType()) { if (!foundNamespaceMembers) { emitNamespaceBegin(innerNamespace); foundNamespaceMembers = true; } visitVarDeclaration(propName, pType); } } if (foundNamespaceMembers) emitNamespaceEnd(); }