* @param silent
* @return
* @throws WinkUnmanagedSyntaxException
*/
public static ParseObject resolveParseObject(final AstNode n, final boolean silent) throws WinkUnmanagedSyntaxException {
ParseObject result = null;
final int type = n.getType();
try {
if (type == Token.SETPROP || type == Token.SETELEM && SetProp.isValidSetProp(n)) {
if (type == Token.SETPROP) {
result = new SetProp(n);
} else if (type == Token.SETELEM) {
result = new SetElem(n);
}
} else if (type == Token.SETNAME) {
result = new SetName(n);
} else if (type == Token.OBJECTLIT) {
result = new ObjectLit(n);
} else if (type == Token.FUNCTION) {
result = new Function(n);
} else if (type == Token.CALL && Call.isValidCall(n)) {
result = Call.getAppropriateCall(n);
} else if (type == Token.EXPR_RESULT && ExprResultCall.isValidCall(n)) {
result = new ExprResultCall(n);
} else {
result = new ParseObject(n);
}
} catch (final WinkUnmanagedSyntaxException e) {
if (silent) {
result = new ParseObject(n);
} else {
if (Constants.failOnUnmanagedSyntax) {
throw e;
} else if (Constants.warnOnUnmanagedSyntax) {
System.err.println(e.getMessage());
result = new ParseObject(n);
}
}
}
return result;