apache / apache/grails-intellij-plugin

IntelliJ fails to detect AST changes in Grails/GORM/MongoDB

Open
#379 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

***What steps will reproduce the issue?***
1\. Create a Grails Gorm for Mongo domain class
2\. Try to use any of the Mongo specific methods (e.g. `collection` or `aggregate`)
3\. Methods are unavailable for autocomplete, but compilation/running the code works.

***What is the expected result?***

The `MongoEntityTraitProvider `provides Mongo specific methods ([such as these](https://gorm.grails.org/5.0.x/mongodb/api/grails/mongodb/MongoEntity.html)) as a trait `MongoEntity` for Grails GORM MongoDB Domain classes. This is in via an AST transform `GormEntityTransformation` - [specifically here](https://github.com/grails/grails-data-mapping/blob/7.3.x/grails-datastore-gorm/src/main/groovy/org/grails/compiler/gorm/GormEntityTransformation.groovy#L378-L418).

These methods should be available for autocomplete, but are not.

***What happens instead?***

The Mongo specific methods are not added, however **the code still compiles and tests pass** - meaning the transform is being applied and used.

If I explicitly change my domain to implement `MongoEntity` then autocomplete is then available.

***Example Repository***

* See `AuthorService` for usage/missing type completion
* Domain is `Author.groovy`

(Without `MongoEntity`)

_⚠️ attachment `image.png` was not included in the export_

(With `MongoEntity`)

_⚠️ attachment `image1.png` was not included in the export_
```
IntelliJ IDEA 2022.2.2 (Ultimate Edition)
Build #IU-222.4167.29, built on September 13, 2022
Subscription is active until December 15, 2022.
Runtime version: 17.0.4+7-b469.53 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.6
GC: G1 Young Generation, G1 Old Generation
Memory: 6100M
Cores: 12
Metal Rendering is ON
Non-Bundled Plugins:
org.jetbrains.plugins.go-template (222.4167.21)
org.intellij.plugins.hcl (222.4167.21)
net.sf.opk.avro-schema-support (213.2.1)
org.sonarlint.idea (7.0.0.52289)
mobi.hsz.idea.gitignore (4.4.2)
org.jetbrains.plugins.ruby (222.4167.21)
com.intellij.javaee.batch (222.4167.21)
Karma (222.4167.21)
org.asciidoctor.intellij.asciidoc (0.37.49)
Pythonid (222.4167.37)
com.intellij.kubernetes (222.4167.21)
org.intellij.grails (222.4167.21)

Kotlin: 222-1.7.10-release-334-IJ4167.29
```

---

*2 attachment(s) referenced here (`image.png`, `image1.png`) are not part of the CSV export.*
*Imported from [IDEA-302660](https://youtrack.jetbrains.com/issue/IDEA-302660) · 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

Start with Author.groovy and AuthorService in the example repository to reproduce the missing completion, then inspect the linked GormEntityTransformation and MongoEntityTraitProvider references. Done means Mongo-specific methods such as collection and aggregate appear in autocomplete without explicitly implementing MongoEntity, while compilation and tests continue to pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mongodb
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.