问题
The Geb documentation says that IDEA supports Geb via the Groovy plugin (http://www.gebish.org/manual/current/ide-and-typing.html#intellij_idea_support). In particular, it says " IntelliJ IDEA (since version 12) has special support for authoring Geb code. This is built in to the Groovy support; no additional installations are required." However, I'm not seeing this in IDEA 13.x or 14. Everything works and runs, but I get no code completion or hinting for any content DSL definitions defined in my Pages. Also, my content DSL references show with the "underlined" formatting used to indicate unknown/dynamic/runtime-only Groovy elements. Since the Geb docs specifically say it should provide this, I'm trying to figure out if I'm missing something?
回答1:
You will only get content definition hinting inside page definitions/classes or when IntelliJ knows the type of your page. There will be no content definition hints if you don't track page types because IntelliJ can't figure out what the current page type is and won't be able to provide autocompletion.
class MyPage extends Page {
static content {
links { $("a") }
fistLink { links.first() } //Intellij will understand what links are here
}
int getLinksCount() {
links.size() // IntelliJ will understand what links are here
}
}
class MySpec extends GebSpec {
...
to(MyPage)
myPage.links // Intellij will not understand/autocomplete links here
...
def myPage = to(MyPage)
myPage.links // Intellij will understand/autocomplete links here
...
}
Also, from what I remember, this only works in the Ultimate and not the Community Edition.
来源:https://stackoverflow.com/questions/30220591/geb-authoring-support-within-intellij-idea