-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Support use-site meta-annotations #16445
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6d3ee4a
Support use-site meta-annotations
dwijnand 6d5ccbb
Fix bean-meta annotation support
dwijnand 1c644d7
Fix BeanProperties positions
dwijnand 78a433f
Don't depend on JVM's Annotation toString impl
dwijnand 48a7d11
Ignore Java reflection using tests in Scala.js
dwijnand ad520f3
Use ||, not |
dwijnand c2c937e
Make sure memoised accessors keep their meta annotation
dwijnand caf73bf
Add an indirect `@beanGetter` example
dwijnand fa6326a
Only retain `@field`-bearing annotations on fields
dwijnand e580aaa
Correctly shuffle annotations to where they should go
dwijnand f847ef6
Switch to atPhaseNoLater & push it upstream
dwijnand ceabdbd
Set field annotations immediately
dwijnand 8c512cd
Fix tests/run/beans expectations
dwijnand e35dc2a
Rename meta annotation sets
dwijnand 0bd5087
Reuse SymUtils.withAnnotationsCarrying
dwijnand ff68dc3
Push copyAndKeepAnnotationsCarrying into SymDenotation
dwijnand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
inspecting field brandName | ||
interface MyColumnBase | ||
inspecting field companyName | ||
interface MyColumnBase | ||
inspecting method brandName | ||
inspecting method companyName | ||
inspecting constructor MyTable | ||
inspecting param brandName | ||
inspecting param companyName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface MyColumnBase { | ||
String name() default ""; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import scala.annotation.meta.field | ||
|
||
type MyColumn = MyColumnBase @field | ||
|
||
class MyTable( | ||
@(MyColumnBase @field)(name="BRAND_NAME") | ||
val brandName: String, | ||
@MyColumn(name="COMPANY_NAME") | ||
val companyName: String, | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// scalajs: --skip | ||
object Test: | ||
def main(args: Array[String]): Unit = | ||
val cls = classOf[MyTable] | ||
|
||
for (m <- cls.getDeclaredFields.sortBy(_.getName)) { | ||
m.setAccessible(true) | ||
println(s"inspecting field ${m.getName}") | ||
for a <- m.getAnnotations().sortBy(_.annotationType.toString) do | ||
println(a.annotationType) | ||
} | ||
|
||
for (m <- cls.getDeclaredMethods.sortBy(_.getName)) { | ||
m.setAccessible(true) | ||
println(s"inspecting method ${m.getName}") | ||
for a <- m.getAnnotations().sortBy(_.annotationType.toString) do | ||
println(a.annotationType) | ||
} | ||
|
||
for c <- cls.getDeclaredConstructors.sortBy(_.getName) do | ||
c.setAccessible(true) | ||
println(s"inspecting constructor ${c.getName}") | ||
for p <- c.getParameters.sortBy(_.getName) do | ||
println(s"inspecting param ${p.getName}") | ||
for a <- p.getAnnotations.sortBy(_.annotationType.toString) do | ||
println(a.annotationType) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
inspecting field value | ||
interface JsonProperty | ||
dwijnand marked this conversation as resolved.
Show resolved
Hide resolved
|
||
inspecting method getValue | ||
interface JsonProperty | ||
inspecting method setValue | ||
inspecting method value | ||
inspecting method value_$eq | ||
inspecting constructor TestBeanProperty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface JsonProperty { | ||
String value() default ""; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// scalajs: --skip | ||
object Test: | ||
def main(args: Array[String]): Unit = | ||
val cls = classOf[TestBeanProperty] | ||
|
||
for (m <- cls.getDeclaredFields.sortBy(_.getName)) { | ||
m.setAccessible(true) | ||
println(s"inspecting field ${m.getName}") | ||
for a <- m.getAnnotations().sortBy(_.annotationType.toString) do | ||
println(a.annotationType) | ||
} | ||
|
||
for (m <- cls.getDeclaredMethods.sortBy(_.getName)) { | ||
m.setAccessible(true) | ||
println(s"inspecting method ${m.getName}") | ||
for a <- m.getAnnotations().sortBy(_.annotationType.toString) do | ||
println(a.annotationType) | ||
} | ||
|
||
for c <- cls.getDeclaredConstructors.sortBy(_.getName) do | ||
c.setAccessible(true) | ||
println(s"inspecting constructor ${c.getName}") | ||
for p <- c.getParameters.sortBy(_.getName) do | ||
println(s"inspecting param ${p.getName}") | ||
for a <- p.getAnnotations.sortBy(_.annotationType.toString) do | ||
println(a.annotationType) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import scala.annotation.meta.beanGetter | ||
import scala.beans.BeanProperty | ||
|
||
class TestBeanProperty { | ||
|
||
@(JsonProperty @beanGetter)(value = "REAL_VALUE") | ||
@BeanProperty | ||
var value: String = _ | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.