use of org.eclipse.jst.jsp.core.internal.java.jspel.TokenMgrError 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);
}
}
}
use of org.eclipse.jst.jsp.core.internal.java.jspel.TokenMgrError 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);
}
}
}
Aggregations