[SOLVED] How to use groovy as script extension?

已完成

I want to do a code generator based on a table, but i can't find any tutorial or example to archieve this:

Right click on "Table_Name" -> Scripted Extensions -> MyScript.groovy

Any documentation?

1

I learned how to do it in the hard way.

My script generates an POJO to be used by the ActiveJdbc ORM framework working with Oracle databases.

For anyone that needs a simple example script: https://github.com/uliss3s/utils/blob/master/scripts/groovy/ActiveJdbcOraclePojoGenerator.groovy

1

Thank you very much for this example. 

Code generation options could be a very powerful feature of Datagrip. Shame that it is so poorly documented by Jetbrains. 

1

I think i'm starting to get it, but i still need some documentation. Bellow is how i'm doing. If there is something i could do better, please, say it.

NEWLINE = System.getProperty("line.separator")

def getJavaType(dataType) {
//TODO
}

SELECTION.each {
if (it.class.canonicalName == "com.intellij.database.psi.DbTableImpl") {
columns = it.getDbChildren(com.intellij.database.psi.DbColumn.class, com.intellij.database.model.ObjectKind.COLUMN)
buffer = ""
columns.each {
buffer += it.name + " / " + it.getDataType().toString() + NEWLINE
}
CLIPBOARD.set(buffer)
}
}
0

still the case.. 2023 now.. come one guys.. get this right

0
Thank you all for your feedback.

This has been taken into consideration, and our team is currently discussing how we can improve this guide section and make it easier to understand, accompanied with examples.
0

请先登录再写评论。