Description
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:
package foo;
import ${hello}.client;
class Foo {}
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.
See also Slack discussion.
Metadata
Assignees
Labels
Type
Projects
Status
No status
Activity