-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support use-site meta-annotations (#16445)
- Loading branch information
Showing
19 changed files
with
246 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
true | ||
10 | ||
[@beans.LibraryAnnotation_1()] | ||
[] | ||
some text | ||
other text |
This file contains 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 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,37 @@ | ||
inspecting constructor MyTable | ||
inspecting param aaaParam1 @MyColumnBase | ||
inspecting param fldParam1 | ||
inspecting param getParam1 | ||
inspecting param parParam1 @MyColumnBase | ||
inspecting field aaaField1 @MyColumnBase | ||
inspecting field aaaParam1 | ||
inspecting field fldField1 @MyColumnBase | ||
inspecting field fldParam1 @MyColumnBase | ||
inspecting field getField1 | ||
inspecting field getParam1 | ||
inspecting field parField1 | ||
inspecting field parParam1 | ||
inspecting method aaaField1 | ||
inspecting method aaaParam1 | ||
inspecting method fldField1 | ||
inspecting method fldParam1 | ||
inspecting method getField1 @MyColumnBase | ||
inspecting method getParam1 @MyColumnBase | ||
inspecting method parField1 | ||
inspecting method parParam1 | ||
inspecting constructor MyTable2 | ||
inspecting param fldParam2 | ||
inspecting param getParam2 | ||
inspecting param parParam2 @MyColumnBase | ||
inspecting field fldField2 @MyColumnBase | ||
inspecting field fldParam2 @MyColumnBase | ||
inspecting field getField2 | ||
inspecting field getParam2 | ||
inspecting field parField2 | ||
inspecting field parParam2 | ||
inspecting method fldField2 | ||
inspecting method fldParam2 | ||
inspecting method getField2 @MyColumnBase | ||
inspecting method getParam2 @MyColumnBase | ||
inspecting method parField2 | ||
inspecting method parParam2 |
This file contains 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,5 @@ | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface MyColumnBase {} |
This file contains 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,27 @@ | ||
import scala.annotation.meta.{ field as fld, getter as get, param as par } | ||
|
||
type FldColumn = MyColumnBase @fld | ||
type GetColumn = MyColumnBase @get | ||
type ParColumn = MyColumnBase @par | ||
|
||
class MyTable( | ||
@(MyColumnBase ) val aaaParam1: String, | ||
@(MyColumnBase @fld) val fldParam1: String, | ||
@(MyColumnBase @get) val getParam1: String, | ||
@(MyColumnBase @par) val parParam1: String, | ||
) { | ||
@(MyColumnBase ) val aaaField1: String = "" | ||
@(MyColumnBase @fld) val fldField1: String = "" | ||
@(MyColumnBase @get) val getField1: String = "" | ||
@(MyColumnBase @par) val parField1: String = "" | ||
} | ||
|
||
class MyTable2( | ||
@FldColumn val fldParam2: String, | ||
@GetColumn val getParam2: String, | ||
@ParColumn val parParam2: String, | ||
) { | ||
@FldColumn val fldField2: String = "" | ||
@GetColumn val getField2: String = "" | ||
@ParColumn val parField2: String = "" | ||
} |
This file contains 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,31 @@ | ||
// scalajs: --skip | ||
object Test: | ||
def main(args: Array[String]): Unit = | ||
go(classOf[MyTable]) | ||
go(classOf[MyTable2]) | ||
|
||
def go(cls: Class[?]): Unit = | ||
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() | ||
|
||
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() | ||
} |
Oops, something went wrong.