Incremental annotation processing with KAPT
Add support for incremental annotation processors in KAPT. These processors conform to https://docs.gradle.org/current/userguide/java_plugin.html#sec:incremental_annotation_processing specification. Support is provided by using javac compiler APIs and recording the source file structure. At runtime, processors are instrumented with custom Filer that is used to keep track of generated files. In order to support classpath changes, stub generation task is used to generated a list of changed FQCNs, and this is simply used by KAPT. Both worker and non-worker mode are supported. #KT-23880
This commit is contained in:
committed by
Alexey Tsvetkov
parent
600a955a51
commit
9f14daa682
+9
@@ -0,0 +1,9 @@
|
||||
package test;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class GenericNumber {
|
||||
<T extends Runnable&Cloneable> java.util.HashSet<? super java.lang.Number> usingGenerics(HashSet<? extends CharSequence> set) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package test;
|
||||
|
||||
public enum MyEnum {
|
||||
VALUE;
|
||||
|
||||
public void process(test.TypeGeneratedByApt toBeGenerated) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package test;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.util.*;
|
||||
import static java.lang.annotation.ElementType.*;
|
||||
|
||||
|
||||
public class MyNumber extends @TypeUseAnnotation HashSet {
|
||||
@FieldAnnotation
|
||||
private String value;
|
||||
|
||||
@MethodAnnotation
|
||||
private void getPrintedValue(@ParameterAnnotation String format) throws @ThrowTypeUseAnnotation RuntimeException{
|
||||
}
|
||||
|
||||
private <@AnotherTypeUseAnnotation T extends Number> void accept(T visitor) {
|
||||
}
|
||||
}
|
||||
|
||||
@interface FieldAnnotation {}
|
||||
@interface MethodAnnotation {}
|
||||
@interface ParameterAnnotation {}
|
||||
|
||||
@Target(value={TYPE_PARAMETER, TYPE_USE})
|
||||
@interface TypeUseAnnotation {}
|
||||
|
||||
@Target(value={TYPE_PARAMETER, TYPE_USE})
|
||||
@interface AnotherTypeUseAnnotation {}
|
||||
|
||||
|
||||
@Target(value={TYPE_PARAMETER, TYPE_USE})
|
||||
@interface ThrowTypeUseAnnotation {}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package test;
|
||||
|
||||
public @interface NumberAnnotation {
|
||||
Class[] classReferences() default { NumberManager.class};
|
||||
MyEnum enumReference() default MyEnum.VALUE;
|
||||
BaseAnnotation otherAnnotation() default @test.BaseAnnotation;
|
||||
}
|
||||
|
||||
@interface BaseAnnotation {}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package test;
|
||||
|
||||
public class NumberException extends RuntimeException {
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package test;
|
||||
|
||||
@NumberAnnotation
|
||||
public class NumberHolder<T extends MyNumber> extends java.util.HashSet<T> implements Runnable {
|
||||
|
||||
private NumberManager manager;
|
||||
|
||||
String getStringValue(NumberManager usingManager) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void run() throws NumberException {
|
||||
}
|
||||
|
||||
class MyInnerClass {}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package test;
|
||||
|
||||
public class NumberManager {
|
||||
|
||||
static final String CONST = "STRING_CONST";
|
||||
static final int INT_CONST = 123 + 123;
|
||||
static int NOT_A_CONST = 1000;
|
||||
|
||||
<T extends NumberHolder> T[] getAllHolders() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private MyEnum getMyEnum() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user