Search code examples
intellij-ideaplayframework

Intellij IDEA can not resolve symbol with Play framework


I am using IDEA 13 with Play 2.2.1 and was doing the examples on the play site.

public static Result index() {
   return redirect(routes.Application.tasks());
}

IDEA says "cannot resolve method redirect(?)" and red underlines routes.Application.tasks()

I have done "compile" and then "idea" from the play console.


Solution

  • I had a similar problem when testing my controller. I solved it by "File" > "Open Project" and choose the base folder of the Play framework project (delete all idea settings file from the folder before so that it will reimport using the SBT settings).

    The last version of the SBT support for IDEA did 90% of the work. Then F4 to enter module settings dialog. Set up your project dependencies like in the picture below (the bright red folder have been set by IDEA and do not exist yet in my project so do not worry if they do in yours). It is a matter of including managed classes and generated code in the code that idea will use and index.

    enter image description here

    now I can use code like this from within IDEA and debug it no problem.

    Result result = Helpers.callAction(controllers.routes.ref.CrudController.createEntity(CrudEntities.contact.name()),
            new FakeRequest().withJsonBody(paramJson)
    );
    

    your way of doing it should work as well.