Search code examples
grailsintellij-idea

Intellij w/ Grails: Cannot resolve symbol for inherited params and methods


Intellij complains about cannot resolve symbol very often when I try to access variables or methods that are inherited in my Grails applications. The apps compile and run fine so there isn't really any issues, but the IDE makes it seem like there is. It makes it hard to figure out when there really is an issue or i'm just getting a false positive. As someone who is new to Grails and trying to learn, i find myself banging my head against a wall trying to fix something that turns out isn't even broken.

For example:

class GlobalParamsInterceptor {
    def SysConfigService sysConfigService;

    GlobalParamsInterceptor() {
        matchAll();
    }

    boolean before() {
        true
     }

    boolean after() {
        model.isApplicationOpen = sysConfigService.isApplicationOpen();
        model.context = grailsApplication.getMainContext();

        true
    }

    void afterView() {
        // no-op
    }
}

matchAll() model grailsApplication are all flagged as unresolved symbols yet they are actually valid. I am using the Ultimate edition of Intellij which is supposed to support Grails so I would assume it should be able to figure these things out right?


Solution

  • I am using the Ultimate edition of Intellij which is supposed to support Grails so I would assume it should be able to figure these things out right?

    In general it does. There are places where IDEA doesn't recognizes traits that are mixed in to some artifacts, and this is one example. The code should still compile and run fine. I don't know if there is a feature request already out there for this one in particular or not, but I will mention it to the IDEA guys.