本文整理汇总了Java中org.mozilla.javascript.Token.VAR属性的典型用法代码示例。如果您正苦于以下问题:Java Token.VAR属性的具体用法?Java Token.VAR怎么用?Java Token.VAR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.mozilla.javascript.Token
的用法示例。
在下文中一共展示了Token.VAR属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkJS
/**
* Checks the parsed file against the API Map.
*
* @param p
* an instance of {@link JavaScriptParser} to get the tree representation of it
* @param jsFileName
* the JavaScript file name that is being checked
* @throws IOException
*/
private void checkJS(JavaScriptParser p, String jsFileName) throws IOException {
ScriptOrFnNode nodeTree = p.parse();
for (Node cursor = nodeTree.getFirstChild(); cursor != null; cursor = cursor.getNext()) {
StringBuffer sb = new StringBuffer();
if (cursor.getType() == Token.FUNCTION) {
int fnIndex = cursor.getExistingIntProp(Node.FUNCTION_PROP);
FunctionNode fn = nodeTree.getFunctionNode(fnIndex);
sb.append("FUNCTION: " + fn.getFunctionName());
} else if (cursor.getType() == Token.VAR) {
Node vn = cursor.getFirstChild();
sb.append("VAR: " + vn.getString());
}
apiMap.remove(jsFileName + sb);
}
}
示例2: getStringDetails
/**
* @return a string with the global variables and function definitions
*/
public String getStringDetails() {
if (jsFile == null) {
throw new RuntimeException("You need to specify the file to parse");
}
if (details == null) {
details = new StringBuffer();
try {
parse();
} catch (IOException e) {
e.printStackTrace();
}
for (Node cursor = nodeTree.getFirstChild(); cursor != null; cursor = cursor.getNext()) {
if (cursor.getType() == Token.FUNCTION) {
int fnIndex = cursor.getExistingIntProp(Node.FUNCTION_PROP);
FunctionNode fn = nodeTree.getFunctionNode(fnIndex);
details.append("FUNCTION: " + fn.getFunctionName() + "\n");
} else if (cursor.getType() == Token.VAR) {
Node vn = cursor.getFirstChild();
details.append("VAR: " + vn.getString() + "\n");
}
}
}
return details.toString();
}
示例3: setNodeType
/**
* Sets the node type.
* @throws IllegalArgumentException if {@code nodeType} is not one of
* {@link Token#VAR}, {@link Token#CONST}, or {@link Token#LET}
*/
public void setNodeType(int nodeType) {
if (nodeType != Token.VAR
&& nodeType != Token.CONST
&& nodeType != Token.LET)
throw new IllegalArgumentException("invalid node type");
setType(nodeType);
}
示例4: setType
/**
* Sets the node type and returns this node.
* @throws IllegalArgumentException if {@code declType} is invalid
*/
@Override
public org.mozilla.javascript.Node setType(int type) {
if (type != Token.VAR
&& type != Token.CONST
&& type != Token.LET)
throw new IllegalArgumentException("invalid decl type: " + type);
return super.setType(type);
}
示例5: setDeclType
/**
* Sets symbol declaration type
*/
public void setDeclType(int declType) {
if (!(declType == Token.FUNCTION
|| declType == Token.LP
|| declType == Token.VAR
|| declType == Token.LET
|| declType == Token.CONST))
throw new IllegalArgumentException("Invalid declType: " + declType);
this.declType = declType;
}
示例6: hasSideEffects
@Override
public boolean hasSideEffects()
{
switch (getType()) {
case Token.ASSIGN:
case Token.ASSIGN_ADD:
case Token.ASSIGN_BITAND:
case Token.ASSIGN_BITOR:
case Token.ASSIGN_BITXOR:
case Token.ASSIGN_DIV:
case Token.ASSIGN_LSH:
case Token.ASSIGN_MOD:
case Token.ASSIGN_MUL:
case Token.ASSIGN_RSH:
case Token.ASSIGN_SUB:
case Token.ASSIGN_URSH:
case Token.BLOCK:
case Token.BREAK:
case Token.CALL:
case Token.CATCH:
case Token.CATCH_SCOPE:
case Token.CONST:
case Token.CONTINUE:
case Token.DEC:
case Token.DELPROP:
case Token.DEL_REF:
case Token.DO:
case Token.ELSE:
case Token.ENTERWITH:
case Token.ERROR: // Avoid cascaded error messages
case Token.EXPORT:
case Token.EXPR_RESULT:
case Token.FINALLY:
case Token.FUNCTION:
case Token.FOR:
case Token.GOTO:
case Token.IF:
case Token.IFEQ:
case Token.IFNE:
case Token.IMPORT:
case Token.INC:
case Token.JSR:
case Token.LABEL:
case Token.LEAVEWITH:
case Token.LET:
case Token.LETEXPR:
case Token.LOCAL_BLOCK:
case Token.LOOP:
case Token.NEW:
case Token.REF_CALL:
case Token.RETHROW:
case Token.RETURN:
case Token.RETURN_RESULT:
case Token.SEMI:
case Token.SETELEM:
case Token.SETELEM_OP:
case Token.SETNAME:
case Token.SETPROP:
case Token.SETPROP_OP:
case Token.SETVAR:
case Token.SET_REF:
case Token.SET_REF_OP:
case Token.SWITCH:
case Token.TARGET:
case Token.THROW:
case Token.TRY:
case Token.VAR:
case Token.WHILE:
case Token.WITH:
case Token.WITHEXPR:
case Token.YIELD:
return true;
default:
return false;
}
}
示例7: hasSideEffects
public boolean hasSideEffects()
{
switch (getType()) {
case Token.ASSIGN:
case Token.ASSIGN_ADD:
case Token.ASSIGN_BITAND:
case Token.ASSIGN_BITOR:
case Token.ASSIGN_BITXOR:
case Token.ASSIGN_DIV:
case Token.ASSIGN_LSH:
case Token.ASSIGN_MOD:
case Token.ASSIGN_MUL:
case Token.ASSIGN_RSH:
case Token.ASSIGN_SUB:
case Token.ASSIGN_URSH:
case Token.BLOCK:
case Token.BREAK:
case Token.CALL:
case Token.CATCH:
case Token.CATCH_SCOPE:
case Token.CONST:
case Token.CONTINUE:
case Token.DEC:
case Token.DELPROP:
case Token.DEL_REF:
case Token.DO:
case Token.ELSE:
case Token.ENTERWITH:
case Token.ERROR: // Avoid cascaded error messages
case Token.EXPORT:
case Token.EXPR_RESULT:
case Token.FINALLY:
case Token.FUNCTION:
case Token.FOR:
case Token.GOTO:
case Token.IF:
case Token.IFEQ:
case Token.IFNE:
case Token.IMPORT:
case Token.INC:
case Token.JSR:
case Token.LABEL:
case Token.LEAVEWITH:
case Token.LET:
case Token.LETEXPR:
case Token.LOCAL_BLOCK:
case Token.LOOP:
case Token.NEW:
case Token.REF_CALL:
case Token.RETHROW:
case Token.RETURN:
case Token.RETURN_RESULT:
case Token.SEMI:
case Token.SETELEM:
case Token.SETELEM_OP:
case Token.SETNAME:
case Token.SETPROP:
case Token.SETPROP_OP:
case Token.SETVAR:
case Token.SET_REF:
case Token.SET_REF_OP:
case Token.SWITCH:
case Token.TARGET:
case Token.THROW:
case Token.TRY:
case Token.VAR:
case Token.WHILE:
case Token.WITH:
case Token.WITHEXPR:
case Token.YIELD:
return true;
default:
return false;
}
}
示例8: hasSideEffects
@Override
public boolean hasSideEffects()
{
switch (getType()) {
case Token.ASSIGN:
case Token.ASSIGN_ADD:
case Token.ASSIGN_BITAND:
case Token.ASSIGN_BITOR:
case Token.ASSIGN_BITXOR:
case Token.ASSIGN_DIV:
case Token.ASSIGN_LSH:
case Token.ASSIGN_MOD:
case Token.ASSIGN_MUL:
case Token.ASSIGN_RSH:
case Token.ASSIGN_SUB:
case Token.ASSIGN_URSH:
case Token.BLOCK:
case Token.BREAK:
case Token.CALL:
case Token.CATCH:
case Token.CATCH_SCOPE:
case Token.CONST:
case Token.CONTINUE:
case Token.DEC:
case Token.DELPROP:
case Token.DEL_REF:
case Token.DO:
case Token.ELSE:
case Token.ENTERWITH:
case Token.ERROR: // Avoid cascaded error messages
case Token.EXPORT:
case Token.EXPR_RESULT:
case Token.FINALLY:
case Token.FUNCTION:
case Token.FOR:
case Token.GOTO:
case Token.IF:
case Token.IFEQ:
case Token.IFNE:
case Token.IMPORT:
case Token.INC:
case Token.JSR:
case Token.LABEL:
case Token.LEAVEWITH:
case Token.LET:
case Token.LETEXPR:
case Token.LOCAL_BLOCK:
case Token.LOOP:
case Token.NEW:
case Token.REF_CALL:
case Token.RETHROW:
case Token.RETURN:
case Token.RETURN_RESULT:
case Token.SEMI:
case Token.SETELEM:
case Token.SETELEM_OP:
case Token.SETNAME:
case Token.SETPROP:
case Token.SETPROP_OP:
case Token.SETVAR:
case Token.SET_REF:
case Token.SET_REF_OP:
case Token.SWITCH:
case Token.TARGET:
case Token.THROW:
case Token.TRY:
case Token.VAR:
case Token.WHILE:
case Token.WITH:
case Token.WITHEXPR:
case Token.YIELD:
return true;
default:
return false;
}
}
示例9: findFeaturePathsUnder
protected static Set<String> findFeaturePathsUnder(Node node, List<String> pathSoFar) {
Set<String> resultSoFar = new TreeSet<String>();
switch (node.getType()) {
case Token.NAME: // e.g. the x in x + 42
if (pathSoFar != null) {
pathSoFar.add(node.getString());
} else {
resultSoFar.add(node.getString());
}
break;
case Token.STRING:
if (pathSoFar != null) {
pathSoFar.add(node.getString());
}
break;
case Token.GETPROP: // e.g. foo.bar
boolean topLevel = pathSoFar == null;
if (topLevel) {
pathSoFar = new ArrayList<String>();
}
for (Node child = node.getFirstChild(); child != null; child = child.getNext()) {
resultSoFar.addAll(findFeaturePathsUnder(child, pathSoFar));
}
if (topLevel) {
resultSoFar.add(getPathString(pathSoFar));
}
return resultSoFar;
case Token.SETNAME: // Left-hand variable being written: x in x = y;
case Token.VAR:
case Token.CALL:
// ignore the left side and process the right side now
resultSoFar.addAll(findFeaturePathsWithinRightSide(node));
break;
default:
break;
}
// Now do the nested subexpressions, for all cases that said break instead of return.
for (Node child = node.getFirstChild(); child != null; child = child.getNext()) {
resultSoFar.addAll(findFeaturePathsUnder(child, pathSoFar));
}
return resultSoFar;
}
示例10: isVar
/**
* Returns true if this is a {@code var} (not
* {@code const} or {@code let}) declaration.
* @return true if {@code declType} is {@link Token#VAR}
*/
public boolean isVar() {
return type == Token.VAR;
}