cwong15 / freemarker-introspection

Classes to allow introspection of a Freemarker template
Apache License 2.0
3 stars 1 forks source link

ClassCastException in StringLiteralExpr.java:26 #2

Open oalekseev opened 4 years ago

oalekseev commented 4 years ago

for templates like this "'some text ${foo1} some text ${foo2} some text'"

java.lang.ClassCastException: java.lang.String cannot be cast to freemarker.core.TemplateElement

at freemarker.introspection.StringLiteralExpr.getDynamicValue(StringLiteralExpr.java:26)
at freemarker.introspection.variables.VariableFinder.visit(VariableFinder.java:239)
at freemarker.introspection.BaseExpr.accept(BaseExpr.java:62)
at freemarker.introspection.variables.VariableFinder.scanParams(VariableFinder.java:195)
at freemarker.introspection.variables.VariableFinder.visit(VariableFinder.java:117)
at freemarker.introspection.BaseElement.accept(BaseElement.java:83)
at freemarker.introspection.variables.VariableFinder.seek(VariableFinder.java:62)
oalekseev commented 4 years ago

this is a fix changes

freemarker.introspection.StringExpr StringExpr

freemarker.introspection.StringLiteralExpr StringLiteralExpr

freemarker.introspection.variables.VariableFinder (method void visit(Expr expr)) VariableFinder

And test for template "'some text ${foo1} some text ${foo2} some text'" freemarker.introspection.ExprParamsTests ExprParamsTests And add import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;