Search in sources :

Example 1 with ELGenerator

use of org.eclipse.jst.jsp.core.internal.java.jspel.ELGenerator 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()"));
}
Also used : IStructuredDocumentRegion(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion) ELGenerator(org.eclipse.jst.jsp.core.internal.java.jspel.ELGenerator) JSPELParser(org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser) HashMap(java.util.HashMap) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel) ASTExpression(org.eclipse.jst.jsp.core.internal.java.jspel.ASTExpression)

Aggregations

HashMap (java.util.HashMap)1 ASTExpression (org.eclipse.jst.jsp.core.internal.java.jspel.ASTExpression)1 ELGenerator (org.eclipse.jst.jsp.core.internal.java.jspel.ELGenerator)1 JSPELParser (org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser)1 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)1 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)1