-
Notifications
You must be signed in to change notification settings - Fork 6
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 #36
Comments
It's an open question here whether IDEA's If there is interest in the workaround solution described above, I may have time to address these. I don't think it would be much work. Of course, a PR would be most welcome, so let me know if you are interested in giving it a try, and I can help you find the places in the code where you will want to look! |
Rough game plan:
As in this: @persistent[DomainModel]
case class User(username: Username, email: Email, fullName: FullName)
object User extends PType[Domain, User] {
implicit val usernameKey = primaryKey(props.username)
} Currently this will fail because the macro ends up extending
|
@mardo has generously offered to take this on. Work to proceed on |
Quick note to say that we've dropped the idea of putting in a |
IDEA can't expand the longevity macro annotations, and consequently shows error messages for
primaryKey
andprops
in an example like this:For references to User in other source files, while implicit resolution of the generated
PEv
s and the keys seems to work fine, we still get compiler errors on things likeUser.props
andUser.queryDsl
(inherited fromPType
).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/
Another potential alternative is to make modifications/enhancements to longevity API to allow users to specify things a little differently so that IDEA can follow along. I'm thinking along the lines of:
So the
@persistent
annotation already extends theUser
companion object withPType
, but we could allow this redundancy easily enough.PType
method something like:This method finds the right property in the
User.props
object generated by the@persistent
macro. In this case, we could saydprop[Username]("username")
instead ofprops.username
. Of course we would lose a lot of type safety guarantees here: this method could throw runtime exception on misnamed or mistyped properties.It looks like these two changes would allow IDEA users to have workarounds for the build errors. The non-workaround, IDEA API for scala macros approach would be much more desirable, but probably a good deal more work.
The text was updated successfully, but these errors were encountered: