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

Allow TYPE_USE on MagicConstant, Pattern, RegExp and Subst #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
@Documented
@Retention(RetentionPolicy.CLASS)
@Target({ METHOD, FIELD, PARAMETER, LOCAL_VARIABLE, ANNOTATION_TYPE })
@Target({ METHOD, FIELD, PARAMETER, LOCAL_VARIABLE, TYPE_USE, ANNOTATION_TYPE })
public @interface Language {
/**
* Language name like "JAVA", "HTML", "XML", "RegExp", etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
@Target({
ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE,
ElementType.ANNOTATION_TYPE,
ElementType.TYPE_USE,
ElementType.METHOD
})
public @interface MagicConstant {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*/
@Documented
@Retention(RetentionPolicy.CLASS)
@Target({ METHOD, FIELD, PARAMETER, LOCAL_VARIABLE, ANNOTATION_TYPE })
@Target({ METHOD, FIELD, PARAMETER, LOCAL_VARIABLE, TYPE_USE, ANNOTATION_TYPE })
public @interface Pattern {
/**
* A regular expression that matches all the valid string literals that assigned to the annotated variables,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
@Documented
@Retention(RetentionPolicy.CLASS)
@Target({METHOD, FIELD, PARAMETER, LOCAL_VARIABLE, ANNOTATION_TYPE})
@Target({METHOD, FIELD, PARAMETER, LOCAL_VARIABLE, TYPE_USE, ANNOTATION_TYPE})
@Language("RegExp")
public @interface RegExp {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* @see Pattern
*/
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER})
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE, ElementType.PARAMETER})
public @interface Subst {
String value();
}
7 changes: 6 additions & 1 deletion java5/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ sourceSets {
task generateSrc(type: Copy) {
from project(':common').sourceSets.main.java
into generatedSourcesDir
filter { line -> line.replaceAll(", ElementType.TYPE_USE", "")}
// This filter removes
// 1. @Target({LOCAL_VARIABLE, TYPE_USE, ANNOTATION_TYPE}) => @Target({LOCAL_VARIABLE, ANNOTATION_TYPE})
// 2. @Target({ElementType.LOCAL_VARIABLE, ElementType.TYPE_USE, ElementType.PARAMETER}) => @Target({ElementType.LOCAL_VARIABLE, ElementType.PARAMETER})
// 3. @Target({ElementType.FIELD, ElementType.TYPE_USE}) => @Target({ElementType.FIELD, })
// 4. @Target({ElementType.TYPE_USE, ElementType.FIELD}) => @Target({ ElementType.FIELD})
filter { line -> line.replaceAll("\\b(ElementType.)?TYPE_USE\\b(\\w*,)?", "") }
}

compileJava {
Expand Down