Search in sources :

Example 1 with ASTExpression

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);
}
Also used : FindFunctionInvocationVisitor(org.eclipse.jst.jsp.core.internal.java.jspel.FindFunctionInvocationVisitor) JSPELParser(org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser) ASTFunctionInvocation(org.eclipse.jst.jsp.core.internal.java.jspel.ASTFunctionInvocation) ParseException(org.eclipse.jst.jsp.core.internal.java.jspel.ParseException) ASTExpression(org.eclipse.jst.jsp.core.internal.java.jspel.ASTExpression)

Example 2 with ASTExpression

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()"));
}
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

ASTExpression (org.eclipse.jst.jsp.core.internal.java.jspel.ASTExpression)2 JSPELParser (org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser)2 HashMap (java.util.HashMap)1 ASTFunctionInvocation (org.eclipse.jst.jsp.core.internal.java.jspel.ASTFunctionInvocation)1 ELGenerator (org.eclipse.jst.jsp.core.internal.java.jspel.ELGenerator)1 FindFunctionInvocationVisitor (org.eclipse.jst.jsp.core.internal.java.jspel.FindFunctionInvocationVisitor)1 ParseException (org.eclipse.jst.jsp.core.internal.java.jspel.ParseException)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