Uploaded image for project: 'SR for Jira - Development'
  1. SR for Jira - Development
  2. SRJIRA-5041

Script Editor: Autocomplete errors and fails when using nested classes

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: To Do
    • Priority: Low
    • Resolution: Unresolved
    • Affects Version/s: 6.18.0
    • Fix Version/s: None
    • Component/s: Script Editor
    • Labels:
      None
    • Critical Points:
      2

      Description

      Code completions are failing in the Script Editor when users hit "CTRL+SPACE" to reference nested classes in their custom scripts. 

      Steps to Reproduce

      • Follow the instructions in our Script Roots "Concepts" documentation to create two scripts – one of which imports a utility Class from another file. Your Script Editor file tree should look like this: 
      • Add a nested class to util/Bollo.groovy (see: Bollo.groovy), then hit "CTRL+SPACE" to use autocomplete.
        • Here autocomplete doesn't work. No error dialog or error in jira log is produced.
      • Add another class in util/Bollo.groovy outside of the Bollo class scope.
        • Here autocomplete doesn't work as long as InnerClass exists. If InnerClass is removed, autocomplete starts working. No error dialog or error in jira log is produced.
      • In foo.groovy (see: foo.groovy) try to use autocomplete to call the nested method inside of Bollo's NestedClass. 
        • Observe the popup with the error message "ScriptRunner: Error fetching completions".
        • All character entries after this point generate another error (see: AutocompleteScriptEditorErrors.mov).
      • Create a new class and method inside of foo.groovy and try to use autocomplete inside of the method.
        • Here autocomplete doesn't work and a popup with the message "ScriptRunner: Error fetching completions." appear.
        • In the Jira log there is a stack trace at the same time.

      Expected Behaviour

      Script Editor should allow users to use Groovy's code autocompletion when using custom scripts with nested classes. 

      Actual Behaviour

      As described above, autocomplete doesn't work in the Script Editor when nested classes are present. This causes the Script Editor to generate errors in the UI and in the atlassian-jira.log: 

      2021-02-12 12:05:11,088+0000 http-nio-8080-exec-2 ERROR example 725x1123x2 1gqpz4p 172.17.0.1 /rest/scriptrunner/latest/codeinsight/completions [c.a.p.r.c.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service: BUG! exception in phase 'conversion' in source unit 'Script611.groovy' The lookup for util.Bollo caused a failed compilation. There should not have been any compilation from this call.
      BUG! exception in phase 'conversion' in source unit 'Script611.groovy' The lookup for util.Bollo caused a failed compilation. There should not have been any compilation from this call.
      	at org.codehaus.groovy.control.ClassNodeResolver.findByClassLoading(ClassNodeResolver.java:214)
      	at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:198)
      	at org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:169)
      	at org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:125)
      	at org.codehaus.groovy.control.ResolveVisitor.resolveToOuter(ResolveVisitor.java:853)
      	at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:467)
      	at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1418)
      	at com.onresolve.scriptrunner.stc.completions.StubbedResolveVisitor.super$5$visitClass(StubbedResolveVisitor.groovy)
      	... 2 filtered 

        Attachments

        1. AutocompleteScriptEditorErrors.mov
          7.71 MB
        2. Bollo.groovy
          0.7 kB
        3. CircularDependencyClass1.groovy
          0.1 kB
        4. CircularDependencyClass2.groovy
          0.1 kB
        5. foo.groovy
          0.4 kB
        6. Screenshot 2021-02-12 at 12.20.49.png
          Screenshot 2021-02-12 at 12.20.49.png
          9 kB

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jbaldwin Joe Baldwin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: