IntelliJ Context Suggestions for Missing Method

50 Views Asked by At

When using IntelliJ and referencing a non-existent method, normally I would expect the context to suggest "Create Method" and try to use the apparent signature. This used to work in the past, but I am not finding it to be the current case.

As an example, if I were to create a Spock unit test:

import spock.lang.Specification

class FizzBuzzTest extends Specification {
    FizzBuzz fizzBuzz
    void setup() {
        fizzBuzz = new FizzBuzz()
    }

    def "should show '1' for 1" () {
        String expected = "1"
        String actual = fizzBuzz.convert(1)

        expect:
        expected == actual
    }
}

The class referenced FizzBuzz doesn't exist and when going to the context menu it will prompt you to "Create Class FizzBuzz". This is the expected behavior, and it works.

Once you have done that, the method call fizzBuzz.convert(1) should be underlined indicating that it doesn't exist, and when going to the context menu, you should be prompted to create it using the apparent signature of String convert(Integer)...

This has worked in the past. But when setting up a new project with "minimal" settings for a teaching example I am not getting it to behave like that.

Instead running the test gives: No signature of method: FizzBuzz.convert() is applicable for argument types: (Integer) values: [1] groovy.lang.MissingMethodException: No signature of method: FizzBuzz.convert() is applicable for argument types: (Integer) values: [1]

But when going to the context menu for fizzBuzz.convert(1) it merely offers to either "Introduce Local Variable", or "Remove unnecessary parenthesis"

Versions:

org.spockframework:spock-core:2.3-groovy-4.0
JVM:14
Gradle:7.0

IntelliJ IDEA 2023.1.1 (Ultimate Edition)
Build #IU-231.8770.65, built on April 27, 2023
<Licensing info snipped... >
Runtime version: 17.0.6+10-b829.9 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 14.1
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 16
Metal Rendering is ON
Non-Bundled Plugins:
    solarized (1.5)
    monokai-pro (1.10)
    IdeaVIM (2.7.0)
    com.atlassian.bitbucket.references (2022.1.224)
    com.github.kisstkondoros.codemetrics (1.0.4)
    GrepConsole (12.22.1-IJ2021.1)
    org.sonarlint.idea (8.2.0.68615)
    org.mapstruct.intellij (1.6.0)
    MetricsReloaded (1.12)
    io.snyk.snyk-intellij-plugin (2.4.59)
    zielu.gittoolbox (500.0.14+222)
    com.intellij.restClient.postmanConverter (1.0.4)

Kotlin: 231-1.8.21-IJ8770.65
1

There are 1 best solutions below

0
Bradley M. Small On

I validated that this also doesn't function in the CE version. However, after I installed the Vim plugin and restarted, it worked as expected.

So, I went back to the original setup where it was not working, and chose "Repair IDE". After reindex it was not fixed. But after the "restart" it worked.

So, I am going to consider this an IntelliJ aberration. Thanks, for looking.