antlr / stringtemplate4

StringTemplate 4
http://www.stringtemplate.org
Other
956 stars 231 forks source link

Property getter broken #193

Closed generateui closed 4 years ago

generateui commented 7 years ago

Consider

class MyClass {
    private int amount;
    public int amount() { return amount; }
}

with template

Amount: <myClass.amount>

does not yield the amount value into my resulting templated file. However, if I change MyClass to

class MyClass {
    private int amount;
    public int getAmount() { return amount; }
}

(note the getAmount) it works. In other words, class.property does not map to myClass.property().

Since java projects exist which use the convention not to use prefixes (ANTLR v4.7 included), I suggest support for this. In my usecase, generating some java code from an ANTLR AST requires me to build an intermediate model, which is cumbersome, error-prone, less readable and harder to debug.

Clashsoft commented 4 years ago

See this FAQ page about Scala property naming conventions, perhaps you can find a workaround.

parrt commented 4 years ago

Hi. problem is that allow <o.f()> allows any code to be called, which is against ST design principles.