Consider the following:
package test
class Test {
static class Foo {
String someString = 'foo'
String other = 'other'
}
static class Bar {
String someString = 'bar'
Foo foo = new Foo()
void doSomething() {
foo.with {
println "someString inside with closure = $someString"
println "other inside with closure = $other"
}
}
}
static main(args) {
Bar b = new Bar()
println "b.someString = $b.someString"
println "b.foo.someString = $b.foo.someString"
b.doSomething()
}
}
Run the main method. You'll see that doSomething() prints foo, i.e. the someString reference within the with closure refers to Foo.someString. However, Greclipse thinks that is Bar.someString, as you can see by all of these facilities:
- F3 over
$someString
- Ctrl+Click over
$someString
- "mark occurences" highlighting when you select
$someString
Maybe it's just a problem of "precedence" between this/owner and delegate properties, because Greclipse behaves correctly with the other property (which is defined only in Foo class).
Consider the following:
Run the main method. You'll see that
doSomething()printsfoo, i.e. thesomeStringreference within thewithclosure refers toFoo.someString. However, Greclipse thinks that isBar.someString, as you can see by all of these facilities:$someString$someString$someStringMaybe it's just a problem of "precedence" between this/owner and delegate properties, because Greclipse behaves correctly with the
otherproperty (which is defined only inFooclass).