private String normalizeIObjectTemplateName(ObjectType type, String displayName) { // IObject itself needs too keep the template names, as it is a trully parametric type. if (type.getDisplayName().equals("IObject")) { return displayName.substring(displayName.indexOf('#') + 1); } // For other types, we use index signatures in TS to express the same concept, so skip // emitting. return null; }
private String getAbsoluteName(ObjectType objectType) { String name = objectType.getDisplayName(); // Names that do not have a namespace '.' are either platform names in the top level // namespace like `Object` or `Element`, or they are unqualified `goog.provide`s, e.g. // `goog.provide('Toplevel')`. In both cases they will be found with the naked name. // However a goog.provide'd name can collide with a re-declared top-level symbol, e.g. if some // code goog.provide's `Element`. // TODO(martinprobst): Consider aliasing all global symbols into the clutz namespace. if (name.indexOf('.') == -1) return name; if (this.isGoogNamespace && name.startsWith("goog.")) return name; return Constants.INTERNAL_NAMESPACE + "." + name; }
private ObjectType getSuperType(FunctionType type) { ObjectType proto = type.getPrototype(); if (proto == null) return null; ObjectType implicitProto = proto.getImplicitPrototype(); if (implicitProto == null) return null; return "Object".equals(implicitProto.getDisplayName()) ? null : implicitProto; }
String emitName = Constants.INTERNAL_NAMESPACE + "." + otype.getDisplayName(); emit("type"); emit(unqualifiedName); emitBreak(); typesUsed.add(otype.getDisplayName());
/** * Emits a type that is not resolved by closure, as the literal string that was in the original * code. Special care is taken for templatized types. */ private void emitNoResolvedTypeAsumingForwardDeclare(ObjectType type) { String displayName = maybeRewriteImportedName(type.getDisplayName()); String maybeGlobalName = maybeRenameGlobalType(displayName); if (maybeGlobalName == null) { typesUsed.add(displayName); displayName = Constants.INTERNAL_NAMESPACE + "." + displayName; } else { displayName = maybeGlobalName; } emit(displayName); List<JSType> templateTypes = type.getTemplateTypes(); if (templateTypes != null && templateTypes.size() > 0) { emitGenericTypeArguments(type.getTemplateTypes().iterator()); } }
String qualifiedName = type.getDisplayName() + "." + propName; if (provides.contains(qualifiedName)) { return false;
typeRegistry.createTemplatizedType(type), inExtendsImplementsPosition); String maybeGlobalName = maybeRenameGlobalType(type.getDisplayName()); if (maybeGlobalName != null) { emit(maybeGlobalName); if (!type.getDisplayName().equals("Object")) { typesUsed.add(type.getDisplayName());
private ImmutableCollection<String> getTagNames(Node tag) { if (tag.isString()) { return ImmutableSet.of(tag.getString().toLowerCase()); } else if (tag.isGetProp() && tag.getFirstChild().matchesQualifiedName("goog.dom.TagName")) { return ImmutableSet.of(tag.getLastChild().getString().toLowerCase()); } // TODO(jakubvrana): Support union, e.g. {!TagName<!HTMLDivElement>|!TagName<!HTMLBRElement>}. JSType type = tag.getJSType(); if (type == null || !type.isGenericObjectType()) { return null; } ObjectType typeAsObj = type.toMaybeObjectType(); if (typeAsObj.getRawType().getDisplayName().equals("goog.dom.TagName")) { JSType tagType = Iterables.getOnlyElement(typeAsObj.getTemplateTypes()); return ELEMENT_TAG_NAMES.get(tagType.getDisplayName()); } return null; }
/** See the comment above on shouldAvoidGeneratingExterns. */ private boolean shouldAvoidGeneratingExterns(ObjectType type) { if (type.getConstructor() == null || type.getConstructor().getSource() == null) return false; return shouldAvoidGeneratingExterns( type.getConstructor().getSource().getSourceFileName(), type.getDisplayName()); }
boolean implementsIArrayLike = false; for (ObjectType implementedInterface : implementedInterfaces) { if (implementedInterface.getDisplayName().equals("IArrayLike")) implementsIArrayLike = true; String displayName = implementedInterface.getDisplayName(); ImmutableList<JSType> templateTypes = implementedInterface.getTemplateTypes();
if (objectType.getDisplayName().endsWith("prototype")) { continue;
if (objectType.getDisplayName().endsWith("prototype")) { continue;
break; if (objectType.getDisplayName().endsWith("prototype")) { continue;