当前位置: 首页>>代码示例>>Java>>正文


Java Visibility.PRIVATE属性代码示例

本文整理汇总了Java中com.google.javascript.rhino.JSDocInfo.Visibility.PRIVATE属性的典型用法代码示例。如果您正苦于以下问题:Java Visibility.PRIVATE属性的具体用法?Java Visibility.PRIVATE怎么用?Java Visibility.PRIVATE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.javascript.rhino.JSDocInfo.Visibility的用法示例。


在下文中一共展示了Visibility.PRIVATE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkNameVisibility

/**
 * Determines whether the given name is visible in the current context.
 * @param t The current traversal.
 * @param name The name node.
 */
private void checkNameVisibility(NodeTraversal t, Node name, Node parent) {
  Var var = t.getScope().getVar(name.getString());
  if (var != null) {
    JSDocInfo docInfo = var.getJSDocInfo();
    if (docInfo != null) {
      // If a name is private, make sure that we're in the same file.
      Visibility visibility = docInfo.getVisibility();
      if (visibility == Visibility.PRIVATE &&
          !t.getInput().getName().equals(docInfo.getSourceName())) {
        if (docInfo.isConstructor() &&
            isValidPrivateConstructorAccess(parent)) {
          return;
        }

        compiler.report(
            JSError.make(t, name, BAD_PRIVATE_GLOBAL_ACCESS,
                name.getString(), docInfo.getSourceName()));
      }
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:26,代码来源:CheckAccessControls.java

示例2: checkNameVisibility

/**
 * Determines whether the given name is visible in the current context.
 * @param t The current traversal.
 * @param name The name node.
 */
private void checkNameVisibility(NodeTraversal t, Node name, Node parent) {
  Var var = t.getScope().getVar(name.getString());
  if (var != null) {
    JSDocInfo docInfo = var.getJSDocInfo();
    if (docInfo != null) {
      // If a name is private, make sure that we're in the same file.
      Visibility visibility = docInfo.getVisibility();
      if (visibility == Visibility.PRIVATE &&
          !t.getInput().getName().equals(docInfo.getSourceName())) {
        if (docInfo.isConstructor() &&
            isValidPrivateConstructorAccess(parent)) {
          return;
        }

        compiler.report(
            t.makeError(name, BAD_PRIVATE_GLOBAL_ACCESS,
                name.getString(), docInfo.getSourceName()));
      }
    }
  }
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:26,代码来源:CheckAccessControls.java

示例3: maybeProcessAccessibilityModifier

void maybeProcessAccessibilityModifier(ParseTree parseTree, Node n, @Nullable TokenType type) {
  if (type != null) {
    Visibility access;
    switch (type) {
      case PUBLIC:
        access = Visibility.PUBLIC;
        break;
      case PROTECTED:
        access = Visibility.PROTECTED;
        break;
      case PRIVATE:
        access = Visibility.PRIVATE;
        break;
      default:
        throw new IllegalStateException("Unexpected access modifier type");
    }
    maybeWarnTypeSyntax(parseTree, Feature.ACCESSIBILITY_MODIFIER);
    n.putProp(Node.ACCESS_MODIFIER, access);
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:20,代码来源:IRFactory.java

示例4: 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));
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:31,代码来源:CheckAccessControls.java

示例5: visitConstructor

@Override
protected boolean visitConstructor(FunctionType constructor) {
  Method constructorMethod = Method.newConstructor();
  if (constructor.getJSDocInfo().getVisibility() == Visibility.PRIVATE) {
    constructorMethod.setAccessModifier(AccessModifier.PRIVATE);
  }

  getCurrentJavaType().addMethod(constructorMethod);

  currentJavaMethodDeque.push(constructorMethod);
  return true;
}
 
开发者ID:google,项目名称:jsinterop-generator,代码行数:12,代码来源:MemberCollector.java

示例6: checkNameVisibility

/**
 * Determines whether the given name is visible in the current context.
 * @param t The current traversal.
 * @param name The name node.
 */
private void checkNameVisibility(NodeTraversal t, Node name, Node parent) {
  Var var = t.getScope().getVar(name.getString());
  if (var != null) {
    JSDocInfo docInfo = var.getJSDocInfo();
    if (docInfo != null) {
      // If a name is private, make sure that we're in the same file.
      Visibility visibility = docInfo.getVisibility();
      if (visibility == Visibility.PRIVATE) {
        StaticSourceFile varSrc = var.getSourceFile();
        StaticSourceFile refSrc = name.getStaticSourceFile();
        if (varSrc != null &&
            refSrc != null &&
            !varSrc.getName().equals(refSrc.getName())) {
          if (docInfo.isConstructor() &&
              isValidPrivateConstructorAccess(parent)) {
            return;
          }

          compiler.report(
              t.makeError(name, BAD_PRIVATE_GLOBAL_ACCESS,
                  name.getString(), varSrc.getName()));
        }
      }
    }
  }
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:31,代码来源:CheckAccessControls.java

示例7: recordAbstract

/**
 * Records that the {@link JSDocInfo} being built should have its
 * {@link JSDocInfo#isAbstract()} flag set to {@code true}.
 *
 * @return {@code true} if the flag was recorded and {@code false}
 * if it was already defined or it was incompatible with the existing flags
 */
public boolean recordAbstract() {
  if (!hasAnySingletonTypeTags()
      && !currentInfo.isInterface()
      && !currentInfo.isAbstract()
      && !currentInfo.isFinal()
      && currentInfo.getVisibility() != Visibility.PRIVATE) {
    currentInfo.setAbstract();
    populated = true;
    return true;
  }
  return false;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:19,代码来源:JSDocInfoBuilder.java

示例8: isPrivatePropDecl

private boolean isPrivatePropDecl(Node n) {
  // TODO(johnlenz): add support private by convention property definitions without JSDoc.
  // TODO(johnlenz): add support for checking protected properties in final classes
  // TODO(johnlenz): add support for checking "package" properties when checking an entire
  // library.
  JSDocInfo info = NodeUtil.getBestJSDocInfo(n);
  return (info != null && info.getVisibility() == Visibility.PRIVATE);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:8,代码来源:CheckUnusedPrivateProperties.java

示例9: 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;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:18,代码来源:AccessControlUtils.java

示例10: 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;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:40,代码来源:AccessControlUtils.java

示例11: 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;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:15,代码来源:CheckAccessControls.java

示例12: 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;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:14,代码来源:CheckAccessControls.java

示例13: 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()));
  }
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:34,代码来源:CheckAccessControls.java

示例14: isPrivate

/**
 * Returns a Matcher that matches against nodes that are declared {@code @private}.
 */
public static Matcher isPrivate() {
  return new Matcher() {
    @Override public boolean matches(Node node, NodeMetadata metadata) {
      JSDocInfo jsDoc = NodeUtil.getBestJSDocInfo(node);
      if (jsDoc != null) {
        return jsDoc.getVisibility() == Visibility.PRIVATE;
      }
      return false;
    }
  };
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:14,代码来源:Matchers.java

示例15: isPrivate

private boolean isPrivate(@Nullable JSDocInfo docInfo) {
  return docInfo != null && docInfo.getVisibility() == Visibility.PRIVATE;
}
 
开发者ID:angular,项目名称:clutz,代码行数:3,代码来源:DeclarationGenerator.java


注:本文中的com.google.javascript.rhino.JSDocInfo.Visibility.PRIVATE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。