本文整理汇总了Java中com.google.javascript.rhino.JSDocInfo类的典型用法代码示例。如果您正苦于以下问题:Java JSDocInfo类的具体用法?Java JSDocInfo怎么用?Java JSDocInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSDocInfo类属于com.google.javascript.rhino包,在下文中一共展示了JSDocInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testAuthors
import com.google.javascript.rhino.JSDocInfo; //导入依赖的package包/类
public void testAuthors() throws Exception {
JSDocInfo jsdoc
= parse("@param {Number} number42 This is a description."
+ "\n* @param {Integer} number87 This is another description."
+ "\n* @author [email protected] (A Person)"
+ "\n* @author [email protected] (B Person)"
+ "\n* @author [email protected] (C Person)*/"
, true);
Collection<String> authors = jsdoc.getAuthors();
assertTrue(authors != null);
assertTrue(authors.size() == 3);
assertContains(authors, "[email protected] (A Person)");
assertContains(authors, "[email protected] (B Person)");
assertContains(authors, "[email protected] (C Person)");
}
开发者ID:andyjko,项目名称:feedlack,代码行数:19,代码来源:JsDocInfoParserTest.java
示例2: getInfoForNameNode
import com.google.javascript.rhino.JSDocInfo; //导入依赖的package包/类
/**
* @param nameNode A name node
* @return The JSDocInfo for the name node
*/
static JSDocInfo getInfoForNameNode(Node nameNode) {
JSDocInfo info = null;
Node parent = null;
if (nameNode != null) {
info = nameNode.getJSDocInfo();
parent = nameNode.getParent();
}
if (info == null && parent != null &&
((parent.getType() == Token.VAR && parent.hasOneChild()) ||
parent.getType() == Token.FUNCTION)) {
info = parent.getJSDocInfo();
}
return info;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:20,代码来源:NodeUtil.java
示例3: assertDocumentationInMarker
import com.google.javascript.rhino.JSDocInfo; //导入依赖的package包/类
/**
* Asserts that a documentation field exists on the given marker.
*
* @param description The text of the documentation field expected.
* @param startCharno The starting character of the text.
* @param endLineno The ending line of the text.
* @param endCharno The ending character of the text.
* @return The marker, for chaining purposes.
*/
private JSDocInfo.Marker assertDocumentationInMarker(JSDocInfo.Marker marker,
String description,
int startCharno,
int endLineno,
int endCharno) {
assertTrue(marker.description != null);
assertEquals(description, marker.description.getItem());
// Match positional information.
assertEquals(marker.annotation.getStartLine(),
marker.description.getStartLine());
assertEquals(startCharno, marker.description.getPositionOnStartLine());
assertEquals(endLineno, marker.description.getEndLine());
assertEquals(endCharno, marker.description.getPositionOnEndLine());
return marker;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:27,代码来源:JsDocInfoParserTest.java
示例4: getDocInfoForDeclaration
import com.google.javascript.rhino.JSDocInfo; //导入依赖的package包/类
/**
* Tries to get the doc info for a given declaration ref.
*/
private static JSDocInfo getDocInfoForDeclaration(Ref ref) {
if (ref.node != null) {
Node refParent = ref.node.getParent();
switch (refParent.getType()) {
case Token.FUNCTION:
case Token.ASSIGN:
return refParent.getJSDocInfo();
case Token.VAR:
return ref.node == refParent.getFirstChild() ?
refParent.getJSDocInfo() : ref.node.getJSDocInfo();
}
}
return null;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:19,代码来源:GlobalNamespace.java
示例5: ensureTyped
import com.google.javascript.rhino.JSDocInfo; //导入依赖的package包/类
/**
* Enforces type casts, and ensures the node is typed.
*
* A cast in the way that we use it in JSDoc annotations never
* alters the generated code and therefore never can induce any runtime
* operation. What this means is that a 'cast' is really just a compile
* time constraint on the underlying value. In the future, we may add
* support for run-time casts for compiled tests.
*
* To ensure some shred of sanity, we enforce the notion that the
* type you are casting to may only meaningfully be a narrower type
* than the underlying declared type. We also invalidate optimizations
* on bad type casts.
*
* @param t The traversal object needed to report errors.
* @param n The node getting a type assigned to it.
* @param type The type to be assigned.
*/
private void ensureTyped(NodeTraversal t, Node n, JSType type) {
// Make sure FUNCTION nodes always get function type.
Preconditions.checkState(n.getType() != Token.FUNCTION ||
type instanceof FunctionType ||
type.isUnknownType());
JSDocInfo info = n.getJSDocInfo();
if (info != null) {
if (info.hasType()) {
JSType infoType = info.getType().evaluate(t.getScope());
validator.expectCanCast(t, n, infoType, type);
type = infoType;
}
if (info.isImplicitCast() && !inExterns) {
String propName = n.getType() == Token.GETPROP ?
n.getLastChild().getString() : "(missing)";
compiler.report(
JSError.make(t, n, ILLEGAL_IMPLICIT_CAST, propName));
}
}
if (n.getJSType() == null) {
n.setJSType(type);
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:44,代码来源:TypeCheck.java
示例6: checkForHosedThisReferences
import com.google.javascript.rhino.JSDocInfo; //导入依赖的package包/类
/**
* Warns about any references to "this" in the given FUNCTION. The function
* is getting collapsed, so the references will change.
*/
private void checkForHosedThisReferences(Node function, JSDocInfo docInfo,
final Name name) {
// A function is getting collapsed. Make sure that if it refers to
// "this", it must be a constructor or documented with @this.
if (docInfo == null ||
(!docInfo.isConstructor() && !docInfo.hasThisType())) {
NodeTraversal.traverse(compiler, function.getLastChild(),
new NodeTraversal.AbstractShallowCallback() {
public void visit(NodeTraversal t, Node n, Node parent) {
if (n.getType() == Token.THIS) {
compiler.report(
JSError.make(name.declaration.sourceName, n,
UNSAFE_THIS, name.fullName()));
}
}
});
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:23,代码来源:CollapseProperties.java
示例7: check
import com.google.javascript.rhino.JSDocInfo; //导入依赖的package包/类
/**
* Reports errors for any invalid use of control structures.
*
* @param node Current node to check.
*/
private void check(Node node) {
switch (node.getType()) {
case Token.WITH:
JSDocInfo info = node.getJSDocInfo();
boolean allowWith =
info != null && info.getSuppressions().contains("with");
if (!allowWith) {
report(node, USE_OF_WITH);
}
break;
case Token.SCRIPT:
// Remember the source file name in case we need to report an error.
sourceName = (String) node.getProp(Node.SOURCENAME_PROP);
break;
}
for (Node bChild = node.getFirstChild(); bChild != null;) {
Node next = bChild.getNext();
check(bChild);
bChild = next;
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:29,代码来源:ControlStructureCheck.java
示例8: visitFunctionNode
import com.google.javascript.rhino.JSDocInfo; //导入依赖的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
示例9: testRegression3
import com.google.javascript.rhino.JSDocInfo; //导入依赖的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
示例10: testRegression9
import com.google.javascript.rhino.JSDocInfo; //导入依赖的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
示例11: checkNameDeprecation
import com.google.javascript.rhino.JSDocInfo; //导入依赖的package包/类
/**
* Checks the given NAME node to ensure that access restrictions are obeyed.
*/
private void checkNameDeprecation(NodeTraversal t, Node n, Node parent) {
// Don't bother checking definitions or constructors.
if (parent.getType() == Token.FUNCTION || parent.getType() == Token.VAR ||
parent.getType() == Token.NEW) {
return;
}
Scope.Var var = t.getScope().getVar(n.getString());
JSDocInfo docInfo = var == null ? null : var.getJSDocInfo();
if (docInfo != null && docInfo.isDeprecated() &&
shouldEmitDeprecationWarning(t, n, parent)) {
if (docInfo.getDeprecationReason() != null) {
compiler.report(
JSError.make(t, n, DEPRECATED_NAME_REASON, n.getString(),
docInfo.getDeprecationReason()));
} else {
compiler.report(
JSError.make(t, n, DEPRECATED_NAME, n.getString()));
}
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:27,代码来源:CheckAccessControls.java
示例12: checkNameVisibility
import com.google.javascript.rhino.JSDocInfo; //导入依赖的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
示例13: getPropertyDeprecationInfo
import com.google.javascript.rhino.JSDocInfo; //导入依赖的package包/类
/**
* 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;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:22,代码来源:CheckAccessControls.java
示例14: testRegression2
import com.google.javascript.rhino.JSDocInfo; //导入依赖的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
示例15: testGetAndSetJSDocInfoWithObjectTypes
import com.google.javascript.rhino.JSDocInfo; //导入依赖的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
示例16: testRegression13
import com.google.javascript.rhino.JSDocInfo; //导入依赖的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
示例17: testRegression15
import com.google.javascript.rhino.JSDocInfo; //导入依赖的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
示例18: getJSDocInfo
import com.google.javascript.rhino.JSDocInfo; //导入依赖的package包/类
/**
* Gets the docInfo for this type.
*/
@Override public JSDocInfo getJSDocInfo() {
if (docInfo != null) {
return docInfo;
} else if (getImplicitPrototype() != null) {
return getImplicitPrototype().getJSDocInfo();
} else {
return super.getJSDocInfo();
}
}
开发者ID:andyjko,项目名称:feedlack,代码行数:13,代码来源:ObjectType.java
示例19: testBadImplementsWithNullable
import com.google.javascript.rhino.JSDocInfo; //导入依赖的package包/类
public void testBadImplementsWithNullable() throws Exception {
JSDocInfo jsdoc = parse("@implements {Disposable?}\n * @constructor */",
"expected closing }");
assertTrue(jsdoc.isConstructor());
assertTypeEquals(new NamedType(registry, "Disposable", null, -1, -1),
jsdoc.getImplementedInterfaces().get(0));
}
开发者ID:andyjko,项目名称:feedlack,代码行数:8,代码来源:JsDocInfoParserTest.java
示例20: getOwnPropertyJSDocInfo
import com.google.javascript.rhino.JSDocInfo; //导入依赖的package包/类
@Override
public JSDocInfo getOwnPropertyJSDocInfo(String propertyName) {
Property p = properties.get(propertyName);
if (p != null) {
return p.docInfo;
}
return null;
}
开发者ID:andyjko,项目名称:feedlack,代码行数:9,代码来源:PrototypeObjectType.java
注:本文中的com.google.javascript.rhino.JSDocInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论