本文整理汇总了Java中com.google.javascript.rhino.JSDocInfo.isConstant方法的典型用法代码示例。如果您正苦于以下问题:Java JSDocInfo.isConstant方法的具体用法?Java JSDocInfo.isConstant怎么用?Java JSDocInfo.isConstant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.rhino.JSDocInfo
的用法示例。
在下文中一共展示了JSDocInfo.isConstant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import com.google.javascript.rhino.JSDocInfo; //导入方法依赖的package包/类
@Override
public void visit(NodeTraversal t, Node n, Node parent) {
// Note: Constant properties annotations are not propagated.
if (n.getType() == Token.NAME) {
if (n.getString().isEmpty()) {
return;
}
JSDocInfo info = null;
// Find the JSDocInfo for a top level variable.
Var var = t.getScope().getVar(n.getString());
if (var != null) {
info = var.getJSDocInfo();
}
if ((info != null && info.isConstant()) &&
!n.getBooleanProp(Node.IS_CONSTANT_NAME)) {
n.putBooleanProp(Node.IS_CONSTANT_NAME, true);
if (assertOnChange) {
String name = n.getString();
throw new IllegalStateException(
"Unexpected const change.\n" +
" name: "+ name + "\n" +
" gramps:" + n.getParent().getParent().toStringTree());
}
// Even though the AST has changed (an annotation was added),
// the annotations are not compared so don't report the change.
// reportCodeChange("constant annotation");
}
}
}
示例2: isConstant
import com.google.javascript.rhino.JSDocInfo; //导入方法依赖的package包/类
private static boolean isConstant(StaticTypedSlot<JSType> jsField) {
JSDocInfo jsdoc = jsField.getJSDocInfo();
return jsdoc != null && jsdoc.isConstant();
}