Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IDEA support for the longevity annotations #38

Closed
sullivan- opened this issue Aug 2, 2017 · 4 comments
Closed

Add IDEA support for the longevity annotations #38

sullivan- opened this issue Aug 2, 2017 · 4 comments

Comments

@sullivan-
Copy link
Member

IDEA can't expand the longevity macro annotations, and consequently shows error messages for primaryKey and props in an example like this:

@persistent[DomainModel]
case class User(username: Username, email: Email, fullName: FullName)

object User {
  implicit val usernameKey = primaryKey(props.username)
}

For references to User in other source files, while implicit resolution of the generated PEvs and the keys seems to work fine, we still get compiler errors on things like User.props and User.queryDsl (inherited from PType).

It looks like the right way to handle this is to use the "IntelliJ API to build scala macros support": https://blog.jetbrains.com/scala/2015/10/14/intellij-api-to-build-scala-macros-support/

It seems that JetBrains is wisely skipping full-blown support for Scala macros in favor of supporting Scala.meta. See e.g. here:

https://blog.jetbrains.com/scala/2016/11/11/intellij-idea-2016-3-rc-scala-js-scala-meta-and-more/

We plan on migrating longevity from Scala macros to Scala meta as soon as possible. But the Scala.meta feature set is not quite developed enough for our needs as of yet. We're tracking progress on this front here: #37

So barring someone writing an IntelliJ plugin for the longevity macro annotations, we could alternatively wait and see how the situation looks after we migrate longevity to Scala.meta.

@sullivan-
Copy link
Member Author

It's worth noting that it is legal and equivalent to write this instead:

@persistent[DomainModel]
case class User(username: Username, email: Email, fullName: FullName)

object User extends longevity.model.PType[Domain, User] {
  implicit val usernameKey = primaryKey(props.username)
}

This will remove many of the false errors that IDEA reports. Errors about User.props, however, will still be present.

@sullivan-
Copy link
Member Author

This ticket supercedes #36, which got bogged down with a lot of discussion of what turned out to be a false lead. I'm recreating the issue here so readers can quickly get a clear picture of the status of this issue.

@sullivan-
Copy link
Member Author

This was completed by @mardo. You can find it in the idea plugins. I'll update the docs for this when I get the chance

@sullivan-
Copy link
Member Author

I've updated the user manual to direct IDEA users to the plugin. Sorry for the delay on this; I was on a long vacation, and just recovering from being sick.

Thanks to @mardo for the hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant