I’m trying to make a plugin which helps with developing Jenkins pipeline scripts.
Essentially I want a way to extend the Groovy reference searching so it includes the scripts in a shared library.
These are groovy scripts, with one Jenkins quirk. The script can have a method call (i.e. foo()) which references a script in a separate shared library. This library has a specific structure where that foo() method call ends up calling the a method called call in a file “/vars/foo.groovy”.
i.e. /vars/foo.groovy
def call() {
print("hello")
}
Jenkinsfile
foo()
// outputs "hello"
You can add the shared library to the project as a dependency, and I’ve got a working documentationProvider and gotoDeclarationHandler but my referenceContributor never fires, so the IDE thinks the methods are always invalid.
It seems I think that IntelliJ does an initial scan of the file, matching symbols against it’s indexes, and if something doesn’t match, it never creates the PSI object for it, and so never fires the referenceContributor . I think this must be because I’m trying to effectively extend Groovy’s support, not create a new language implementation.
Is there anyway to hook into the Groovy indexing process, and add the files in the /vars directory, with the method name referencing the call method? This is more than just a resolveScopeEnlarger because it needs to transform how the file is parsed.