Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IntelliJ GroovyDSL script for whelktool #1287

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions whelktool/src/main/groovy/datatool/WhelkTool.gdsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* GroovyDSL script for whelktool
*
* i.e. IntelliJ autocompletion for stuff added to whelktool script context via javax.script.Bindings
*
* https://youtrack.jetbrains.com/articles/GROOVY-A-15796912
*/

package datatool

String ITEM = 'whelk.datatool.DocumentItem'
String DC = "Closure<$ITEM>"

def ctx = context(scope:scriptScope(), pathRegexp:'.*whelktool/scripts/.*')

contributor(ctx) {
property name:"scriptDir", type:String
property name:"baseUri", type:URI
method name:"asList", params:['':Object], type:List
method name:"create", params:['data':Map], type:ITEM
method name:"findCanonicalId", params:['id':String], type:String
// Seems like the only way to have optional arguments is to list all combinations
method name:"getAtPath", params:['item':Object, 'path':Iterable, 'defaultTo':Object], type:Object
method name:"getAtPath", params:['item':Object, 'path':Iterable], type:Object
method name:"getReportWriter", params:['reportName':String], type:PrintWriter
method name:"getWhelk", type:'whelk.Whelk'
method name:"incrementStats", params:['category':String, 'name':Object, 'example':Object]
method name:"incrementStats", params:['category':String, 'name':Object]
method name:"isInstanceOf", params:['entity':Map, 'baseType':String], type:boolean
method name:"load", params:['id':String], type:Map
method name:"queryDocs", params:['parameters':Map<String, List<String>>], type:Iterable<Map>
method name:"queryIds", params:['parameters':Map<String, List<String>>], type:Iterable<String>
method name:"script", params:['scriptPath':String], type:Closure
method name:"selectByCollection", params:['collection':String, 'process':DC, 'batchSize':int, 'silent':boolean], type:void
method name:"selectByCollection", params:['collection':String, 'process':DC, 'batchSize':int], type:void
method name:"selectByCollection", params:['collection':String, 'process':DC, 'silent':boolean], type:void
method name:"selectByCollection", params:['collection':String, 'process':DC], type:void
method name:"selectByIds", params:['ids':Collection<String>, 'process':DC, 'batchSize':int, 'silent':boolean], type:void
method name:"selectByIds", params:['ids':Collection<String>, 'process':DC, 'batchSize':int], type:void
method name:"selectByIds", params:['ids':Collection<String>, 'process':DC, 'silent':boolean], type:void
method name:"selectByIds", params:['ids':Collection<String>, 'process':DC], type:void
method name:"selectBySqlWhere", params:['whereClause':String, 'batchSize':int, 'silent':boolean, 'process':DC], type:void
method name:"selectBySqlWhere", params:['whereClause':String, 'batchSize':int, 'process':DC], type:void
method name:"selectBySqlWhere", params:['whereClause':String, 'silent':boolean, 'process':DC], type:void
method name:"selectBySqlWhere", params:['whereClause':String, 'process':DC], type:void
method name:"selectBySqlWhere",
params:[params:[
parameter(name:'silent', type:Boolean, doc:''),
parameter(name:'batchSize', type:int)],
'whereClause':String, 'process':DC],
type:void
method name:"selectFromIterable", params:['docs':Iterable, 'process':DC]
}
1 change: 1 addition & 0 deletions whelktool/src/main/groovy/datatool/WhelkTool.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ class WhelkTool {
}

private Bindings createMainBindings() {
// Update Whelktool.gdsl when adding new bindings
Bindings bindings = createDefaultBindings()
bindings.put("scriptDir", scriptFile.parent)
bindings.put("baseUri", Document.BASE_URI)
Expand Down