I found this question Eclipse Groovy and autocompletion and am experiencing the same issue, however, it is almost three years hence and I am using the current version of the Groovy Eclipse plugin, and there do not appear to be any syntax errors that would be confusing ANTLR.
I also tried using the Groovy/Grails Tool Suite, and got the same results.
I have mocked up a simple test case under which the content assist works for Groovy objects' methods, and for Java objects' static members, but not Java objects' methods.
The Groovy class:
package test_groovy
import test_groovy.FooJava
class FooGroovy
{
def fooJava = [2, "baz"] as FooJava
def x = 4
def FooGroovy()
{
// empty constructor
}
def useFooJava()
{
// only displays Groovy methods, not the java ones
def str = fooJava.getStr()
println "str: ${str}"
// static members like this *can* be found via content assist
def str2 = FooJava.FOO_STR
println "str2: ${str2}"
// This is also not found via content assist
def str3 = fooJava.dumpToStr()
println "str3: ${str3}"
}
def fooBar()
{
return x + 3
}
static void main(def args)
{
def fooGroovy = [] as FooGroovy
// Groovy object methods can be found via content assist
def res = fooGroovy.fooBar()
println "res: ${res}"
fooGroovy.useFooJava()
}
}
The Java class:
package test_groovy;
public class FooJava
{
private long bar;
private String str;
public static final String FOO_STR = "foo";
public FooJava(long bar, String str)
{
super();
this.bar = bar;
this.str = str;
}
public long getBar()
{
return bar;
}
public void setBar(long bar)
{
this.bar = bar;
}
public String getStr()
{
return str;
}
public void setStr(String str)
{
this.str = str;
}
public String dumpToStr()
{
return new String("Str: " + str + ", bar: " + bar);
}
}
I am using Eclipse Kepler Service Release 2, Groovy compiler 2.0.7 and Groovy Eclipse plugin version 2.8.0.xx-20130703-1600-e43-RELEASE.
Under the Java > Editor > Content Assist > Advanced preferences menu, I have made sure all the Java options are checked off in addition to Groovy Content (Java Non-Type, Java, Java type Proposals).
Since this does seem to work in general for some, I am wondering what I could be missing here that would allow content assist to work for Java object methods. Thanks.