use of org.eclipse.jst.jsp.core.internal.java.jspel.ASTExpression in project webtools.sourceediting by eclipse.
the class JSPELContentAssistProcessor method getInvocation.
protected ASTFunctionInvocation getInvocation(int relativePosition, String elText) {
FindFunctionInvocationVisitor visitor = new FindFunctionInvocationVisitor(relativePosition);
JSPELParser parser = JSPELParser.createParser(elText);
try {
ASTExpression expression = parser.Expression();
return (ASTFunctionInvocation) expression.jjtAccept(visitor, null);
} catch (ParseException e) {
/* parse exception = no completion */
}
return (null);
}
use of org.eclipse.jst.jsp.core.internal.java.jspel.ASTExpression in project webtools.sourceediting by eclipse.
the class JSPELTranslationTest method testBooleanMethods.
public void testBooleanMethods() throws ParseException {
final String content = "pageContext.request.secure";
final IStructuredModel model = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(ContentTypeIdForJSP.ContentTypeID_JSP);
final IStructuredDocument document = model.getStructuredDocument();
document.set("${" + content + "}");
final JSPELParser parser = JSPELParser.createParser(content);
ASTExpression expression = parser.Expression();
IStructuredDocumentRegion currentNode = document.getFirstStructuredDocumentRegion();
StringBuffer result = new StringBuffer();
new ELGenerator().generate(expression, currentNode, result, new HashMap(), document, currentNode, 0, content.length());
int index = result.indexOf("((HttpServletRequest)");
assertTrue("return of HTTPServletRequest was not found", index >= 0);
assertTrue("pageContext.request.secure is not using the boolean accessor", result.substring(index).startsWith("((HttpServletRequest)pageContext.getRequest()).isSecure()"));
}
Aggregations