-
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 9 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
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,13 @@ | ||
inspecting field fieldName1 @MyColumnBase | ||
inspecting field fieldName2 @MyColumnBase | ||
inspecting field getterName1 | ||
inspecting field getterName2 | ||
inspecting method fieldName1 | ||
inspecting method fieldName2 | ||
inspecting method getterName1 @MyColumnBase | ||
inspecting method getterName2 @MyColumnBase | ||
inspecting constructor MyTable | ||
inspecting param fieldName1 | ||
inspecting param fieldName2 | ||
inspecting param getterName1 | ||
inspecting param getterName2 |
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,16 @@ | ||
import scala.annotation.meta.* | ||
|
||
type FieldColumn = MyColumnBase @field | ||
type GetterColumn = MyColumnBase @getter | ||
|
||
class MyTable( | ||
@(MyColumnBase @field)(name="FIELD_NAME1") | ||
val fieldName1: String, | ||
@FieldColumn(name="FIELD_NAME2") | ||
val fieldName2: String, | ||
|
||
@(MyColumnBase @getter)(name="GETTER_NAME1") | ||
val getterName1: String, | ||
@GetterColumn(name="GETTER_NAME2") | ||
val getterName2: 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,29 @@ | ||
// scalajs: --skip | ||
object Test: | ||
def main(args: Array[String]): Unit = | ||
val cls = classOf[MyTable] | ||
|
||
for (m <- cls.getDeclaredFields.sortBy(_.getName)) { | ||
m.setAccessible(true) | ||
print(s"inspecting field ${m.getName}") | ||
for a <- m.getAnnotations().sortBy(_.annotationType.toString) do | ||
print(s" @${a.annotationType.getName}") | ||
println() | ||
} | ||
|
||
for (m <- cls.getDeclaredMethods.sortBy(_.getName)) { | ||
m.setAccessible(true) | ||
print(s"inspecting method ${m.getName}") | ||
for a <- m.getAnnotations().sortBy(_.annotationType.toString) do | ||
print(s" @${a.annotationType.getName}") | ||
println() | ||
} | ||
|
||
for c <- cls.getDeclaredConstructors.sortBy(_.getName) do | ||
c.setAccessible(true) | ||
println(s"inspecting constructor ${c.getName}") | ||
for p <- c.getParameters.sortBy(_.getName) do | ||
print(s"inspecting param ${p.getName}") | ||
for a <- p.getAnnotations.sortBy(_.annotationType.toString) do | ||
print(s" @${a.annotationType.getName}") | ||
println() |
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,11 @@ | ||
inspecting field value | ||
inspecting field value2 | ||
inspecting method getValue @JsonProperty | ||
inspecting method getValue2 @JsonProperty | ||
inspecting method setValue | ||
inspecting method setValue2 | ||
inspecting method value | ||
inspecting method value2 | ||
inspecting method value2_$eq | ||
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,29 @@ | ||
// scalajs: --skip | ||
object Test: | ||
def main(args: Array[String]): Unit = | ||
val cls = classOf[TestBeanProperty] | ||
|
||
for (m <- cls.getDeclaredFields.sortBy(_.getName)) { | ||
m.setAccessible(true) | ||
print(s"inspecting field ${m.getName}") | ||
for a <- m.getAnnotations().sortBy(_.annotationType.toString) do | ||
print(s" @${a.annotationType.getName}") | ||
println() | ||
} | ||
|
||
for (m <- cls.getDeclaredMethods.sortBy(_.getName)) { | ||
m.setAccessible(true) | ||
print(s"inspecting method ${m.getName}") | ||
for a <- m.getAnnotations().sortBy(_.annotationType.toString) do | ||
print(s" @${a.annotationType.getName}") | ||
println() | ||
} | ||
|
||
for c <- cls.getDeclaredConstructors.sortBy(_.getName) do | ||
c.setAccessible(true) | ||
println(s"inspecting constructor ${c.getName}") | ||
for p <- c.getParameters.sortBy(_.getName) do | ||
print(s"inspecting param ${p.getName}") | ||
for a <- p.getAnnotations.sortBy(_.annotationType.toString) do | ||
print(s" @${a.annotationType.getName}") | ||
println() |
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,16 @@ | ||
import scala.annotation.meta.beanGetter | ||
import scala.beans.BeanProperty | ||
|
||
type BeanGetterJsonProperty = JsonProperty @beanGetter | ||
|
||
class TestBeanProperty { | ||
|
||
@(JsonProperty @beanGetter)(value = "REAL_VALUE") | ||
@BeanProperty | ||
var value: String = _ | ||
|
||
@BeanGetterJsonProperty(value = "REAL_VALUE2") | ||
@BeanProperty | ||
var value2: 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.