本文整理汇总了Java中org.mozilla.javascript.ast.FunctionNode.setJsDocNode方法的典型用法代码示例。如果您正苦于以下问题:Java FunctionNode.setJsDocNode方法的具体用法?Java FunctionNode.setJsDocNode怎么用?Java FunctionNode.setJsDocNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mozilla.javascript.ast.FunctionNode
的用法示例。
在下文中一共展示了FunctionNode.setJsDocNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: arrowFunction
import org.mozilla.javascript.ast.FunctionNode; //导入方法依赖的package包/类
private AstNode arrowFunction(AstNode params) throws IOException {
int baseLineno = ts.lineno; // line number where source starts
int functionSourceStart = params != null ? params.getPosition() : -1; // start of "function" kwd
FunctionNode fnNode = new FunctionNode(functionSourceStart);
fnNode.setFunctionType(FunctionNode.ARROW_FUNCTION);
fnNode.setJsDocNode(getAndResetJsDoc());
// Would prefer not to call createDestructuringAssignment until codegen,
// but the symbol definitions have to happen now, before body is parsed.
Map<String, Node> destructuring = new HashMap<String, Node>();
Set<String> paramNames = new HashSet<String>();
PerFunctionVariables savedVars = new PerFunctionVariables(fnNode);
try {
if (params instanceof ParenthesizedExpression) {
fnNode.setParens(0, params.getLength());
AstNode p = ((ParenthesizedExpression)params).getExpression();
if (!(p instanceof EmptyExpression)) {
arrowFunctionParams(fnNode, p, destructuring, paramNames);
}
} else {
arrowFunctionParams(fnNode, params, destructuring, paramNames);
}
if (!destructuring.isEmpty()) {
Node destructuringNode = new Node(Token.COMMA);
// Add assignment helper for each destructuring parameter
for (Map.Entry<String, Node> param: destructuring.entrySet()) {
Node assign = createDestructuringAssignment(Token.VAR,
param.getValue(), createName(param.getKey()));
destructuringNode.addChildToBack(assign);
}
fnNode.putProp(Node.DESTRUCTURING_PARAMS, destructuringNode);
}
fnNode.setBody(parseFunctionBody(FunctionNode.ARROW_FUNCTION, fnNode));
fnNode.setEncodedSourceBounds(functionSourceStart, ts.tokenEnd);
fnNode.setLength(ts.tokenEnd - functionSourceStart);
} finally {
savedVars.restore();
}
if (fnNode.isGenerator()) {
reportError("msg.arrowfunction.generator");
return makeErrorNode();
}
fnNode.setSourceName(sourceURI);
fnNode.setBaseLineno(baseLineno);
fnNode.setEndLineno(ts.lineno);
return fnNode;
}