本文整理汇总了Java中com.google.javascript.rhino.JSDocInfo.Visibility类的典型用法代码示例。如果您正苦于以下问题:Java Visibility类的具体用法?Java Visibility怎么用?Java Visibility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Visibility类属于com.google.javascript.rhino.JSDocInfo包,在下文中一共展示了Visibility类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
}
示例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()));
}
}
}
}
示例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"));
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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()));
}
}
}
}
示例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"));
}
示例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());
}
示例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);
}
}