use of org.eclipse.wst.jsdt.core.dom.ExpressionStatement in project webtools.sourceediting by eclipse.
the class RunCodeHandler method getObjectLiteralField.
static ObjectLiteralField getObjectLiteralField(String source) {
String js = "x.prototype = {" + source + "}";
JavaScriptUnit jsu = getAST(js);
ExpressionStatement stmt = (ExpressionStatement) jsu.statements().get(0);
ObjectLiteral lit = (ObjectLiteral) ((Assignment) stmt.getExpression()).getRightHandSide();
ObjectLiteralField field = (ObjectLiteralField) lit.fields().get(0);
ASTNode node = ASTNode.copySubtree(jsu.getAST(), field);
return (ObjectLiteralField) node;
}
Aggregations