rewrite icon indicating copy to clipboard operation
rewrite copied to clipboard

XMLParser for jsp only works for jsp directives, but not for all jsp syntaxes

Open Jenson3210 opened this issue 1 year ago • 6 comments

According to this link and other sources online, there are multiple tags possible in jsp.

It seems the parser is failing to handle different tags than the tested directive.

See unit test added as reference using 2 examples from provided link.

Caused by: org.openrewrite.xml.XmlParsingException: Syntax error in scriptlet.jsp at line 4:5 no viable alternative at input '<%'.
	at org.openrewrite.xml.XmlParser$ForwardingErrorListener.syntaxError(XmlParser.java:120)
	... 123 more
Caused by: org.antlr.v4.runtime.NoViableAltException
	at org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:2031)
	at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:470)
	at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:396)
	at org.openrewrite.xml.internal.grammar.XMLParser.element(XMLParser.java:1060

Jenson3210 avatar Jul 05 '24 21:07 Jenson3210

Added a test case that shows the failure.

Jenson3210 avatar Jul 05 '24 21:07 Jenson3210

Thanks! I think this might be similar to this issue right?

  • https://github.com/openrewrite/rewrite/issues/4240

We added some basic JSP parser support in March via

  • https://github.com/openrewrite/rewrite/pull/4075

Looks like we'd need to extend that to cover additional syntax.

timtebeek avatar Jul 05 '24 21:07 timtebeek

Ah! Now I know where we get these loggings from! Most likely related indeed! Did not consider this one to be the same as it was talking about mod cli.

Sorry for the double!

Jenson3210 avatar Jul 05 '24 21:07 Jenson3210

found https://github.com/wjase/jsp-parser/tree/master/src/main/antlr4/com/cybernostics/jsp/parser which could be usefull for a bases for the antlr processing

Jenson3210 avatar Jul 09 '24 12:07 Jenson3210

found https://github.com/wjase/jsp-parser/tree/master/src/main/antlr4/com/cybernostics/jsp/parser which could be usefull for a bases for the antlr processing

Nice find! One of those times where "last changed 7 years ago" feels right, and not problematic. 😅 Are you exploring an extension to our Antlr spec then?

timtebeek avatar Jul 09 '24 12:07 timtebeek

Well, if I can't sleep I will have a look at this. It's haunting me 😅

But feel free to assign someone if there is no progress here. Started several times already and rollend back. It's not a piece of cake

Jenson3210 avatar Jul 09 '24 12:07 Jenson3210

Here's a proposed extension to our XML handling to support more JSP elements:

  • https://github.com/openrewrite/rewrite/pull/6054

timtebeek avatar Sep 19 '25 10:09 timtebeek