apache / apache/grails-intellij-plugin

Grails 3 - Action method not recognized

Open
#249 0 comments 0 reactions 0 assignees View on GitHub
bug imported-from-youtrack
Dominant language
Java
Stars
17
Forks
4
Avg merge
5d 15h
Merged PRs (30d)
4

Description

Using Grails 3.1.1, IntelliJ 15.0.3 (143.1821)

1. Create a new Grails project (using Intellij)
2. Create a controller/view (using Intellij)
==> The action "index" is not recognized as an action: the action in the controller is marked as unused, the parameter in the view is not recognized and not navigable, the GSP icon doesn't appear in the margin

3. Change the action from a method to a closure:
```
def index() {
return [
name: 'World'
]
}
```
Change to
```
def index = {
return [
name: 'World'
]
}
```
==> Now everything gets back in place: the icon appears, the action is no longer marked as unused, ctrl-click on a parameter in the view navigates to the controller.

Using closures instead of method is not a good workaround, as the Grails documentation says:

> In earlier versions of Grails actions were implemented with Closures. This is still supported, but the preferred approach is to use methods.
> Leveraging methods instead of Closure properties has some advantages:
> - Memory efficient
> - Allow use of stateless controllers (singleton scope)
> - You can override actions from subclasses and call the overridden superclass method with super.actionName()
> - Methods can be intercepted with standard proxying mechanisms, something that is complicated to do with Closures since they're fields.

---

*Imported from [IDEA-151975](https://youtrack.jetbrains.com/issue/IDEA-151975) · Type: Bug · Votes: 0*
*Comments, attachments, dates and reporter are not part of the export — follow the link above for the full history.*

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue in a Grails 3.1.1 project created with IntelliJ 15.0.3, using a controller, view, and method-based index action. Compare method and closure action handling in the IntelliJ Grails plugin, then verify that the method action is recognized, its view parameter is navigable, and the GSP margin icon appears.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.