Java interop #1: synthetic accessors for 'Groovy bean properties'
GRVY-314 was marked as "Won't Fix".
However, I still think that the current behaviour is wrong.
I'll try to explain why, breaking the observed problem into two parts.
First part
-
Java module has Groovy facet and contains a groovy class.
Groovy code (GroovyBean.groovy):
-
class GroovyBean {
String someString;
}
-
Java client calling above groovy class (JavaClient.java):
-
public class JavaClient {
public static void main(String[] args) {
GroovyBean b = new GroovyBean();
b.setSomeString("test"); // should be "green" but is "red"
}
}
-
Observed behavior:
1) Code is red: In the Java code, method "setSomeString" is marked as unresolved.
2) Now compile the groovy class, attach the compiled version as a library
and delete the original source. Result: code is green.
For 'Groovy properties', the groovy PSI should include a getter and setter,
as described here:
http://groovy.codehaus.org/Groovy+Beans
(section "Property and field rules")
-tt
Please sign in to leave a comment.
It is indeed a bug, though your conslusions about groovy psi containing accessors is not necessary.
Hello Eugene,
Is there a ticket already in JIRA? Then I can add myself as 'watcher'.
-tt
Hello Eugene,
Hmm, would it not make sense if 'synthetic' accessors were present in the
PSI?
Then a lot of current plugins that work with getters/setters of a (Java)
class would transparently work with groovy classes (containing such special
'groovy properties').
-tt
I'm not sure they would like synthetic psi. What it would certainly cause is the performance penalty.
No, please submit one.
No, please submit one.
One concrete example would be spring facet from Selena.
As far as I can see property resolving is based on com.intellij.psi.util.PropertyUtil.
At the moment no properties are returned of course, for the reason mentioned
in this thread. :)
-tt