本文整理汇总了Java中com.google.javascript.rhino.JSDocInfo.Visibility类的典型用法代码示例。如果您正苦于以下问题:Java Visibility类的具体用法?Java Visibility怎么用?Java Visibility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Visibility类属于com.google.javascript.rhino.JSDocInfo包,在下文中一共展示了Visibility类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: visitFunctionNode
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
private void visitFunctionNode(Node n, Node parent) {
Node name = null;
JSDocInfo info = parent.getJSDocInfo();
if (info != null && info.isConstructor()) {
name = parent.getFirstChild();
} else {
// look to the child, maybe it's a named function
info = n.getJSDocInfo();
if (info != null && info.isConstructor()) {
name = n.getFirstChild();
}
}
if (name != null && name.isQualifiedName()) {
String qualifiedName = name.getQualifiedName();
if (!this.convention.isPrivate(qualifiedName)) {
Visibility visibility = info.getVisibility();
if (!visibility.equals(JSDocInfo.Visibility.PRIVATE)) {
ctors.put(qualifiedName, name);
}
}
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:23,代码来源:CheckProvides.java
示例2: checkNameVisibility
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
/**
* 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,代码行数:27,代码来源:CheckAccessControls.java
示例3: testGetAndSetJSDocInfoWithObjectTypes
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
public void testGetAndSetJSDocInfoWithObjectTypes() throws Exception {
ObjectType sup =
registry.createObjectType(registry.createAnonymousObjectType());
ObjectType sub = registry.createObjectType(sup);
JSDocInfo deprecated = new JSDocInfo();
deprecated.setDeprecated(true);
JSDocInfo privateInfo = new JSDocInfo();
privateInfo.setVisibility(Visibility.PRIVATE);
sup.defineProperty("X", NUMBER_TYPE, false, false);
sup.setPropertyJSDocInfo("X", privateInfo, false);
sub.setPropertyJSDocInfo("X", deprecated, false);
assertFalse(sup.getOwnPropertyJSDocInfo("X").isDeprecated());
assertEquals(Visibility.PRIVATE,
sup.getOwnPropertyJSDocInfo("X").getVisibility());
assertEquals(NUMBER_TYPE, sup.getPropertyType("X"));
assertTrue(sub.getOwnPropertyJSDocInfo("X").isDeprecated());
assertNull(sub.getOwnPropertyJSDocInfo("X").getVisibility());
assertEquals(NUMBER_TYPE, sub.getPropertyType("X"));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:25,代码来源:JSTypeTest.java
示例4: testRegression2
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
public void testRegression2() throws Exception {
String comment =
" * @return {boolean} whatever\n" +
" * but important\n" +
" *\n" +
" * @param {number} index the index of blah\n" +
" * some more comments here\n" +
" * @param name the name of the guy\n" +
" *\n" +
" * @protected\n" +
" */";
JSDocInfo info = parse(comment);
assertEquals(2, info.getParameterCount());
assertTypeEquals(NUMBER_TYPE, info.getParameterType("index"));
assertEquals(null, info.getParameterType("name"));
assertTypeEquals(BOOLEAN_TYPE, info.getReturnType());
assertEquals(Visibility.PROTECTED, info.getVisibility());
}
开发者ID:andyjko,项目名称:feedlack,代码行数:20,代码来源:JsDocInfoParserTest.java
示例5: testRegression3
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
public void testRegression3() throws Exception {
String comment =
" * @param mediaTag this specified whether the @media tag is ....\n" +
" *\n" +
"\n" +
"@public\n" +
" *\n" +
"\n" +
" **********\n" +
" * @final\n" +
" */";
JSDocInfo info = parse(comment);
assertEquals(1, info.getParameterCount());
assertEquals(null, info.getParameterType("mediaTag"));
assertEquals(Visibility.PUBLIC, info.getVisibility());
assertTrue(info.isConstant());
}
开发者ID:andyjko,项目名称:feedlack,代码行数:19,代码来源:JsDocInfoParserTest.java
示例6: testRegression9
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
public void testRegression9() throws Exception {
JSDocInfo jsdoc = parse(
" * @param {string} p0 blah blah blah\n" +
" */");
assertNull(jsdoc.getBaseType());
assertFalse(jsdoc.isConstant());
assertNull(jsdoc.getDescription());
assertNull(jsdoc.getEnumParameterType());
assertFalse(jsdoc.isHidden());
assertEquals(1, jsdoc.getParameterCount());
assertTypeEquals(STRING_TYPE, jsdoc.getParameterType("p0"));
assertNull(jsdoc.getReturnType());
assertNull(jsdoc.getType());
assertEquals(Visibility.INHERITED, jsdoc.getVisibility());
}
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:JsDocInfoParserTest.java
示例7: testRegression10
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
public void testRegression10() throws Exception {
JSDocInfo jsdoc = parse(
" * @param {!String} p0 blah blah blah\n" +
" * @param {boolean} p1 fobar\n" +
" * @return {!Date} jksjkash dshad\n" +
" */");
assertNull(jsdoc.getBaseType());
assertFalse(jsdoc.isConstant());
assertNull(jsdoc.getDescription());
assertNull(jsdoc.getEnumParameterType());
assertFalse(jsdoc.isHidden());
assertEquals(2, jsdoc.getParameterCount());
assertTypeEquals(STRING_OBJECT_TYPE, jsdoc.getParameterType("p0"));
assertTypeEquals(BOOLEAN_TYPE, jsdoc.getParameterType("p1"));
assertTypeEquals(DATE_TYPE, jsdoc.getReturnType());
assertNull(jsdoc.getType());
assertEquals(Visibility.INHERITED, jsdoc.getVisibility());
}
开发者ID:andyjko,项目名称:feedlack,代码行数:20,代码来源:JsDocInfoParserTest.java
示例8: testRegression12
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
public void testRegression12() throws Exception {
JSDocInfo jsdoc = parse(
" * @extends FooBar\n" +
" */");
assertTypeEquals(new NamedType(registry, "FooBar", null, 0, 0),
jsdoc.getBaseType());
assertFalse(jsdoc.isConstant());
assertNull(jsdoc.getDescription());
assertNull(jsdoc.getEnumParameterType());
assertFalse(jsdoc.isHidden());
assertEquals(0, jsdoc.getParameterCount());
assertNull(jsdoc.getReturnType());
assertNull(jsdoc.getType());
assertEquals(Visibility.INHERITED, jsdoc.getVisibility());
}
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:JsDocInfoParserTest.java
示例9: testRegression13
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
public void testRegression13() throws Exception {
JSDocInfo jsdoc = parse(
" * @type {!RegExp}\n" +
" * @protected\n" +
" */");
assertNull(jsdoc.getBaseType());
assertFalse(jsdoc.isConstant());
assertNull(jsdoc.getDescription());
assertNull(jsdoc.getEnumParameterType());
assertFalse(jsdoc.isHidden());
assertEquals(0, jsdoc.getParameterCount());
assertNull(jsdoc.getReturnType());
assertTypeEquals(REGEXP_TYPE, jsdoc.getType());
assertEquals(Visibility.PROTECTED, jsdoc.getVisibility());
}
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:JsDocInfoParserTest.java
示例10: testRegression14
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
public void testRegression14() throws Exception {
JSDocInfo jsdoc = parse(
" * @const\n" +
" * @private\n" +
" */");
assertNull(jsdoc.getBaseType());
assertTrue(jsdoc.isConstant());
assertNull(jsdoc.getDescription());
assertNull(jsdoc.getEnumParameterType());
assertFalse(jsdoc.isHidden());
assertEquals(0, jsdoc.getParameterCount());
assertNull(jsdoc.getReturnType());
assertNull(jsdoc.getType());
assertEquals(Visibility.PRIVATE, jsdoc.getVisibility());
}
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:JsDocInfoParserTest.java
示例11: testRegression15
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
public void testRegression15() throws Exception {
JSDocInfo jsdoc = parse(
" * @desc Hello,\n" +
" * World!\n" +
" */");
assertNull(jsdoc.getBaseType());
assertFalse(jsdoc.isConstant());
assertEquals("Hello, World!", jsdoc.getDescription());
assertNull(jsdoc.getEnumParameterType());
assertFalse(jsdoc.isHidden());
assertEquals(0, jsdoc.getParameterCount());
assertNull(jsdoc.getReturnType());
assertNull(jsdoc.getType());
assertEquals(Visibility.INHERITED, jsdoc.getVisibility());
assertFalse(jsdoc.isExport());
}
开发者ID:andyjko,项目名称:feedlack,代码行数:18,代码来源:JsDocInfoParserTest.java
示例12: checkNameVisibility
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
/**
* 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,代码行数:27,代码来源:CheckAccessControls.java
示例13: testGetAndSetJSDocInfoWithObjectTypes
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
public void testGetAndSetJSDocInfoWithObjectTypes() throws Exception {
ObjectType sup =
registry.createObjectType(registry.createAnonymousObjectType());
ObjectType sub = registry.createObjectType(sup);
JSDocInfo deprecated = new JSDocInfo();
deprecated.setDeprecated(true);
JSDocInfo privateInfo = new JSDocInfo();
privateInfo.setVisibility(Visibility.PRIVATE);
sup.defineProperty("X", NUMBER_TYPE, false, false);
sup.setPropertyJSDocInfo("X", privateInfo, false);
sub.setPropertyJSDocInfo("X", deprecated, false);
assertFalse(sup.getOwnPropertyJSDocInfo("X").isDeprecated());
assertEquals(Visibility.PRIVATE,
sup.getOwnPropertyJSDocInfo("X").getVisibility());
assertTypeEquals(NUMBER_TYPE, sup.getPropertyType("X"));
assertTrue(sub.getOwnPropertyJSDocInfo("X").isDeprecated());
assertNull(sub.getOwnPropertyJSDocInfo("X").getVisibility());
assertTypeEquals(NUMBER_TYPE, sub.getPropertyType("X"));
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:25,代码来源:JSTypeTest.java
示例14: testRegression12
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
public void testRegression12() throws Exception {
JSDocInfo jsdoc = parse(
" * @extends FooBar\n" +
" */");
assertTypeEquals(registry.createNamedType("FooBar", null, 0, 0),
jsdoc.getBaseType());
assertFalse(jsdoc.isConstant());
assertNull(jsdoc.getDescription());
assertNull(jsdoc.getEnumParameterType());
assertFalse(jsdoc.isHidden());
assertEquals(0, jsdoc.getParameterCount());
assertNull(jsdoc.getReturnType());
assertNull(jsdoc.getType());
assertEquals(Visibility.INHERITED, jsdoc.getVisibility());
}
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:17,代码来源:JsDocInfoParserTest.java
示例15: visit
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
JSDocInfo bestJSDocInfo = NodeUtil.getBestJSDocInfo(n);
if (bestJSDocInfo == null) {
return;
}
// Add visibility for private and protected.
if (Visibility.PRIVATE.equals(bestJSDocInfo.getVisibility())) {
n.putProp(Node.ACCESS_MODIFIER, Visibility.PRIVATE);
} else if (Visibility.PROTECTED.equals(bestJSDocInfo.getVisibility())) {
n.putProp(Node.ACCESS_MODIFIER, Visibility.PROTECTED);
}
// Change variable declarations to constants
if (bestJSDocInfo.isConstant() && (n.isVar() || n.isLet())) {
n.setToken(Token.CONST);
}
}
开发者ID:angular,项目名称:clutz,代码行数:20,代码来源:TypeAnnotationPass.java
示例16: testGetAndSetJSDocInfoWithObjectTypes
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
public void testGetAndSetJSDocInfoWithObjectTypes() throws Exception {
ObjectType sup =
registry.createObjectType(registry.createAnonymousObjectType(null));
ObjectType sub = registry.createObjectType(sup);
JSDocInfo deprecated = new JSDocInfo();
deprecated.setDeprecated(true);
JSDocInfo privateInfo = new JSDocInfo();
privateInfo.setVisibility(Visibility.PRIVATE);
sup.defineProperty("X", NUMBER_TYPE, true, null);
sup.setPropertyJSDocInfo("X", privateInfo);
sub.defineProperty("X", NUMBER_TYPE, true, null);
sub.setPropertyJSDocInfo("X", deprecated);
assertFalse(sup.getOwnPropertyJSDocInfo("X").isDeprecated());
assertEquals(Visibility.PRIVATE,
sup.getOwnPropertyJSDocInfo("X").getVisibility());
assertTypeEquals(NUMBER_TYPE, sup.getPropertyType("X"));
assertTrue(sub.getOwnPropertyJSDocInfo("X").isDeprecated());
assertNull(sub.getOwnPropertyJSDocInfo("X").getVisibility());
assertTypeEquals(NUMBER_TYPE, sub.getPropertyType("X"));
}
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:JSTypeTest.java
示例17: visitFunction
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
private void visitFunction(NodeTraversal t, Node function, Node parent) {
JSDocInfo jsDoc = NodeUtil.getBestJSDocInfo(function);
if (jsDoc == null && !hasAnyInlineJsDoc(function)) {
checkMissingJsDoc(t, function);
} else {
if (t.inGlobalScope()
|| hasAnyInlineJsDoc(function)
|| !jsDoc.getParameterNames().isEmpty()
|| jsDoc.hasReturnType()) {
checkParams(t, function, jsDoc);
}
checkReturn(t, function, jsDoc);
}
if (parent.isMemberFunctionDef()
&& "constructor".equals(parent.getString())
&& jsDoc != null
&& !jsDoc.getVisibility().equals(Visibility.INHERITED)) {
t.report(function, CONSTRUCTOR_DISALLOWED_JSDOC);
}
}
开发者ID:google,项目名称:closure-compiler,代码行数:23,代码来源:CheckJSDocStyle.java
示例18: visitName
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
private void visitName(NodeTraversal t, Node n) {
Symbol symbol = symbols.get(n, n.getString());
if (symbol == null) {
return;
}
// Visibility already set.
if (symbol.getVisibility() != null) {
return;
}
Var var = t.getScope().getVar(n.getString());
if (var == null) {
return;
}
Visibility v = AccessControlUtils.getEffectiveNameVisibility(
n, var, fileVisibilityMap);
if (v == null) {
return;
}
symbol.setVisibility(v);
}
开发者ID:google,项目名称:closure-compiler,代码行数:21,代码来源:SymbolTable.java
示例19: visitFunctionNode
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
private void visitFunctionNode(Node n, Node parent) {
// TODO(user): Use isPrivate method below to recognize all functions.
Node name = null;
JSDocInfo info = parent.getJSDocInfo();
if (info != null && info.isConstructor()) {
name = parent.getFirstChild();
} else {
// look to the child, maybe it's a named function
info = n.getJSDocInfo();
if (info != null && info.isConstructor()) {
name = n.getFirstChild();
}
}
if (name != null && name.isQualifiedName()) {
String qualifiedName = name.getQualifiedName();
if (!this.convention.isPrivate(qualifiedName)) {
Visibility visibility = info.getVisibility();
if (!visibility.equals(JSDocInfo.Visibility.PRIVATE)) {
ctors.put(qualifiedName, name);
}
}
}
}
开发者ID:google,项目名称:closure-compiler,代码行数:24,代码来源:CheckProvides.java
示例20: getEffectivePropertyVisibility
import com.google.javascript.rhino.JSDocInfo.Visibility; //导入依赖的package包/类
/**
* Returns the effective visibility of the given property. This can differ
* from the property's declared visibility if the property is inherited from
* a superclass, or if the file's {@code @fileoverview} JsDoc specifies
* a default visibility.
*
* @param property The property to compute effective visibility for.
* @param referenceType The JavaScript type of the property.
* @param fileVisibilityMap A map of {@code @fileoverview} visibility
* annotations, used to compute the property's default visibility.
* @param codingConvention The coding convention in effect (if any),
* used to determine whether the property is private by lexical convention
* (example: trailing underscore).
*/
static Visibility getEffectivePropertyVisibility(
Node property,
ObjectTypeI referenceType,
ImmutableMap<StaticSourceFile, Visibility> fileVisibilityMap,
@Nullable CodingConvention codingConvention) {
String propertyName = property.getLastChild().getString();
StaticSourceFile definingSource = getDefiningSource(
property, referenceType, propertyName);
Visibility fileOverviewVisibility = fileVisibilityMap.get(definingSource);
Node parent = property.getParent();
boolean isOverride = parent.getJSDocInfo() != null
&& parent.isAssign()
&& parent.getFirstChild() == property;
ObjectTypeI objectType = getObjectType(
referenceType, isOverride, propertyName);
if (isOverride) {
Visibility overridden = getOverriddenPropertyVisibility(
objectType, propertyName);
return getEffectiveVisibilityForOverriddenProperty(
overridden, fileOverviewVisibility, propertyName, codingConvention);
} else {
return getEffectiveVisibilityForNonOverriddenProperty(
property, objectType, fileOverviewVisibility, codingConvention);
}
}
开发者ID:google,项目名称:closure-compiler,代码行数:40,代码来源:AccessControlUtils.java
注:本文中的com.google.javascript.rhino.JSDocInfo.Visibility类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论