Issue
I am using Jenkins with Pipelines and have defined a scripted pipeline using a Jenkinsfile
. It looks something like this:
node {
/* some stages */
}
I have imported the GDSL File that comes with Jenkins into IntelliJ. Now I got syntax highlighting but the whole file is being highlighted in a single warning block for which IntelliJ shows the following message:
'node' cannot be applied to '(groovy.lang.closure<Object>)'
I thought it might be that the node object is not supported as root by the syntax definition, but if i try to write pipeline
as root then the same warning appears.
Solution
I found a solution. A small change is required in the pipeline.gdsl
file (e.g. the GDSL file which was downloaded from Jenkins and placed into IntelliJ by us).
Find the following line in the gdsl file:
method(name: 'node', type: 'Object',
params: [label:java.lang.String, body:'Closure'],
doc: 'Allocate node')
And add this line in addition to the previous one:
method(name: 'node', type: 'Object',
params: [body:'Closure'],
doc: 'Allocate node')
This will create an overload definition in the Syntax tree that tells IntelliJ that the node method has two version one which accepts both a String
and a Closure
, and another which accepts only a Closure
.
Answered By - lanoxx
Answer Checked By - Willingham (JavaFixing Volunteer)