You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The J.Erroneous support in the Java parser allows the parser to create J.Erroneous nodes whenever some illegal Java syntax is encountered. This however only works when the J.Erroneous type is compatible with the receiving property. For property values wrapped in something like a JRightPadded this will not be checked by the JVM due to Java's type erasure. So for the following example it would be illegal to return a J.Erroneous instead of a J.Import as the parser currently does:
packagefoo;
import${hello}.client;
classFoo {}
A source file like this would not compile, but it might appear in a src/main/resources folder as in this example.
One solution could be to add a Class<? extends J> parameter to the convert() method and then the method would throw an exception whenever the result it returns isn't compatible with that type. As a result the parser would then return a ParseError instead of a broken LST model.
The
J.Erroneous
support in the Java parser allows the parser to createJ.Erroneous
nodes whenever some illegal Java syntax is encountered. This however only works when theJ.Erroneous
type is compatible with the receiving property. For property values wrapped in something like aJRightPadded
this will not be checked by the JVM due to Java's type erasure. So for the following example it would be illegal to return aJ.Erroneous
instead of aJ.Import
as the parser currently does:A source file like this would not compile, but it might appear in a
src/main/resources
folder as in this example.One solution could be to add a
Class<? extends J>
parameter to theconvert()
method and then the method would throw an exception whenever the result it returns isn't compatible with that type. As a result the parser would then return aParseError
instead of a broken LST model.See also Slack discussion.
The text was updated successfully, but these errors were encountered: