groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerald Wiltse <jerrywil...@gmail.com>
Subject Question about GroovyClassLoader, Imoprt, and ContentAssist
Date Fri, 18 Dec 2015 19:12:13 GMT
This is my first post to the list. If it's inappropriate for questions like
this, please let me know.

Goal: I want to define groovy classes in .groovy files as part of a
package, but without ever needing to compile them. Then, I want to define
groovy scripts in the same package, import the class definitions from the
nearby .groovy files, and execute the script... all without compilation (of
the other groovy files with classes).

Problem, This appears to be possible using GroovyClassLoader() (and several
people have posted how-tos). However, the problem I have that nobody else
seems to reference is that this strategy means that content assist will
never be able to identify your classes and methods, and your code will be
full of underlines, and receive no error checking. (eclipse and otherwise i
would think).

You might say "Thats just a side effect of using such a dynamic feature,
how would eclipse be able to know?", but consider the following:

As I was building my project, I was creating the scripts and the classes in
the package just like normal a program. When I add my import statements for
my custom classes, Eclipse recognizes everything and content assist is
happy. However, despite content assist being satisfied, it hits a snag when
I try to execute a script because eclipse returns: unable to resolve class
(presumably because it's still only a groovy file, and not compiled to a
class file).

So, I looked around and it looks like I have to comment out the import
statement, and then use groovyclassloader to parse the groovy file instead.
However, this has the negative side effect of breaking content assist.

Question: Are my conclusions above all basically correct?

Suggestion: Is there any known way to have content-assist work along-side
with GroovyClassLoader? Maybe some way to tell it to ignore failed imports
or something?


Gerald R. Wiltse
jerrywiltse@gmail.com
248-893-9110 (c)
888-248-7095 (p)
888-272-6046 (f)

Mime
View raw message