GDSL: how to let new fake method resolve to some part of code
I'm new to IDEA development, but trying to develop better IDE support for Geb testing framework using GDSL. Geb is Groovy pased and basically, it just introduces some context-dependent magic like
class MyPage extends Page {
static content = {
testContent { "something" }
}
void testMethod() {
println "something else"
}
}
and then it can be used
to MyPage
println testContent // prints "something"
testMethod() // prints "something else"
without using typed local variable or with-block.
I managed to scan PSI tree to get previously activated page, found necessary elements there and contributed them using `property` and `method` methods. They are now highlighted and their types are recognized.
But it is still not perfect, cause now Ctrl+Click does nothing, the fake methods are created, but they don't point to original places where these elements are actually defined.
I looked through IDEA source code and it seems that `property` and `method` methods in GDSL accept only the following attributes: `name`, `type`, `params`, `doc`, `docUrl`, `isStatic`. Also, `doc` and `docUrl` must be String_s and I did not understand how they are used. So there is no obvious way to pass there something like `file` and `line` or PsiElement...
I also tried to execute `place.reference.bindToElement(PsiElement)` for the corresponding places, but that is recognized as a write action and is forbidden.
Is there any way to make Ctrl+Click at newly generated method/property navigate to some specific place in code?
Please sign in to leave a comment.
Pushed my code to GitHub https://github.com/vbolshutkin/geb-gdsl
Found the solution. Turned out, property method supports only following keys: `name`, `type`, `isStatic`, `doc`, `docUrl` . It is not possible to tweak anything there.
But method method is more flexible. It supports `name`, `type`, `isStatic`,`params`, `doc`, `docUrl`,`constructor`,`bindsTo`,`containingClass`, The last two are exactly what I was looking for.
Unfortunately, there is no information about that in documentation and GDSL-related blog, so I had to download IDEA sources.
Also, I did not understand how do `doc`, `docUrl` parameters work. It definitely should be documented better