本文整理汇总了Java中com.google.javascript.rhino.JSDocInfo.Visibility.INHERITED属性的典型用法代码示例。如果您正苦于以下问题:Java Visibility.INHERITED属性的具体用法?Java Visibility.INHERITED怎么用?Java Visibility.INHERITED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.javascript.rhino.JSDocInfo.Visibility
的用法示例。
在下文中一共展示了Visibility.INHERITED属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObjectType
/**
* Returns the lowest property defined on a class with visibility information.
*/
@Nullable static ObjectTypeI getObjectType(
@Nullable ObjectTypeI referenceType,
boolean isOverride,
String propertyName) {
if (referenceType == null) {
return null;
}
// Find the lowest property defined on a class with visibility information.
ObjectTypeI current = isOverride ? referenceType.getPrototypeObject() : referenceType;
for (; current != null; current = current.getPrototypeObject()) {
JSDocInfo docInfo = current.getOwnPropertyJSDocInfo(propertyName);
if (docInfo != null && docInfo.getVisibility() != Visibility.INHERITED) {
return current;
}
}
return null;
}
示例2: checkKeyVisibilityConvention
/**
* Determines whether the given OBJECTLIT property visibility
* violates the coding convention.
* @param t The current traversal.
* @param key The objectlit key node (STRING_KEY, GETTER_DEF, SETTER_DEF).
*/
private void checkKeyVisibilityConvention(NodeTraversal t,
Node key, Node parent) {
JSDocInfo info = key.getJSDocInfo();
if (info == null) {
return;
}
if (!isPrivateByConvention(key.getString())) {
return;
}
Node assign = parent.getParent();
if (assign == null || !assign.isAssign()) {
return;
}
Node left = assign.getFirstChild();
if (!left.isGetProp()
|| !left.getLastChild().getString().equals("prototype")) {
return;
}
Visibility declaredVisibility = info.getVisibility();
// Visibility is declared to be something other than private.
if (declaredVisibility != Visibility.INHERITED
&& declaredVisibility != Visibility.PRIVATE) {
compiler.report(t.makeError(key, CONVENTION_MISMATCH));
}
}
示例3: checkOverriddenPropertyVisibilityMismatch
private void checkOverriddenPropertyVisibilityMismatch(
Visibility overriding,
Visibility overridden,
@Nullable Visibility fileOverview,
NodeTraversal t,
Node getprop) {
if (overriding == Visibility.INHERITED
&& overriding != overridden
&& fileOverview != null
&& fileOverview != Visibility.INHERITED) {
String propertyName = getprop.getLastChild().getString();
compiler.report(
t.makeError(getprop,
BAD_PROPERTY_OVERRIDE_IN_FILE_WITH_FILEOVERVIEW_VISIBILITY,
propertyName,
fileOverview.name()));
}
}
示例4: copyFrom
public static JSDocInfoBuilder copyFrom(JSDocInfo info) {
JSDocInfo clone = info.clone();
if (clone.getVisibility() == Visibility.INHERITED) {
clone.setVisibility(null);
}
return new JSDocInfoBuilder(clone, info.isDocumentationIncluded(), true);
}
示例5: checkConformance
@Override
protected ConformanceResult checkConformance(NodeTraversal t, Node n) {
if (!n.isScript()) {
return ConformanceResult.CONFORMANCE;
}
JSDocInfo docInfo = n.getJSDocInfo();
if (docInfo == null || !docInfo.hasFileOverview()) {
return ConformanceResult.VIOLATION;
}
Visibility v = docInfo.getVisibility();
if (v == null || v == Visibility.INHERITED) {
return ConformanceResult.VIOLATION;
}
return ConformanceResult.CONFORMANCE;
}
示例6: getEffectiveNameVisibility
/**
* Returns the effective visibility of the given name. This can differ
* from the name's declared visibility if the file's {@code @fileoverview}
* JsDoc specifies a default visibility.
*
* @param name The name node to compute effective visibility for.
* @param var The name to compute effective visibility for.
* @param fileVisibilityMap A map of {@code @fileoverview} visibility
* annotations, used to compute the name's default visibility.
*/
static Visibility getEffectiveNameVisibility(Node name, Var var,
ImmutableMap<StaticSourceFile, Visibility> fileVisibilityMap) {
JSDocInfo jsDocInfo = var.getJSDocInfo();
Visibility raw = (jsDocInfo == null || jsDocInfo.getVisibility() == null)
? Visibility.INHERITED
: jsDocInfo.getVisibility();
if (raw != Visibility.INHERITED) {
return raw;
}
Visibility defaultVisibilityForFile =
fileVisibilityMap.get(var.getSourceFile());
TypeI type = name.getTypeI();
boolean createdFromGoogProvide = (type != null && type.isLiteralObject());
// Ignore @fileoverview visibility when computing the effective visibility
// for names created by goog.provide.
//
// ProcessClosurePrimitives rewrites goog.provide()s as object literal
// declarations, but the exact form depends on the ordering of the
// input files. If goog.provide('a.b') occurs in the inputs before
// goog.provide('a'), it is rewritten like
//
// var a={};a.b={};
//
// If the file containing goog.provide('a.b') also declares a @fileoverview
// visibility, it must not apply to a, as this would make every a.* namespace
// effectively package-private.
return (createdFromGoogProvide || defaultVisibilityForFile == null)
? raw
: defaultVisibilityForFile;
}
示例7: getOverriddenPropertyVisibility
/**
* Returns the original visibility of an overridden property.
*/
private static Visibility getOverriddenPropertyVisibility(
ObjectTypeI objectType, String propertyName) {
return objectType != null
? objectType.getOwnPropertyJSDocInfo(propertyName).getVisibility()
: Visibility.INHERITED;
}
示例8: getEffectiveVisibilityForOverriddenProperty
/**
* Returns the effective visibility of the given overridden property.
* An overridden property inherits the visibility of the property it
* overrides.
*/
private static Visibility getEffectiveVisibilityForOverriddenProperty(
Visibility visibility,
@Nullable Visibility fileOverviewVisibility,
String propertyName,
@Nullable CodingConvention codingConvention) {
if (codingConvention != null && codingConvention.isPrivate(propertyName)) {
return Visibility.PRIVATE;
}
return (fileOverviewVisibility != null
&& visibility == Visibility.INHERITED)
? fileOverviewVisibility
: visibility;
}
示例9: getEffectiveVisibilityForNonOverriddenProperty
/**
* Returns the effective visibility of the given non-overridden property.
* Non-overridden properties without an explicit visibility annotation
* receive the default visibility declared in the file's {@code @fileoverview}
* block, if one exists.
*/
private static Visibility getEffectiveVisibilityForNonOverriddenProperty(
Node getprop,
ObjectTypeI objectType,
@Nullable Visibility fileOverviewVisibility,
@Nullable CodingConvention codingConvention) {
String propertyName = getprop.getLastChild().getString();
if (codingConvention != null && codingConvention.isPrivate(propertyName)) {
return Visibility.PRIVATE;
}
Visibility raw = Visibility.INHERITED;
if (objectType != null) {
raw = objectType.getOwnPropertyJSDocInfo(propertyName).getVisibility();
}
TypeI type = getprop.getTypeI();
boolean createdFromGoogProvide = (type != null && type.isLiteralObject());
// Ignore @fileoverview visibility when computing the effective visibility
// for properties created by goog.provide.
//
// ProcessClosurePrimitives rewrites goog.provide()s as object literal
// declarations, but the exact form depends on the ordering of the
// input files. If goog.provide('a.b.c') occurs in the inputs before
// goog.provide('a'), it is rewritten like
//
// var a={};a.b={}a.b.c={};
//
// If the file containing goog.provide('a.b.c') also declares
// a @fileoverview visibility, it must not apply to b, as this would make
// every a.b.* namespace effectively package-private.
return (raw != Visibility.INHERITED
|| fileOverviewVisibility == null
|| createdFromGoogProvide)
? raw
: fileOverviewVisibility;
}
示例10: checkPrivateNameConvention
/**
* Returns the effective visibility of the given name, reporting an error
* if there is a contradiction in the various sources of visibility
* (example: a variable with a trailing underscore that is declared
* {@code @public}).
*/
private Visibility checkPrivateNameConvention(Visibility v, Node name) {
if (isPrivateByConvention(name.getString())) {
if (v != Visibility.PRIVATE && v != Visibility.INHERITED) {
compiler.report(JSError.make(name, CONVENTION_MISMATCH));
}
return Visibility.PRIVATE;
}
return v;
}
示例11: propertyIsDeclaredButNotPrivate
private static boolean propertyIsDeclaredButNotPrivate(Node getprop, Node parent) {
// This is a declaration with JSDoc
JSDocInfo info = NodeUtil.getBestJSDocInfo(getprop);
if ((parent.isAssign() || parent.isExprResult())
&& parent.getFirstChild() == getprop
&& info != null) {
Visibility declaredVisibility = info.getVisibility();
if (declaredVisibility != Visibility.PRIVATE
&& declaredVisibility != Visibility.INHERITED) {
return true;
}
}
return false;
}
示例12: checkOverriddenPropertyVisibility
private void checkOverriddenPropertyVisibility(
NodeTraversal t,
Node getprop,
Node parent,
Visibility visibility,
Visibility fileOverviewVisibility,
ObjectTypeI objectType,
boolean sameInput) {
// Check an ASSIGN statement that's trying to override a property
// on a superclass.
JSDocInfo overridingInfo = parent.getJSDocInfo();
Visibility overridingVisibility = overridingInfo == null
? Visibility.INHERITED
: overridingInfo.getVisibility();
// Check that:
// (a) the property *can* be overridden,
// (b) the visibility of the override is the same as the
// visibility of the original property,
// (c) the visibility is explicitly redeclared if the override is in
// a file with default visibility in the @fileoverview block.
if (visibility == Visibility.PRIVATE && !sameInput) {
compiler.report(
t.makeError(getprop, PRIVATE_OVERRIDE,
objectType.toString()));
} else if (overridingVisibility != Visibility.INHERITED
&& overridingVisibility != visibility
&& fileOverviewVisibility == null) {
compiler.report(
t.makeError(getprop, VISIBILITY_MISMATCH,
visibility.name(), objectType.toString(),
overridingVisibility.name()));
}
}
示例13: getVisibility
/** Returns the effective visibility for the given type. */
public Visibility getVisibility(NominalType type) {
JsDoc docs = type.getJsDoc();
Visibility visibility = docs.getVisibility();
if (visibility == Visibility.INHERITED
&& defaultVisibilities.containsKey(type.getSourceFile())) {
visibility = defaultVisibilities.get(type.getSourceFile());
}
if (visibility == Visibility.INHERITED) {
visibility = Visibility.PUBLIC;
}
return visibility;
}