Search in sources :

Example 1 with ParseException

use of org.eclipse.jst.jsp.core.internal.java.jspel.ParseException in project webtools.sourceediting by eclipse.

the class JSPELValidator method validateELContent.

protected void validateELContent(ITextRegionCollection container, ITextRegion elOpenRegion, Iterator elRegions, IReporter reporter, IFile file) {
    int contentStart = elOpenRegion.getEnd();
    int contentDocStart = container.getEndOffset(elOpenRegion);
    int contentLength = container.getLength();
    int regionCount = 0;
    ITextRegion elRegion = null;
    /* Find the EL closing region, otherwise the last region will be used to calculate the EL content text */
    while (elRegions != null && elRegions.hasNext() && (regionCount++ < MAX_REGIONS)) {
        elRegion = (ITextRegion) elRegions.next();
        if (elRegion.getType() == DOMJSPRegionContexts.JSP_EL_CLOSE)
            break;
    }
    String elText = container.getFullText().substring(contentStart, (elRegion != null) ? elRegion.getStart() : (contentLength - 1));
    JSPELParser elParser = JSPELParser.createParser(elText);
    try {
        elParser.Expression();
    } catch (ParseException e) {
        int sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_EL_SYNTAX);
        if (sev != ValidationMessage.IGNORE) {
            Token curTok = e.currentToken;
            int problemStartOffset = contentDocStart + curTok.beginColumn;
            Message message = new LocalizedMessage(sev, JSPCoreMessages.JSPEL_Syntax);
            message.setOffset(problemStartOffset);
            message.setLength(curTok.endColumn - curTok.beginColumn + 1);
            message.setTargetObject(file);
            reporter.addMessage(fMessageOriginator, message);
        }
    } catch (TokenMgrError te) {
        int sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_EL_LEXER);
        if (sev != ValidationMessage.IGNORE) {
            Message message = new LocalizedMessage(IMessage.NORMAL_SEVERITY, JSPCoreMessages.JSPEL_Token);
            message.setOffset(contentDocStart);
            message.setLength(contentLength);
            message.setTargetObject(file);
            reporter.addMessage(fMessageOriginator, message);
        }
    }
}
Also used : ValidationMessage(org.eclipse.wst.sse.core.internal.validate.ValidationMessage) IMessage(org.eclipse.wst.validation.internal.provisional.core.IMessage) Message(org.eclipse.wst.validation.internal.core.Message) JSPELParser(org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) Token(org.eclipse.jst.jsp.core.internal.java.jspel.Token) TokenMgrError(org.eclipse.jst.jsp.core.internal.java.jspel.TokenMgrError) ParseException(org.eclipse.jst.jsp.core.internal.java.jspel.ParseException)

Example 2 with ParseException

use of org.eclipse.jst.jsp.core.internal.java.jspel.ParseException 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 3 with ParseException

use of org.eclipse.jst.jsp.core.internal.java.jspel.ParseException in project webtools.sourceediting by eclipse.

the class JSPELValidator method validateXMLNode.

protected void validateXMLNode(ITextRegionCollection container, ITextRegion region, IReporter reporter, IFile file) {
    String elText = container.getText(region);
    JSPELParser elParser = JSPELParser.createParser(elText);
    int contentStart = container.getStartOffset(region);
    int contentLength = container.getLength();
    try {
        elParser.Expression();
    } catch (ParseException e) {
        int sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_EL_SYNTAX);
        if (sev != ValidationMessage.IGNORE) {
            Token curTok = e.currentToken;
            int problemStartOffset = contentStart + curTok.beginColumn;
            Message message = new LocalizedMessage(sev, JSPCoreMessages.JSPEL_Syntax);
            message.setOffset(problemStartOffset);
            message.setLength(curTok.endColumn - curTok.beginColumn + 1);
            message.setTargetObject(file);
            reporter.addMessage(fMessageOriginator, message);
        }
    } catch (TokenMgrError te) {
        int sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_EL_LEXER);
        if (sev != ValidationMessage.IGNORE) {
            Message message = new LocalizedMessage(IMessage.NORMAL_SEVERITY, JSPCoreMessages.JSPEL_Token);
            message.setOffset(contentStart);
            message.setLength(contentLength);
            message.setTargetObject(file);
            reporter.addMessage(fMessageOriginator, message);
        }
    }
}
Also used : ValidationMessage(org.eclipse.wst.sse.core.internal.validate.ValidationMessage) IMessage(org.eclipse.wst.validation.internal.provisional.core.IMessage) Message(org.eclipse.wst.validation.internal.core.Message) JSPELParser(org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser) Token(org.eclipse.jst.jsp.core.internal.java.jspel.Token) TokenMgrError(org.eclipse.jst.jsp.core.internal.java.jspel.TokenMgrError) ParseException(org.eclipse.jst.jsp.core.internal.java.jspel.ParseException)

Aggregations

JSPELParser (org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser)3 ParseException (org.eclipse.jst.jsp.core.internal.java.jspel.ParseException)3 Token (org.eclipse.jst.jsp.core.internal.java.jspel.Token)2 TokenMgrError (org.eclipse.jst.jsp.core.internal.java.jspel.TokenMgrError)2 ValidationMessage (org.eclipse.wst.sse.core.internal.validate.ValidationMessage)2 Message (org.eclipse.wst.validation.internal.core.Message)2 IMessage (org.eclipse.wst.validation.internal.provisional.core.IMessage)2 ASTExpression (org.eclipse.jst.jsp.core.internal.java.jspel.ASTExpression)1 ASTFunctionInvocation (org.eclipse.jst.jsp.core.internal.java.jspel.ASTFunctionInvocation)1 FindFunctionInvocationVisitor (org.eclipse.jst.jsp.core.internal.java.jspel.FindFunctionInvocationVisitor)1 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)1