Groovy Support - @Bindable-Annotation

Answered

Hey Guys,

i have a strange bug with Intellij IDE in combination with Groovy annotations. I would like to annotate a groovy-class with @Bindable. According to the javadoc of the annotation it generates a getter and setter for each property and the setter will trigger a propertyChangeEvent when called. Furthermore the annotation generates a propertyChangeSupport-Attribute and methods to add and remove propertyChangeListener.

Here comes the strange point: after compiling the groovy-class, the idea recognises the getter- and setter-methods of my attributes and even suggests them in the code-completion (great that far). But Idea does not notice the addPropertyChangeListener-Methode. If i call it anyway and recompile my project, everything works fine and if i decompile the .class files that were generated from the compiler my groovy-class contains the necessary methods for the propertyChangeListeners.

Although my little program works  as intended Intellij IDE always marks the line red and says "cannot resolve method addPropertyChangeListener()...".

In real development i cannot work with false-errors in my code. Even when it's just the IDE which dosen't work as intended. I fear it would lead to real errors that are not found because they could be hidden between the 'false-positives'..

I have tested it both with Intellij 15 Community Edition and Intellij 13 Ultimate Edition. I have tested both groovy-all 2.4.5 and groovy-all 2.4.6 . In all combinations the problem exists.

Do you have any ideas how to bring Intellij to recognise the add/remove propertyChangeListener methods?

Thanks a lot for your help

 

My little test -program:

Lot.groovy:

package com.company

import groovy.beans.Bindable

@Bindable
class Lot{
String lotName;
}



package com.company;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

public class Main {

public static void main(String[] args) {
Lot l = new Lot();
l.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
System.out.println(l.getLotName());
}
});
l.setLotName("Event fired");
}
}

 

 

1 comment
Comment actions Permalink

Thanks for submitting an issue at https://youtrack.jetbrains.com/issue/IDEA-152988. Our developers will investigate it.

0

Please sign in to leave a comment.