/** Returns the original visibility of an overridden property. */ static Visibility getOverriddenPropertyVisibility(ObjectType objectType, String propertyName) { return objectType != null ? objectType.getOwnPropertyJSDocInfo(propertyName).getVisibility() : Visibility.INHERITED; }
/** * Returns the original visibility of an overridden property. */ private static Visibility getOverriddenPropertyVisibility( ObjectType objectType, String propertyName) { return objectType != null ? objectType.getOwnPropertyJSDocInfo(propertyName).getVisibility() : Visibility.INHERITED; }
private boolean isTypeCheckSuppressedProperty(ObjectType obj, String propName) { JSDocInfo info = obj.getOwnPropertyJSDocInfo(propName); return info != null && info.getSuppressions().contains("checkTypes"); }
/** * Returns true if the given property on the given object should be emitted. That is, it is * visible or a constructor. */ private boolean isEmittableProperty(ObjectType obj, String propName) { JSDocInfo info = obj.getOwnPropertyJSDocInfo(propName); // Skip emitting private properties, but do emit constructors because they introduce a // type that can be used in type contexts. return !isPrivate(info) || isConstructor(info); }
/** * Returns true if any type in the chain has an implicitCast annotation for * the given property. */ private static boolean propertyIsImplicitCast(ObjectType type, String prop) { for (; type != null; type = type.getImplicitPrototype()) { JSDocInfo docInfo = type.getOwnPropertyJSDocInfo(prop); if (docInfo != null && docInfo.isImplicitCast()) { return true; } } return false; }
/** * Returns true if any type in the chain has an implicitCast annotation for * the given property. */ private static boolean propertyIsImplicitCast(ObjectType type, String prop) { for (; type != null; type = type.getImplicitPrototype()) { JSDocInfo docInfo = type.getOwnPropertyJSDocInfo(prop); if (docInfo != null && docInfo.isImplicitCast()) { return true; } } return false; }
/** * Returns the lowest property defined on a class with visibility information. */ @Nullable static ObjectType getObjectType( @Nullable ObjectType referenceType, boolean isOverride, String propertyName) { if (referenceType == null) { return null; } // Find the lowest property defined on a class with visibility information. ObjectType current = isOverride ? referenceType.getImplicitPrototype() : referenceType; for (; current != null; current = current.getImplicitPrototype()) { JSDocInfo docInfo = current.getOwnPropertyJSDocInfo(propertyName); if (docInfo != null && docInfo.getVisibility() != Visibility.INHERITED) { return current; } } return null; }
/** * Returns the deprecation reason for the property if it is marked * as being deprecated. Returns empty string if the property is deprecated * but no reason was given. Returns null if the property is not deprecated. */ @Nullable private static String getPropertyDeprecationInfo(ObjectType type, String prop) { String depReason = getDeprecationReason(type.getOwnPropertyJSDocInfo(prop)); if (depReason != null) { return depReason; } ObjectType implicitProto = type.getImplicitPrototype(); if (implicitProto != null) { return getPropertyDeprecationInfo(implicitProto, prop); } return null; }
@Nullable private static ObjectType getObjectType( @Nullable ObjectType referenceType, boolean isOverride, String propertyName) { if (referenceType == null) { return null; } // Find the lowest property defined on a class with visibility // information. ObjectType objectType = isOverride ? referenceType.getImplicitPrototype() : referenceType; for (; objectType != null; objectType = objectType.getImplicitPrototype()) { JSDocInfo docInfo = objectType.getOwnPropertyJSDocInfo(propertyName); if (docInfo != null && docInfo.getVisibility() != Visibility.INHERITED) { return objectType; } } return null; }
/** * Returns the lowest property defined on a class with visibility information. */ @Nullable private static ObjectType getObjectType( @Nullable ObjectType referenceType, boolean isOverride, String propertyName) { if (referenceType == null) { return null; } ObjectType objectType = isOverride ? referenceType.getImplicitPrototype() : referenceType; for (; objectType != null; objectType = objectType.getImplicitPrototype()) { JSDocInfo docInfo = objectType.getOwnPropertyJSDocInfo(propertyName); if (docInfo != null && docInfo.getVisibility() != Visibility.INHERITED) { return objectType; } } return null; }
if (isExtern && isStatic && isLikelyNamespace(type.getOwnPropertyJSDocInfo(propName))) { return false;
/** * Look up the visibility of the overridden property recursively. In Closure, a child class can * override an implicit public property with tighter visibility, but it is not allowed in * TypeScript. So clutz ignores and emits it as a public property. */ private boolean isProtectedProperty(ObjectType prototype, final String propName) { Visibility visibility = Visibility.INHERITED; while (prototype != null) { if (prototype.hasOwnProperty(propName)) { final JSDocInfo jsDocInfo = prototype.getOwnPropertyJSDocInfo(propName); if (jsDocInfo != null) { visibility = jsDocInfo.getVisibility(); } } prototype = prototype.getImplicitPrototype(); } return visibility == Visibility.PROTECTED; }
/** * Returns if a property is declared constant. */ private boolean isPropertyDeclaredConstant( ObjectType objectType, String prop) { if (enforceCodingConventions && compiler.getCodingConvention().isConstant(prop)) { return true; } for (; objectType != null; objectType = objectType.getImplicitPrototype()) { JSDocInfo docInfo = objectType.getOwnPropertyJSDocInfo(prop); if (docInfo != null && docInfo.isConstant()) { return true; } } return false; }
/** * Returns if a property is declared constant. */ private boolean isPropertyDeclaredConstant( ObjectType objectType, String prop) { if (enforceCodingConventions && compiler.getCodingConvention().isConstant(prop)) { return true; } for (; objectType != null; objectType = objectType.getImplicitPrototype()) { JSDocInfo docInfo = objectType.getOwnPropertyJSDocInfo(prop); if (docInfo != null && docInfo.isConstant()) { return true; } } return false; }
JSDocInfo jsdoc = objectType.getOwnPropertyJSDocInfo(propertyName); if (jsdoc != null) { raw = jsdoc.getVisibility();
private void visitProperty( String propName, ObjectType objType, boolean isStatic, boolean forcePropDeclaration, boolean isNamespace, List<String> classTemplateTypeNames) { JSType propertyType = objType.getPropertyType(propName); // The static methods from the function prototype are provided by lib.d.ts. if (isStatic && isFunctionPrototypeProp(propName)) return; JSDocInfo jsdoc = objType.getOwnPropertyJSDocInfo(propName); maybeEmitJsDoc(jsdoc, /* ignoreParams */ false); boolean isProtected = isProtectedProperty(objType, propName); emitProperty( propName, propertyType, isStatic, isProtected, forcePropDeclaration, isNamespace, classTemplateTypeNames); }
raw = objectType.getOwnPropertyJSDocInfo(propertyName).getVisibility();
raw = objectType.getOwnPropertyJSDocInfo(propertyName).getVisibility();
/** * Returns the deprecation reason for the property if it is marked * as being deprecated. Returns empty string if the property is deprecated * but no reason was given. Returns null if the property is not deprecated. */ private static String getPropertyDeprecationInfo(ObjectType type, String prop) { JSDocInfo info = type.getOwnPropertyJSDocInfo(prop); if (info != null && info.isDeprecated()) { if (info.getDeprecationReason() != null) { return info.getDeprecationReason(); } return ""; } ObjectType implicitProto = type.getImplicitPrototype(); if (implicitProto != null) { return getPropertyDeprecationInfo(implicitProto, prop); } return null; }
di = objectType.getOwnPropertyJSDocInfo(propertyName); if (di != null) { if (fieldIsPrivate || di.getVisibility() == Visibility.PRIVATE) {