Kapt: Remove kapt1 from Kotlin compiler
This commit is contained in:
@@ -31,7 +31,7 @@ public class ClassBuilderFactories {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ClassBuilderMode getClassBuilderMode() {
|
public ClassBuilderMode getClassBuilderMode() {
|
||||||
return ClassBuilderMode.full(false);
|
return ClassBuilderMode.FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -56,21 +56,15 @@ public class ClassBuilderFactories {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ClassBuilderFactory TEST = new TestClassBuilderFactory(false);
|
public static ClassBuilderFactory TEST = new TestClassBuilderFactory();
|
||||||
|
|
||||||
public static ClassBuilderFactory TEST_WITH_SOURCE_RETENTION_ANNOTATIONS = new TestClassBuilderFactory(true);
|
|
||||||
|
|
||||||
public static class TestClassBuilderFactory implements ClassBuilderFactory {
|
public static class TestClassBuilderFactory implements ClassBuilderFactory {
|
||||||
private final boolean generateSourceRetentionAnnotations;
|
public TestClassBuilderFactory() {}
|
||||||
|
|
||||||
public TestClassBuilderFactory(boolean generateSourceRetentionAnnotations) {
|
|
||||||
this.generateSourceRetentionAnnotations = generateSourceRetentionAnnotations;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ClassBuilderMode getClassBuilderMode() {
|
public ClassBuilderMode getClassBuilderMode() {
|
||||||
return ClassBuilderMode.full(generateSourceRetentionAnnotations);
|
return ClassBuilderMode.FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -101,37 +95,33 @@ public class ClassBuilderFactories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static ClassBuilderFactory binaries(boolean generateSourceRetentionAnnotations) {
|
public static ClassBuilderFactory BINARIES = new ClassBuilderFactory() {
|
||||||
return new ClassBuilderFactory() {
|
@NotNull
|
||||||
@NotNull
|
@Override
|
||||||
@Override
|
public ClassBuilderMode getClassBuilderMode() {
|
||||||
public ClassBuilderMode getClassBuilderMode() {
|
return ClassBuilderMode.FULL;
|
||||||
return ClassBuilderMode.full(generateSourceRetentionAnnotations);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ClassBuilder newClassBuilder(@NotNull JvmDeclarationOrigin origin) {
|
public ClassBuilder newClassBuilder(@NotNull JvmDeclarationOrigin origin) {
|
||||||
return new AbstractClassBuilder.Concrete(new BinaryClassWriter());
|
return new AbstractClassBuilder.Concrete(new BinaryClassWriter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String asText(ClassBuilder builder) {
|
public String asText(ClassBuilder builder) {
|
||||||
throw new UnsupportedOperationException("BINARIES generator asked for text");
|
throw new UnsupportedOperationException("BINARIES generator asked for text");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] asBytes(ClassBuilder builder) {
|
public byte[] asBytes(ClassBuilder builder) {
|
||||||
ClassWriter visitor = (ClassWriter) builder.getVisitor();
|
ClassWriter visitor = (ClassWriter) builder.getVisitor();
|
||||||
return visitor.toByteArray();
|
return visitor.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {}
|
||||||
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private ClassBuilderFactories() {
|
private ClassBuilderFactories() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,15 +35,11 @@ public class ClassBuilderMode {
|
|||||||
this.generateSourceRetentionAnnotations = generateSourceRetentionAnnotations;
|
this.generateSourceRetentionAnnotations = generateSourceRetentionAnnotations;
|
||||||
this.generateMultiFileFacadePartClasses = generateMultiFileFacadePartClasses;
|
this.generateMultiFileFacadePartClasses = generateMultiFileFacadePartClasses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClassBuilderMode full(boolean generateSourceRetentionAnnotations) {
|
|
||||||
return generateSourceRetentionAnnotations ? KAPT : FULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full function bodies
|
* Full function bodies
|
||||||
*/
|
*/
|
||||||
private final static ClassBuilderMode FULL = new ClassBuilderMode(
|
public final static ClassBuilderMode FULL = new ClassBuilderMode(
|
||||||
/* bodies = */ true,
|
/* bodies = */ true,
|
||||||
/* metadata = */ true,
|
/* metadata = */ true,
|
||||||
/* sourceRetention = */ false,
|
/* sourceRetention = */ false,
|
||||||
@@ -57,15 +53,6 @@ public class ClassBuilderMode {
|
|||||||
/* metadata = */ false,
|
/* metadata = */ false,
|
||||||
/* sourceRetention = */ true,
|
/* sourceRetention = */ true,
|
||||||
/* generateMultiFileFacadePartClasses = */ false);
|
/* generateMultiFileFacadePartClasses = */ false);
|
||||||
|
|
||||||
/**
|
|
||||||
* Function signatures + metadata (to support incremental compilation with kapt)
|
|
||||||
*/
|
|
||||||
public final static ClassBuilderMode KAPT = new ClassBuilderMode(
|
|
||||||
/* bodies = */ false,
|
|
||||||
/* metadata = */ true,
|
|
||||||
/* sourceRetention = */ true,
|
|
||||||
/* generateMultiFileFacadePartClasses = */ false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function signatures + metadata (to support incremental compilation with kapt)
|
* Function signatures + metadata (to support incremental compilation with kapt)
|
||||||
|
|||||||
+1
-1
@@ -196,7 +196,7 @@ public class JvmSerializerExtension extends SerializerExtension {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serializeErrorType(@NotNull KotlinType type, @NotNull ProtoBuf.Type.Builder builder) {
|
public void serializeErrorType(@NotNull KotlinType type, @NotNull ProtoBuf.Type.Builder builder) {
|
||||||
if (classBuilderMode == ClassBuilderMode.KAPT || classBuilderMode == ClassBuilderMode.KAPT3) {
|
if (classBuilderMode == ClassBuilderMode.KAPT3) {
|
||||||
builder.setClassName(stringTable.getStringIndex(TypeSignatureMappingKt.NON_EXISTENT_CLASS_NAME));
|
builder.setClassName(stringTable.getStringIndex(TypeSignatureMappingKt.NON_EXISTENT_CLASS_NAME));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,13 +37,10 @@ dependencies {
|
|||||||
sourceSets {
|
sourceSets {
|
||||||
"main" {
|
"main" {
|
||||||
projectDefault()
|
projectDefault()
|
||||||
java.srcDirs("../../plugins/annotation-collector/src",
|
java.srcDirs("../builtins-serializer/src",
|
||||||
"../builtins-serializer/src",
|
|
||||||
"../javac-wrapper/src")
|
"../javac-wrapper/src")
|
||||||
}
|
}
|
||||||
"test" {
|
"test" { }
|
||||||
java.srcDirs("../../plugins/annotation-collector/test")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
testsJar {}
|
testsJar {}
|
||||||
|
|||||||
@@ -16,17 +16,15 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.cli.jvm
|
package org.jetbrains.kotlin.cli.jvm
|
||||||
|
|
||||||
import org.jetbrains.kotlin.annotation.AnnotationCollectorCommandLineProcessor
|
|
||||||
import org.jetbrains.kotlin.annotation.AnnotationCollectorComponentRegistrar
|
|
||||||
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
|
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
|
||||||
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
|
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
|
||||||
|
|
||||||
object BundledCompilerPlugins {
|
object BundledCompilerPlugins {
|
||||||
|
|
||||||
val componentRegistrars: List<ComponentRegistrar>
|
val componentRegistrars: List<ComponentRegistrar>
|
||||||
get() = listOf(AnnotationCollectorComponentRegistrar())
|
get() = emptyList()
|
||||||
|
|
||||||
val commandLineProcessors: List<CommandLineProcessor>
|
val commandLineProcessors: List<CommandLineProcessor>
|
||||||
get() = listOf(AnnotationCollectorCommandLineProcessor())
|
get() = emptyList()
|
||||||
|
|
||||||
}
|
}
|
||||||
+1
-2
@@ -420,10 +420,9 @@ object KotlinToJVMBytecodeCompiler {
|
|||||||
sourceFiles: List<KtFile>,
|
sourceFiles: List<KtFile>,
|
||||||
module: Module?
|
module: Module?
|
||||||
): GenerationState {
|
): GenerationState {
|
||||||
val isKapt2Enabled = environment.project.getUserData(IS_KAPT2_ENABLED_KEY) ?: false
|
|
||||||
val generationState = GenerationState.Builder(
|
val generationState = GenerationState.Builder(
|
||||||
environment.project,
|
environment.project,
|
||||||
ClassBuilderFactories.binaries(isKapt2Enabled),
|
ClassBuilderFactories.BINARIES,
|
||||||
result.moduleDescriptor,
|
result.moduleDescriptor,
|
||||||
result.bindingContext,
|
result.bindingContext,
|
||||||
sourceFiles,
|
sourceFiles,
|
||||||
|
|||||||
+1
-2
@@ -422,10 +422,9 @@ object KotlinToJVMBytecodeCompiler {
|
|||||||
sourceFiles: List<KtFile>,
|
sourceFiles: List<KtFile>,
|
||||||
module: Module?
|
module: Module?
|
||||||
): GenerationState {
|
): GenerationState {
|
||||||
val isKapt2Enabled = environment.project.getUserData(IS_KAPT2_ENABLED_KEY) ?: false
|
|
||||||
val generationState = GenerationState.Builder(
|
val generationState = GenerationState.Builder(
|
||||||
environment.project,
|
environment.project,
|
||||||
ClassBuilderFactories.binaries(isKapt2Enabled),
|
ClassBuilderFactories.BINARIES,
|
||||||
result.moduleDescriptor,
|
result.moduleDescriptor,
|
||||||
result.bindingContext,
|
result.bindingContext,
|
||||||
sourceFiles,
|
sourceFiles,
|
||||||
|
|||||||
+1
-2
@@ -422,10 +422,9 @@ object KotlinToJVMBytecodeCompiler {
|
|||||||
sourceFiles: List<KtFile>,
|
sourceFiles: List<KtFile>,
|
||||||
module: Module?
|
module: Module?
|
||||||
): GenerationState {
|
): GenerationState {
|
||||||
val isKapt2Enabled = environment.project.getUserData(IS_KAPT2_ENABLED_KEY) ?: false
|
|
||||||
val generationState = GenerationState.Builder(
|
val generationState = GenerationState.Builder(
|
||||||
environment.project,
|
environment.project,
|
||||||
ClassBuilderFactories.binaries(isKapt2Enabled),
|
ClassBuilderFactories.BINARIES,
|
||||||
result.moduleDescriptor,
|
result.moduleDescriptor,
|
||||||
result.bindingContext,
|
result.bindingContext,
|
||||||
sourceFiles,
|
sourceFiles,
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.cli.jvm.config
|
|
||||||
|
|
||||||
import com.intellij.openapi.util.Key
|
|
||||||
|
|
||||||
val IS_KAPT2_ENABLED_KEY = Key<Boolean>("IsKapt2EnabledKey")
|
|
||||||
@@ -89,7 +89,7 @@ open class GenericReplCompiler(disposable: Disposable,
|
|||||||
|
|
||||||
val generationState = GenerationState.Builder(
|
val generationState = GenerationState.Builder(
|
||||||
psiFile.project,
|
psiFile.project,
|
||||||
ClassBuilderFactories.binaries(false),
|
ClassBuilderFactories.BINARIES,
|
||||||
compilerState.analyzerEngine.module,
|
compilerState.analyzerEngine.module,
|
||||||
compilerState.analyzerEngine.trace.bindingContext,
|
compilerState.analyzerEngine.trace.bindingContext,
|
||||||
listOf(psiFile),
|
listOf(psiFile),
|
||||||
|
|||||||
+1
-1
@@ -24,7 +24,7 @@ import java.io.File
|
|||||||
|
|
||||||
abstract class AbstractKapt3BuilderModeBytecodeShapeTest : CodegenTestCase() {
|
abstract class AbstractKapt3BuilderModeBytecodeShapeTest : CodegenTestCase() {
|
||||||
private companion object {
|
private companion object {
|
||||||
var TEST_LIGHT_ANALYSIS: ClassBuilderFactory = object : ClassBuilderFactories.TestClassBuilderFactory(false) {
|
var TEST_LIGHT_ANALYSIS: ClassBuilderFactory = object : ClassBuilderFactories.TestClassBuilderFactory() {
|
||||||
override fun getClassBuilderMode() = ClassBuilderMode.KAPT3
|
override fun getClassBuilderMode() = ClassBuilderMode.KAPT3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ import java.io.File
|
|||||||
|
|
||||||
abstract class AbstractLightAnalysisModeTest : CodegenTestCase() {
|
abstract class AbstractLightAnalysisModeTest : CodegenTestCase() {
|
||||||
private companion object {
|
private companion object {
|
||||||
var TEST_LIGHT_ANALYSIS: ClassBuilderFactory = object : ClassBuilderFactories.TestClassBuilderFactory(false) {
|
var TEST_LIGHT_ANALYSIS: ClassBuilderFactory = object : ClassBuilderFactories.TestClassBuilderFactory() {
|
||||||
override fun getClassBuilderMode() = ClassBuilderMode.LIGHT_ANALYSIS_FOR_TESTS
|
override fun getClassBuilderMode() = ClassBuilderMode.LIGHT_ANALYSIS_FOR_TESTS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.android.quickfix.AbstractAndroidQuickFixMultiFileTes
|
|||||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest
|
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest
|
||||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest
|
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest
|
||||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest
|
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest
|
||||||
import org.jetbrains.kotlin.annotation.AbstractAnnotationProcessorBoxTest
|
|
||||||
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinBinariesCheckerTest
|
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinBinariesCheckerTest
|
||||||
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinSourceCheckerTest
|
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinSourceCheckerTest
|
||||||
import org.jetbrains.kotlin.checkers.AbstractJsCheckerTest
|
import org.jetbrains.kotlin.checkers.AbstractJsCheckerTest
|
||||||
@@ -1016,12 +1015,6 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testGroup("plugins/annotation-collector/test", "plugins/annotation-collector/testData") {
|
|
||||||
testClass<AbstractAnnotationProcessorBoxTest> {
|
|
||||||
model("collectToFile", recursive = false, extension = null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
testGroup("plugins/kapt3/kapt3-compiler/test", "plugins/kapt3/kapt3-compiler/testData") {
|
testGroup("plugins/kapt3/kapt3-compiler/test", "plugins/kapt3/kapt3-compiler/testData") {
|
||||||
testClass<AbstractClassFileToSourceStubConverterTest> {
|
testClass<AbstractClassFileToSourceStubConverterTest> {
|
||||||
model("converter")
|
model("converter")
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.android.quickfix.AbstractAndroidQuickFixMultiFileTes
|
|||||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest
|
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest
|
||||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest
|
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest
|
||||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest
|
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest
|
||||||
import org.jetbrains.kotlin.annotation.AbstractAnnotationProcessorBoxTest
|
|
||||||
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinBinariesCheckerTest
|
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinBinariesCheckerTest
|
||||||
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinSourceCheckerTest
|
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinSourceCheckerTest
|
||||||
import org.jetbrains.kotlin.checkers.AbstractJsCheckerTest
|
import org.jetbrains.kotlin.checkers.AbstractJsCheckerTest
|
||||||
@@ -1006,12 +1005,6 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testGroup("plugins/annotation-collector/test", "plugins/annotation-collector/testData") {
|
|
||||||
testClass<AbstractAnnotationProcessorBoxTest> {
|
|
||||||
model("collectToFile", recursive = false, extension = null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
testGroup("plugins/kapt3/kapt3-compiler/test", "plugins/kapt3/kapt3-compiler/testData") {
|
testGroup("plugins/kapt3/kapt3-compiler/test", "plugins/kapt3/kapt3-compiler/testData") {
|
||||||
testClass<AbstractClassFileToSourceStubConverterTest> {
|
testClass<AbstractClassFileToSourceStubConverterTest> {
|
||||||
model("converter")
|
model("converter")
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import org.jetbrains.kotlin.android.quickfix.AbstractAndroidQuickFixMultiFileTes
|
|||||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest
|
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest
|
||||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest
|
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest
|
||||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest
|
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest
|
||||||
import org.jetbrains.kotlin.annotation.AbstractAnnotationProcessorBoxTest
|
|
||||||
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinBinariesCheckerTest
|
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinBinariesCheckerTest
|
||||||
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinSourceCheckerTest
|
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinSourceCheckerTest
|
||||||
import org.jetbrains.kotlin.checkers.AbstractJsCheckerTest
|
import org.jetbrains.kotlin.checkers.AbstractJsCheckerTest
|
||||||
@@ -1018,12 +1017,6 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testGroup("plugins/annotation-collector/test", "plugins/annotation-collector/testData") {
|
|
||||||
testClass<AbstractAnnotationProcessorBoxTest> {
|
|
||||||
model("collectToFile", recursive = false, extension = null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
testGroup("plugins/kapt3/kapt3-compiler/test", "plugins/kapt3/kapt3-compiler/testData") {
|
testGroup("plugins/kapt3/kapt3-compiler/test", "plugins/kapt3/kapt3-compiler/testData") {
|
||||||
testClass<AbstractClassFileToSourceStubConverterTest> {
|
testClass<AbstractClassFileToSourceStubConverterTest> {
|
||||||
model("converter")
|
model("converter")
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ import org.jetbrains.kotlin.android.quickfix.AbstractAndroidQuickFixMultiFileTes
|
|||||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest
|
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBoxTest
|
||||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest
|
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidBytecodeShapeTest
|
||||||
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest
|
import org.jetbrains.kotlin.android.synthetic.test.AbstractAndroidSyntheticPropertyDescriptorTest
|
||||||
import org.jetbrains.kotlin.annotation.AbstractAnnotationProcessorBoxTest
|
|
||||||
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinBinariesCheckerTest
|
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinBinariesCheckerTest
|
||||||
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinSourceCheckerTest
|
import org.jetbrains.kotlin.checkers.AbstractJavaAgainstKotlinSourceCheckerTest
|
||||||
import org.jetbrains.kotlin.checkers.AbstractJsCheckerTest
|
import org.jetbrains.kotlin.checkers.AbstractJsCheckerTest
|
||||||
@@ -1018,12 +1017,6 @@ fun main(args: Array<String>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testGroup("plugins/annotation-collector/test", "plugins/annotation-collector/testData") {
|
|
||||||
testClass<AbstractAnnotationProcessorBoxTest> {
|
|
||||||
model("collectToFile", recursive = false, extension = null)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
testGroup("plugins/kapt3/kapt3-compiler/test", "plugins/kapt3/kapt3-compiler/testData") {
|
testGroup("plugins/kapt3/kapt3-compiler/test", "plugins/kapt3/kapt3-compiler/testData") {
|
||||||
testClass<AbstractClassFileToSourceStubConverterTest> {
|
testClass<AbstractClassFileToSourceStubConverterTest> {
|
||||||
model("converter")
|
model("converter")
|
||||||
|
|||||||
+1
-1
@@ -460,7 +460,7 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, val sourcePosition: Sour
|
|||||||
|
|
||||||
val state = GenerationState.Builder(
|
val state = GenerationState.Builder(
|
||||||
fileForDebugger.project,
|
fileForDebugger.project,
|
||||||
if (!DEBUG_MODE) ClassBuilderFactories.binaries(false) else ClassBuilderFactories.TEST,
|
if (!DEBUG_MODE) ClassBuilderFactories.BINARIES else ClassBuilderFactories.TEST,
|
||||||
moduleDescriptor,
|
moduleDescriptor,
|
||||||
bindingContext,
|
bindingContext,
|
||||||
files,
|
files,
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class KtCompilingExecutor(file: ScratchFile) : ScratchExecutor(file) {
|
|||||||
|
|
||||||
val state = GenerationState.Builder(
|
val state = GenerationState.Builder(
|
||||||
file.project,
|
file.project,
|
||||||
ClassBuilderFactories.binaries(false),
|
ClassBuilderFactories.BINARIES,
|
||||||
resolutionFacade.moduleDescriptor,
|
resolutionFacade.moduleDescriptor,
|
||||||
bindingContext,
|
bindingContext,
|
||||||
files,
|
files,
|
||||||
|
|||||||
+1
-1
@@ -174,7 +174,7 @@ class KJVMCompilerImpl : KJVMCompilerProxy {
|
|||||||
|
|
||||||
val generationState = GenerationState.Builder(
|
val generationState = GenerationState.Builder(
|
||||||
psiFile.project,
|
psiFile.project,
|
||||||
ClassBuilderFactories.binaries(false),
|
ClassBuilderFactories.BINARIES,
|
||||||
analysisResult.moduleDescriptor,
|
analysisResult.moduleDescriptor,
|
||||||
analysisResult.bindingContext,
|
analysisResult.bindingContext,
|
||||||
sourceFiles,
|
sourceFiles,
|
||||||
|
|||||||
+1
-1
@@ -170,7 +170,7 @@ class ParcelableDeclarationChecker : DeclarationChecker {
|
|||||||
|
|
||||||
val typeMapper = KotlinTypeMapper(
|
val typeMapper = KotlinTypeMapper(
|
||||||
bindingContext,
|
bindingContext,
|
||||||
ClassBuilderMode.full(false),
|
ClassBuilderMode.FULL,
|
||||||
IncompatibleClassTracker.DoNothing,
|
IncompatibleClassTracker.DoNothing,
|
||||||
descriptor.module.name.asString(),
|
descriptor.module.name.asString(),
|
||||||
/* isJvm8Target */ false,
|
/* isJvm8Target */ false,
|
||||||
|
|||||||
-270
@@ -1,270 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.annotation
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import org.jetbrains.kotlin.codegen.ClassBuilder
|
|
||||||
import org.jetbrains.kotlin.codegen.ClassBuilderFactory
|
|
||||||
import org.jetbrains.kotlin.codegen.DelegatingClassBuilder
|
|
||||||
import org.jetbrains.kotlin.codegen.DelegatingClassBuilderFactory
|
|
||||||
import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension
|
|
||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
|
||||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
|
|
||||||
import org.jetbrains.org.objectweb.asm.*
|
|
||||||
import java.io.File
|
|
||||||
import java.io.IOException
|
|
||||||
import java.io.Writer
|
|
||||||
import java.util.regex.Pattern
|
|
||||||
import java.util.regex.PatternSyntaxException
|
|
||||||
|
|
||||||
abstract class AnnotationCollectorExtensionBase(val supportInheritedAnnotations: Boolean) : ClassBuilderInterceptorExtension {
|
|
||||||
|
|
||||||
private object RecordTypes {
|
|
||||||
val ANNOTATED_CLASS = "c"
|
|
||||||
val ANNOTATED_METHOD = "m"
|
|
||||||
val ANNOTATED_FIELD = "f"
|
|
||||||
|
|
||||||
val SHORTENED_ANNOTATION = "a"
|
|
||||||
val SHORTENED_PACKAGE_NAME = "p"
|
|
||||||
|
|
||||||
val CLASS_DECLARATION = "d"
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract val annotationFilterList: List<String>?
|
|
||||||
|
|
||||||
private val shortenedAnnotationCache = ShortenedNameCache(RecordTypes.SHORTENED_ANNOTATION)
|
|
||||||
private val shortenedPackageNameCache = ShortenedNameCache(RecordTypes.SHORTENED_PACKAGE_NAME)
|
|
||||||
|
|
||||||
override fun interceptClassBuilderFactory(
|
|
||||||
interceptedFactory: ClassBuilderFactory,
|
|
||||||
bindingContext: BindingContext,
|
|
||||||
diagnostics: DiagnosticSink
|
|
||||||
): ClassBuilderFactory {
|
|
||||||
return AnnotationCollectorClassBuilderFactory(interceptedFactory, getWriter(diagnostics), diagnostics)
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract fun getWriter(diagnostic: DiagnosticSink): Writer
|
|
||||||
protected abstract fun closeWriter()
|
|
||||||
|
|
||||||
private inner class AnnotationCollectorClassBuilderFactory(
|
|
||||||
delegateFactory: ClassBuilderFactory,
|
|
||||||
val writer: Writer,
|
|
||||||
val diagnostics: DiagnosticSink
|
|
||||||
) : DelegatingClassBuilderFactory(delegateFactory) {
|
|
||||||
|
|
||||||
override fun newClassBuilder(origin: JvmDeclarationOrigin): DelegatingClassBuilder {
|
|
||||||
return AnnotationCollectorClassBuilder(delegate.newClassBuilder(origin), writer, diagnostics)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun close() {
|
|
||||||
closeWriter()
|
|
||||||
delegate.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private inner class AnnotationCollectorClassBuilder(
|
|
||||||
internal val delegateClassBuilder: ClassBuilder,
|
|
||||||
val writer: Writer,
|
|
||||||
val diagnostics: DiagnosticSink
|
|
||||||
) : DelegatingClassBuilder() {
|
|
||||||
private val annotationFilterEnabled: Boolean
|
|
||||||
private val annotationFilters: List<Pattern>
|
|
||||||
|
|
||||||
init {
|
|
||||||
val nullableAnnotations = annotationFilterList?.map { it.compilePatternOpt() } ?: listOf()
|
|
||||||
annotationFilterEnabled = nullableAnnotations.isNotEmpty()
|
|
||||||
annotationFilters = nullableAnnotations.filterNotNull()
|
|
||||||
}
|
|
||||||
|
|
||||||
private val classVisitor: ClassVisitor by lazy {
|
|
||||||
object : ClassVisitor(Opcodes.ASM5, super.getVisitor()) {
|
|
||||||
override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? {
|
|
||||||
recordAnnotation(null, RecordTypes.ANNOTATED_CLASS, desc)
|
|
||||||
return super.visitAnnotation(desc, visible)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private lateinit var currentClassSimpleName: String
|
|
||||||
|
|
||||||
private lateinit var currentPackageName: String
|
|
||||||
|
|
||||||
override fun getVisitor() = classVisitor
|
|
||||||
|
|
||||||
override fun getDelegate() = delegateClassBuilder
|
|
||||||
|
|
||||||
override fun defineClass(
|
|
||||||
origin: PsiElement?,
|
|
||||||
version: Int,
|
|
||||||
access: Int,
|
|
||||||
name: String,
|
|
||||||
signature: String?,
|
|
||||||
superName: String,
|
|
||||||
interfaces: Array<out String>
|
|
||||||
) {
|
|
||||||
val currentClassSimpleName = name.substringAfterLast('/')
|
|
||||||
val currentPackageName = name.substringBeforeLast('/', "").replace('/', '.')
|
|
||||||
|
|
||||||
this.currentClassSimpleName = currentClassSimpleName
|
|
||||||
this.currentPackageName = currentPackageName
|
|
||||||
|
|
||||||
if (supportInheritedAnnotations) {
|
|
||||||
recordClass(currentPackageName, currentClassSimpleName)
|
|
||||||
}
|
|
||||||
|
|
||||||
super.defineClass(origin, version, access, name, signature, superName, interfaces)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newField(
|
|
||||||
origin: JvmDeclarationOrigin,
|
|
||||||
access: Int,
|
|
||||||
name: String,
|
|
||||||
desc: String,
|
|
||||||
signature: String?,
|
|
||||||
value: Any?
|
|
||||||
): FieldVisitor {
|
|
||||||
return object : FieldVisitor(Opcodes.ASM5, super.newField(origin, access, name, desc, signature, value)) {
|
|
||||||
override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? {
|
|
||||||
recordAnnotation(name, RecordTypes.ANNOTATED_FIELD, desc)
|
|
||||||
return super.visitAnnotation(desc, visible)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun newMethod(
|
|
||||||
origin: JvmDeclarationOrigin,
|
|
||||||
access: Int,
|
|
||||||
name: String,
|
|
||||||
desc: String,
|
|
||||||
signature: String?,
|
|
||||||
exceptions: Array<out String>?
|
|
||||||
): MethodVisitor {
|
|
||||||
return object : MethodVisitor(Opcodes.ASM5, super.newMethod(origin, access, name, desc, signature, exceptions)) {
|
|
||||||
override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? {
|
|
||||||
recordAnnotation(name, RecordTypes.ANNOTATED_METHOD, desc)
|
|
||||||
return super.visitAnnotation(desc, visible)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isAnnotationHandled(annotationFqName: String): Boolean {
|
|
||||||
return if (annotationFilterEnabled)
|
|
||||||
annotationFilters.any { it.matcher(annotationFqName).matches() }
|
|
||||||
else annotationFqName != JvmAnnotationNames.METADATA_FQ_NAME.asString()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun recordClass(packageName: String, className: String) {
|
|
||||||
if (!isValidName(packageName) || !isValidName(className)) return
|
|
||||||
|
|
||||||
val packageNameId = if (!packageName.isEmpty())
|
|
||||||
shortenedPackageNameCache.save(packageName, writer)
|
|
||||||
else null
|
|
||||||
|
|
||||||
val outputClassName = getOutputClassName(packageNameId, className)
|
|
||||||
writer.write("${RecordTypes.CLASS_DECLARATION} $outputClassName\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun recordAnnotation(name: String?, type: String, annotationDesc: String) {
|
|
||||||
val annotationFqName = Type.getType(annotationDesc).className
|
|
||||||
if (!isAnnotationHandled(annotationFqName) || !isValidName(annotationFqName)) return
|
|
||||||
|
|
||||||
if (name != null && !isValidName(name)) return
|
|
||||||
|
|
||||||
try {
|
|
||||||
val packageName = this.currentPackageName
|
|
||||||
if (!isValidName(packageName)) return
|
|
||||||
|
|
||||||
val className = this.currentClassSimpleName
|
|
||||||
if (!isValidName(className)) return
|
|
||||||
|
|
||||||
val annotationId = shortenedAnnotationCache.save(annotationFqName, writer)
|
|
||||||
|
|
||||||
val packageNameId = if (!packageName.isEmpty())
|
|
||||||
shortenedPackageNameCache.save(packageName, writer)
|
|
||||||
else null
|
|
||||||
|
|
||||||
val outputClassName = getOutputClassName(packageNameId, className)
|
|
||||||
val elementName = if (name != null) " $name" else ""
|
|
||||||
|
|
||||||
writer.write("$type $annotationId $outputClassName$elementName\n")
|
|
||||||
}
|
|
||||||
catch (e: IOException) {
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isValidName(name: String): Boolean {
|
|
||||||
return ' ' !in name
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getOutputClassName(packageNameId: String?, className: String): String {
|
|
||||||
return if (packageNameId == null) className else "$packageNameId/$className"
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun String.compilePatternOpt(): Pattern? {
|
|
||||||
return try {
|
|
||||||
Pattern.compile(this)
|
|
||||||
}
|
|
||||||
catch (e: PatternSyntaxException) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ShortenedNameCache(val type: String) {
|
|
||||||
private val internalCache = hashMapOf<String, String>()
|
|
||||||
private var counter: Int = 0
|
|
||||||
|
|
||||||
fun save(name: String, writer: Writer): String {
|
|
||||||
return internalCache.getOrPut(name) {
|
|
||||||
val resultId = counter.toString()
|
|
||||||
writer.write("$type $name $resultId\n")
|
|
||||||
counter += 1
|
|
||||||
resultId
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class AnnotationCollectorExtension(
|
|
||||||
override val annotationFilterList: List<String>? = null,
|
|
||||||
private val outputFilename: String? = null,
|
|
||||||
supportInheritedAnnotations: Boolean
|
|
||||||
) : AnnotationCollectorExtensionBase(supportInheritedAnnotations) {
|
|
||||||
|
|
||||||
private var writerInternal: Writer? = null
|
|
||||||
|
|
||||||
override fun closeWriter() {
|
|
||||||
writerInternal?.close()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getWriter(diagnostic: DiagnosticSink): Writer {
|
|
||||||
return writerInternal ?: try {
|
|
||||||
with (File(outputFilename)) {
|
|
||||||
val parent = parentFile
|
|
||||||
if (!parent.exists()) parent.mkdirs()
|
|
||||||
writerInternal = bufferedWriter()
|
|
||||||
writerInternal!!
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e: IOException) {
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-99
@@ -1,99 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.annotation
|
|
||||||
|
|
||||||
import com.intellij.mock.MockProject
|
|
||||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
|
||||||
import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension
|
|
||||||
import org.jetbrains.kotlin.compiler.plugin.CliOption
|
|
||||||
import org.jetbrains.kotlin.compiler.plugin.CliOptionProcessingException
|
|
||||||
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
|
|
||||||
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
|
|
||||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
|
||||||
import org.jetbrains.kotlin.config.CompilerConfigurationKey
|
|
||||||
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
object AnnotationCollectorConfigurationKeys {
|
|
||||||
val ANNOTATION_FILTER_LIST: CompilerConfigurationKey<List<String>> =
|
|
||||||
CompilerConfigurationKey.create<List<String>>("annotation filter regular expressions")
|
|
||||||
val OUTPUT_FILENAME: CompilerConfigurationKey<String> =
|
|
||||||
CompilerConfigurationKey.create<String>("annotation file name")
|
|
||||||
val STUBS_PATH: CompilerConfigurationKey<String> =
|
|
||||||
CompilerConfigurationKey.create<String>("stubs output directory")
|
|
||||||
val INHERITED: CompilerConfigurationKey<String> =
|
|
||||||
CompilerConfigurationKey.create<String>("support inherited annotations")
|
|
||||||
}
|
|
||||||
|
|
||||||
class AnnotationCollectorCommandLineProcessor : CommandLineProcessor {
|
|
||||||
companion object {
|
|
||||||
val ANNOTATION_COLLECTOR_COMPILER_PLUGIN_ID: String = "org.jetbrains.kotlin.kapt"
|
|
||||||
|
|
||||||
val ANNOTATION_FILTER_LIST_OPTION: CliOption =
|
|
||||||
CliOption("annotations", "<path>", "Annotation filter regular expressions, separated by commas", required = false)
|
|
||||||
|
|
||||||
val OUTPUT_FILENAME_OPTION: CliOption =
|
|
||||||
CliOption("output", "<path>", "File in which annotated declarations will be placed", required = false)
|
|
||||||
|
|
||||||
val STUBS_PATH_OPTION: CliOption =
|
|
||||||
CliOption("stubs", "<path>", "Output path for stubs", required = false)
|
|
||||||
|
|
||||||
val INHERITED_ANNOTATIONS_OPTION: CliOption =
|
|
||||||
CliOption("inherited", "<true/false>",
|
|
||||||
"True if collecting Kotlin class names for inherited annotations is needed", required = false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override val pluginId: String = ANNOTATION_COLLECTOR_COMPILER_PLUGIN_ID
|
|
||||||
|
|
||||||
override val pluginOptions: Collection<CliOption> =
|
|
||||||
listOf(ANNOTATION_FILTER_LIST_OPTION, OUTPUT_FILENAME_OPTION, STUBS_PATH_OPTION, INHERITED_ANNOTATIONS_OPTION)
|
|
||||||
|
|
||||||
override fun processOption(option: CliOption, value: String, configuration: CompilerConfiguration) {
|
|
||||||
when (option) {
|
|
||||||
ANNOTATION_FILTER_LIST_OPTION -> {
|
|
||||||
val annotations = value.split(',').filter { !it.isEmpty() }.toList()
|
|
||||||
configuration.put(AnnotationCollectorConfigurationKeys.ANNOTATION_FILTER_LIST, annotations)
|
|
||||||
}
|
|
||||||
OUTPUT_FILENAME_OPTION -> configuration.put(AnnotationCollectorConfigurationKeys.OUTPUT_FILENAME, value)
|
|
||||||
STUBS_PATH_OPTION -> configuration.put(AnnotationCollectorConfigurationKeys.STUBS_PATH, value)
|
|
||||||
INHERITED_ANNOTATIONS_OPTION -> configuration.put(AnnotationCollectorConfigurationKeys.INHERITED, value)
|
|
||||||
else -> throw CliOptionProcessingException("Unknown option: ${option.name}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class AnnotationCollectorComponentRegistrar : ComponentRegistrar {
|
|
||||||
override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration) {
|
|
||||||
val supportInheritedAnnotations = "true" == (configuration.get(AnnotationCollectorConfigurationKeys.INHERITED) ?: "true")
|
|
||||||
|
|
||||||
val annotationFilterList = configuration.get(AnnotationCollectorConfigurationKeys.ANNOTATION_FILTER_LIST)
|
|
||||||
val outputFilename = configuration.get(AnnotationCollectorConfigurationKeys.OUTPUT_FILENAME)
|
|
||||||
if (outputFilename != null) {
|
|
||||||
val collectorExtension = AnnotationCollectorExtension(annotationFilterList, outputFilename, supportInheritedAnnotations)
|
|
||||||
ClassBuilderInterceptorExtension.registerExtension(project, collectorExtension)
|
|
||||||
}
|
|
||||||
|
|
||||||
val stubs = configuration.get(AnnotationCollectorConfigurationKeys.STUBS_PATH)
|
|
||||||
if (stubs != null) {
|
|
||||||
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
|
|
||||||
val reportOutputFiles = configuration.getBoolean(CommonConfigurationKeys.REPORT_OUTPUT_FILES)
|
|
||||||
AnalysisHandlerExtension.registerExtension(project, StubProducerExtension(File(stubs), messageCollector, reportOutputFiles))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-82
@@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.annotation
|
|
||||||
|
|
||||||
import com.intellij.openapi.project.Project
|
|
||||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
|
||||||
import org.jetbrains.kotlin.cli.common.output.outputUtils.writeAll
|
|
||||||
import org.jetbrains.kotlin.codegen.*
|
|
||||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
|
||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
|
|
||||||
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
|
|
||||||
import org.jetbrains.org.objectweb.asm.ClassWriter
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class StubProducerExtension(
|
|
||||||
private val stubsOutputDir: File,
|
|
||||||
private val messageCollector: MessageCollector,
|
|
||||||
private val reportOutputFiles: Boolean
|
|
||||||
) : AnalysisHandlerExtension {
|
|
||||||
override fun analysisCompleted(
|
|
||||||
project: Project,
|
|
||||||
module: ModuleDescriptor,
|
|
||||||
bindingTrace: BindingTrace,
|
|
||||||
files: Collection<KtFile>
|
|
||||||
): AnalysisResult? {
|
|
||||||
val generationState = GenerationState.Builder(
|
|
||||||
project,
|
|
||||||
StubClassBuilderFactory(),
|
|
||||||
module,
|
|
||||||
bindingTrace.bindingContext,
|
|
||||||
files.toList(),
|
|
||||||
CompilerConfiguration.EMPTY
|
|
||||||
).build()
|
|
||||||
|
|
||||||
KotlinCodegenFacade.compileCorrectFiles(generationState, CompilationErrorHandler.THROW_EXCEPTION)
|
|
||||||
|
|
||||||
if (!stubsOutputDir.exists()) stubsOutputDir.mkdirs()
|
|
||||||
generationState.factory.writeAll(stubsOutputDir, messageCollector, reportOutputFiles)
|
|
||||||
|
|
||||||
generationState.destroy()
|
|
||||||
return AnalysisResult.success(BindingContext.EMPTY, module, shouldGenerateCode = false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class StubClassBuilderFactory : ClassBuilderFactory {
|
|
||||||
|
|
||||||
override fun getClassBuilderMode() = ClassBuilderMode.KAPT
|
|
||||||
|
|
||||||
override fun newClassBuilder(origin: JvmDeclarationOrigin) = AbstractClassBuilder.Concrete(
|
|
||||||
ClassWriter(ClassWriter.COMPUTE_FRAMES or ClassWriter.COMPUTE_MAXS))
|
|
||||||
|
|
||||||
override fun asText(builder: ClassBuilder) = throw UnsupportedOperationException("BINARIES generator asked for text")
|
|
||||||
|
|
||||||
override fun asBytes(builder: ClassBuilder): ByteArray {
|
|
||||||
val visitor = builder.visitor as ClassWriter
|
|
||||||
return visitor.toByteArray()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun close() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-88
@@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.annotation
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
|
||||||
import org.jetbrains.kotlin.codegen.CodegenTestFiles
|
|
||||||
import org.jetbrains.kotlin.codegen.CodegenTestUtil
|
|
||||||
import org.jetbrains.kotlin.codegen.extensions.ClassBuilderInterceptorExtension
|
|
||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
|
||||||
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisHandlerExtension
|
|
||||||
import org.jetbrains.kotlin.test.*
|
|
||||||
import java.io.File
|
|
||||||
import java.io.StringWriter
|
|
||||||
|
|
||||||
abstract class AbstractAnnotationProcessorBoxTest : KotlinTestWithEnvironmentManagement() {
|
|
||||||
fun doTest(path: String) {
|
|
||||||
val testDir = File(path)
|
|
||||||
|
|
||||||
fun filesByExtension(ext: String) = testDir
|
|
||||||
.listFiles { file -> file.isFile && file.extension.equals(ext, ignoreCase = true) }
|
|
||||||
.sortedBy { it.name }
|
|
||||||
|
|
||||||
val testName = getTestName(true)
|
|
||||||
val ktFiles = filesByExtension("kt")
|
|
||||||
val supportInheritedAnnotations = testName.contains("inherited", ignoreCase = true)
|
|
||||||
val supportStubs = testName.contains("stubs", ignoreCase = true)
|
|
||||||
|
|
||||||
val javaFiles = filesByExtension("java")
|
|
||||||
val javaSourceRoot =
|
|
||||||
if (javaFiles.isNotEmpty()) {
|
|
||||||
KotlinTestUtils.tmpDir("java-files").also { javaSourceRoot ->
|
|
||||||
javaFiles.forEach { javaFile -> javaFile.copyTo(File(javaSourceRoot, javaFile.name)) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else null
|
|
||||||
|
|
||||||
val configuration = KotlinTestUtils.newConfiguration(
|
|
||||||
ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, listOf(KotlinTestUtils.getAnnotationsJar()), listOfNotNull(javaSourceRoot)
|
|
||||||
)
|
|
||||||
val environment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
|
||||||
val project = environment.project
|
|
||||||
|
|
||||||
val collectorExtension = AnnotationCollectorExtensionForTests(supportInheritedAnnotations)
|
|
||||||
ClassBuilderInterceptorExtension.registerExtension(project, collectorExtension)
|
|
||||||
|
|
||||||
if (supportStubs) {
|
|
||||||
val stubsDir = KotlinTestUtils.tmpDir("class-stubs")
|
|
||||||
val stubProducerExtension = StubProducerExtension(stubsDir, MessageCollector.NONE, false)
|
|
||||||
AnalysisHandlerExtension.registerExtension(project, stubProducerExtension)
|
|
||||||
}
|
|
||||||
|
|
||||||
val testFiles = ktFiles.map { KotlinTestUtils.createFile(it.name, KotlinTestUtils.doLoadFile(it), environment.project) }
|
|
||||||
|
|
||||||
CodegenTestUtil.generateFiles(environment, CodegenTestFiles.create(testFiles))
|
|
||||||
|
|
||||||
val actualAnnotations = collectorExtension.stringWriter.toString()
|
|
||||||
val expectedAnnotationsFile = File(path + "annotations.txt")
|
|
||||||
|
|
||||||
KotlinTestUtils.assertEqualsToFile(expectedAnnotationsFile, actualAnnotations)
|
|
||||||
}
|
|
||||||
|
|
||||||
private class AnnotationCollectorExtensionForTests(
|
|
||||||
supportInheritedAnnotations: Boolean
|
|
||||||
) : AnnotationCollectorExtensionBase(supportInheritedAnnotations) {
|
|
||||||
val stringWriter = StringWriter()
|
|
||||||
|
|
||||||
override fun getWriter(diagnostic: DiagnosticSink) = stringWriter
|
|
||||||
override fun closeWriter() {}
|
|
||||||
|
|
||||||
override val annotationFilterList = listOf<String>()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-136
@@ -1,136 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
|
||||||
* that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.annotation;
|
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
|
||||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
|
||||||
import org.jetbrains.kotlin.test.TargetBackend;
|
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
@TestMetadata("plugins/annotation-collector/testData/collectToFile")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
|
||||||
public class AnnotationProcessorBoxTestGenerated extends AbstractAnnotationProcessorBoxTest {
|
|
||||||
private void runTest(String testDataFilePath) throws Exception {
|
|
||||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testAllFilesPresentInCollectToFile() throws Exception {
|
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/annotation-collector/testData/collectToFile"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("annotatedGettersSetters")
|
|
||||||
public void testAnnotatedGettersSetters() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/annotatedGettersSetters/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("annotationInSameFile")
|
|
||||||
public void testAnnotationInSameFile() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/annotationInSameFile/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("anonymousClasses")
|
|
||||||
public void testAnonymousClasses() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/anonymousClasses/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("classAnnotations")
|
|
||||||
public void testClassAnnotations() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/classAnnotations/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("constructors")
|
|
||||||
public void testConstructors() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/constructors/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("defaultPackage")
|
|
||||||
public void testDefaultPackage() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/defaultPackage/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("fieldAnnotations")
|
|
||||||
public void testFieldAnnotations() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/fieldAnnotations/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("inheritedComplex")
|
|
||||||
public void testInheritedComplex() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/inheritedComplex/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("inheritedSimple")
|
|
||||||
public void testInheritedSimple() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/inheritedSimple/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("inheritedTopLevel")
|
|
||||||
public void testInheritedTopLevel() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/inheritedTopLevel/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("localClasses")
|
|
||||||
public void testLocalClasses() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/localClasses/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("localFunctions")
|
|
||||||
public void testLocalFunctions() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/localFunctions/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("methodAnnotations")
|
|
||||||
public void testMethodAnnotations() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/methodAnnotations/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("multiFileTopLevelAnnotated")
|
|
||||||
public void testMultiFileTopLevelAnnotated() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/multiFileTopLevelAnnotated/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("nestedClasses")
|
|
||||||
public void testNestedClasses() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/nestedClasses/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("platformStatic")
|
|
||||||
public void testPlatformStatic() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/platformStatic/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("retentionPoliciesJavaAnnotations")
|
|
||||||
public void testRetentionPoliciesJavaAnnotations() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/retentionPoliciesJavaAnnotations/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("retentionPoliciesJavaAnnotationsStubs")
|
|
||||||
public void testRetentionPoliciesJavaAnnotationsStubs() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/retentionPoliciesJavaAnnotationsStubs/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("retentionPoliciesKotlinAnnotations")
|
|
||||||
public void testRetentionPoliciesKotlinAnnotations() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/retentionPoliciesKotlinAnnotations/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("retentionPoliciesKotlinAnnotationsStubs")
|
|
||||||
public void testRetentionPoliciesKotlinAnnotationsStubs() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/retentionPoliciesKotlinAnnotationsStubs/");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("topLevelAnnotated")
|
|
||||||
public void testTopLevelAnnotated() throws Exception {
|
|
||||||
runTest("plugins/annotation-collector/testData/collectToFile/topLevelAnnotated/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
public data class SomeClass(val arg: Any? = null) {
|
|
||||||
|
|
||||||
public val immutableProperty: Int = 5
|
|
||||||
@java.lang.Deprecated get
|
|
||||||
|
|
||||||
public var mutableProperty: String = "String"
|
|
||||||
@java.lang.Deprecated get
|
|
||||||
@java.lang.Deprecated set
|
|
||||||
|
|
||||||
}
|
|
||||||
Vendored
-14
@@ -1,14 +0,0 @@
|
|||||||
a java.lang.Deprecated 0
|
|
||||||
p org.test 0
|
|
||||||
m 0 0/SomeClass getImmutableProperty
|
|
||||||
a org.jetbrains.annotations.NotNull 1
|
|
||||||
f 1 0/SomeClass mutableProperty
|
|
||||||
m 0 0/SomeClass getMutableProperty
|
|
||||||
m 1 0/SomeClass getMutableProperty
|
|
||||||
m 0 0/SomeClass setMutableProperty
|
|
||||||
a org.jetbrains.annotations.Nullable 2
|
|
||||||
f 2 0/SomeClass arg
|
|
||||||
m 2 0/SomeClass getArg
|
|
||||||
m 2 0/SomeClass component1
|
|
||||||
m 1 0/SomeClass copy
|
|
||||||
m 1 0/SomeClass copy$default
|
|
||||||
Vendored
-12
@@ -1,12 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
@Retention(AnnotationRetention.BINARY)
|
|
||||||
public annotation class SomeAnnotation
|
|
||||||
|
|
||||||
@SomeAnnotation public class SomeClass {
|
|
||||||
|
|
||||||
@SomeAnnotation public fun annotatedFunction() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-8
@@ -1,8 +0,0 @@
|
|||||||
a kotlin.annotation.Retention 0
|
|
||||||
p org.test 0
|
|
||||||
c 0 0/SomeAnnotation
|
|
||||||
a java.lang.annotation.Retention 1
|
|
||||||
c 1 0/SomeAnnotation
|
|
||||||
a org.test.SomeAnnotation 2
|
|
||||||
c 2 0/SomeClass
|
|
||||||
m 2 0/SomeClass annotatedFunction
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
a java.lang.Deprecated 0
|
|
||||||
p org.test 0
|
|
||||||
f 0 0/SomeClass$a$1 property
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
public class SomeClass {
|
|
||||||
|
|
||||||
private fun a() {
|
|
||||||
object : Any() {
|
|
||||||
@java.lang.Deprecated
|
|
||||||
val property: Int = 5
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
a java.lang.Deprecated 0
|
|
||||||
p org.test 0
|
|
||||||
c 0 0/SomeClass
|
|
||||||
c 0 0/SomeObject
|
|
||||||
-5
@@ -1,5 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
@java.lang.Deprecated public class SomeClass
|
|
||||||
|
|
||||||
@java.lang.Deprecated public object SomeObject
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
a java.lang.Deprecated 0
|
|
||||||
p org.test 0
|
|
||||||
m 0 0/SomeClass <init>
|
|
||||||
m 0 0/SomeClass <init>
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
public class SomeClass {
|
|
||||||
|
|
||||||
@java.lang.Deprecated constructor() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Deprecated constructor(s: String) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
a java.lang.Deprecated 0
|
|
||||||
f 0 SomeClass annotatedProperty
|
|
||||||
a org.jetbrains.annotations.Nullable 1
|
|
||||||
f 1 SomeClass annotatedProperty
|
|
||||||
m 1 SomeClass getAnnotatedProperty
|
|
||||||
m 0 SomeClass annotatedFunction
|
|
||||||
f 1 SomeClass arg
|
|
||||||
m 1 SomeClass getArg
|
|
||||||
m 1 SomeClass component1
|
|
||||||
a org.jetbrains.annotations.NotNull 2
|
|
||||||
m 2 SomeClass copy
|
|
||||||
m 2 SomeClass copy$default
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
data public class SomeClass(val arg: Any? = null) {
|
|
||||||
|
|
||||||
@java.lang.Deprecated public var annotatedProperty: String? = null
|
|
||||||
|
|
||||||
@java.lang.Deprecated public inline fun annotatedFunction() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
a java.lang.Deprecated 0
|
|
||||||
p org.test 0
|
|
||||||
f 0 0/SomeClass annotatedVal
|
|
||||||
a org.jetbrains.annotations.Nullable 1
|
|
||||||
f 1 0/SomeClass annotatedVal
|
|
||||||
m 1 0/SomeClass getAnnotatedVal
|
|
||||||
f 0 0/SomeClass annotatedVar
|
|
||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
public class SomeClass {
|
|
||||||
|
|
||||||
@java.lang.Deprecated
|
|
||||||
public val annotatedVal: String? = null
|
|
||||||
|
|
||||||
@java.lang.Deprecated
|
|
||||||
public var annotatedVar: Int = 5
|
|
||||||
|
|
||||||
}
|
|
||||||
-18
@@ -1,18 +0,0 @@
|
|||||||
p org.test 0
|
|
||||||
d 0/Ann1
|
|
||||||
a java.lang.annotation.Inherited 0
|
|
||||||
c 0 0/Ann1
|
|
||||||
a java.lang.annotation.Retention 1
|
|
||||||
c 1 0/Ann1
|
|
||||||
d 0/Ann2
|
|
||||||
c 0 0/Ann2
|
|
||||||
c 1 0/Ann2
|
|
||||||
d 0/D
|
|
||||||
d 0/C
|
|
||||||
d 0/B
|
|
||||||
a org.test.Ann2 2
|
|
||||||
c 2 0/B
|
|
||||||
d 0/A
|
|
||||||
a org.test.Ann1 3
|
|
||||||
c 3 0/A
|
|
||||||
d 0/A$DefaultImpls
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
import java.lang.annotation.Inherited
|
|
||||||
|
|
||||||
@Inherited
|
|
||||||
annotation class Ann1
|
|
||||||
|
|
||||||
@Inherited
|
|
||||||
annotation class Ann2
|
|
||||||
|
|
||||||
@Ann1
|
|
||||||
interface A
|
|
||||||
|
|
||||||
@Ann2
|
|
||||||
open class B : A
|
|
||||||
|
|
||||||
open class C : B()
|
|
||||||
|
|
||||||
class D : C()
|
|
||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
p org.test 0
|
|
||||||
d 0/Ann
|
|
||||||
a java.lang.annotation.Inherited 0
|
|
||||||
c 0 0/Ann
|
|
||||||
a java.lang.annotation.Retention 1
|
|
||||||
c 1 0/Ann
|
|
||||||
d 0/B
|
|
||||||
d 0/A
|
|
||||||
a org.test.Ann 2
|
|
||||||
c 2 0/A
|
|
||||||
d 0/A$DefaultImpls
|
|
||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
import java.lang.annotation.Inherited
|
|
||||||
|
|
||||||
@Inherited
|
|
||||||
annotation class Ann
|
|
||||||
|
|
||||||
@Ann
|
|
||||||
interface A
|
|
||||||
|
|
||||||
class B : A
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
p org.test 0
|
|
||||||
d 0/InheritedTopLevelKt
|
|
||||||
a org.jetbrains.annotations.NotNull 0
|
|
||||||
m 0 0/InheritedTopLevelKt getTopLevelProperty
|
|
||||||
-8
@@ -1,8 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
fun topLevelFunction() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
val topLevelProperty: String
|
|
||||||
get() = "text"
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
a java.lang.Deprecated 0
|
|
||||||
p org.test 0
|
|
||||||
c 0 0/SomeClass$someFunction$LocalClass
|
|
||||||
f 0 0/SomeClass$someFunction$LocalClass annotatedProperty
|
|
||||||
a org.jetbrains.annotations.Nullable 1
|
|
||||||
f 1 0/SomeClass$someFunction$LocalClass annotatedProperty
|
|
||||||
m 1 0/SomeClass$someFunction$LocalClass getAnnotatedProperty
|
|
||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
public class SomeClass {
|
|
||||||
|
|
||||||
public fun someFunction() {
|
|
||||||
@java.lang.Deprecated class LocalClass {
|
|
||||||
|
|
||||||
public @java.lang.Deprecated var annotatedProperty: String? = null
|
|
||||||
|
|
||||||
public inline fun annotatedFunction() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
a java.lang.Deprecated 0
|
|
||||||
p org.test 0
|
|
||||||
m 0 0/Class$method$1 invoke
|
|
||||||
m 0 0/LocalFunctionsKt$function$1 invoke
|
|
||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
class Class {
|
|
||||||
fun method() {
|
|
||||||
@java.lang.Deprecated fun localFunctionInsideMethod() {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun function() {
|
|
||||||
@java.lang.Deprecated fun localFunctionInsideFunction() {}
|
|
||||||
}
|
|
||||||
-8
@@ -1,8 +0,0 @@
|
|||||||
a java.lang.annotation.Retention 0
|
|
||||||
p org.test 0
|
|
||||||
c 0 0/Ann
|
|
||||||
a org.test.Ann 1
|
|
||||||
m 1 0/Child overridenWithAnnotation
|
|
||||||
m 1 0/Child childMethod
|
|
||||||
m 1 0/Parent overridenWithoutAnnotation
|
|
||||||
m 1 0/Parent notOverriden
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
annotation class Ann
|
|
||||||
|
|
||||||
open class Parent {
|
|
||||||
@Ann
|
|
||||||
open fun overridenWithoutAnnotation() {}
|
|
||||||
|
|
||||||
open fun overridenWithAnnotation() {}
|
|
||||||
|
|
||||||
@Ann
|
|
||||||
fun notOverriden() {}
|
|
||||||
|
|
||||||
open fun notAnnotated() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Child : Parent() {
|
|
||||||
override fun overridenWithoutAnnotation() {}
|
|
||||||
|
|
||||||
@Ann
|
|
||||||
override fun overridenWithAnnotation() {}
|
|
||||||
|
|
||||||
@Ann
|
|
||||||
fun childMethod() {}
|
|
||||||
}
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
annotation class Ann
|
|
||||||
Vendored
-10
@@ -1,10 +0,0 @@
|
|||||||
a org.test.Ann 0
|
|
||||||
p org.test 0
|
|
||||||
m 0 0/TestFacade__PartAKt funA
|
|
||||||
m 0 0/TestFacade__PartAKt valA$annotations
|
|
||||||
m 0 0/TestFacade__PartBKt funB
|
|
||||||
m 0 0/TestFacade__PartBKt valB$annotations
|
|
||||||
m 0 0/TestFacade funA
|
|
||||||
m 0 0/TestFacade funB
|
|
||||||
a java.lang.annotation.Retention 1
|
|
||||||
c 1 0/Ann
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
@file:JvmMultifileClass
|
|
||||||
@file:JvmName("TestFacade")
|
|
||||||
|
|
||||||
package org.test
|
|
||||||
|
|
||||||
@Ann
|
|
||||||
fun funA() {}
|
|
||||||
|
|
||||||
@Ann
|
|
||||||
val valA = 4
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
@file:JvmMultifileClass
|
|
||||||
@file:JvmName("TestFacade")
|
|
||||||
|
|
||||||
package org.test
|
|
||||||
|
|
||||||
@Ann
|
|
||||||
fun funB() {}
|
|
||||||
|
|
||||||
@Ann
|
|
||||||
val valB = 4
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
a java.lang.Deprecated 0
|
|
||||||
p org.test 0
|
|
||||||
c 0 0/SomeClass$SomeInnerObject
|
|
||||||
c 0 0/SomeClass$InnerClass
|
|
||||||
c 0 0/SomeClass$InnerClass$InnerClassInInnerClass
|
|
||||||
c 0 0/SomeClass$NestedClass
|
|
||||||
c 0 0/SomeClass$Companion
|
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
public class SomeClass {
|
|
||||||
|
|
||||||
@java.lang.Deprecated
|
|
||||||
companion object {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Deprecated
|
|
||||||
object SomeInnerObject {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Deprecated
|
|
||||||
inner class InnerClass {
|
|
||||||
|
|
||||||
@java.lang.Deprecated
|
|
||||||
inner class InnerClassInInnerClass {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@java.lang.Deprecated
|
|
||||||
class NestedClass {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
a kotlin.jvm.JvmStatic 0
|
|
||||||
p org.test 0
|
|
||||||
m 0 0/SomeClass$Companion a
|
|
||||||
m 0 0/SomeClass a
|
|
||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
public class SomeClass {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
@JvmStatic inline fun a() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.CLASS)
|
|
||||||
public @interface ClassAnnotation {}
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
public @interface DefaultAnnotation {}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface RuntimeAnnotation {}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
|
||||||
public @interface SourceAnnotation {}
|
|
||||||
plugins/annotation-collector/testData/collectToFile/retentionPoliciesJavaAnnotations/annotations.txt
Vendored
-6
@@ -1,6 +0,0 @@
|
|||||||
a DefaultAnnotation 0
|
|
||||||
c 0 DafaultUsage
|
|
||||||
a ClassAnnotation 1
|
|
||||||
c 1 ClassUsage
|
|
||||||
a RuntimeAnnotation 2
|
|
||||||
c 2 RuntimeUsage
|
|
||||||
Vendored
-11
@@ -1,11 +0,0 @@
|
|||||||
@DefaultAnnotation
|
|
||||||
class DafaultUsage
|
|
||||||
|
|
||||||
@SourceAnnotation
|
|
||||||
class SourceUsage
|
|
||||||
|
|
||||||
@ClassAnnotation
|
|
||||||
class ClassUsage
|
|
||||||
|
|
||||||
@RuntimeAnnotation
|
|
||||||
class RuntimeUsage
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.CLASS)
|
|
||||||
public @interface ClassAnnotation {}
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
public @interface DefaultAnnotation {}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface RuntimeAnnotation {}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
|
||||||
public @interface SourceAnnotation {}
|
|
||||||
-8
@@ -1,8 +0,0 @@
|
|||||||
a DefaultAnnotation 0
|
|
||||||
c 0 DafaultUsage
|
|
||||||
a SourceAnnotation 1
|
|
||||||
c 1 SourceUsage
|
|
||||||
a ClassAnnotation 2
|
|
||||||
c 2 ClassUsage
|
|
||||||
a RuntimeAnnotation 3
|
|
||||||
c 3 RuntimeUsage
|
|
||||||
Vendored
-11
@@ -1,11 +0,0 @@
|
|||||||
@DefaultAnnotation
|
|
||||||
class DafaultUsage
|
|
||||||
|
|
||||||
@SourceAnnotation
|
|
||||||
class SourceUsage
|
|
||||||
|
|
||||||
@ClassAnnotation
|
|
||||||
class ClassUsage
|
|
||||||
|
|
||||||
@RuntimeAnnotation
|
|
||||||
class RuntimeUsage
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
annotation class DefaultAnnotation
|
|
||||||
|
|
||||||
@Retention(AnnotationRetention.SOURCE)
|
|
||||||
annotation class SourceAnnotation
|
|
||||||
|
|
||||||
@Retention(AnnotationRetention.BINARY)
|
|
||||||
annotation class BinaryAnnotation
|
|
||||||
|
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
|
||||||
annotation class RuntimeAnnotation
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
a java.lang.annotation.Retention 0
|
|
||||||
c 0 DefaultAnnotation
|
|
||||||
a kotlin.annotation.Retention 1
|
|
||||||
c 1 SourceAnnotation
|
|
||||||
c 0 SourceAnnotation
|
|
||||||
c 1 BinaryAnnotation
|
|
||||||
c 0 BinaryAnnotation
|
|
||||||
c 1 RuntimeAnnotation
|
|
||||||
c 0 RuntimeAnnotation
|
|
||||||
a DefaultAnnotation 2
|
|
||||||
c 2 DafaultUsage
|
|
||||||
a BinaryAnnotation 3
|
|
||||||
c 3 BinaryUsage
|
|
||||||
a RuntimeAnnotation 4
|
|
||||||
c 4 RuntimeUsage
|
|
||||||
Vendored
-11
@@ -1,11 +0,0 @@
|
|||||||
@DefaultAnnotation
|
|
||||||
class DafaultUsage
|
|
||||||
|
|
||||||
@SourceAnnotation
|
|
||||||
class SourceUsage
|
|
||||||
|
|
||||||
@BinaryAnnotation
|
|
||||||
class BinaryUsage
|
|
||||||
|
|
||||||
@RuntimeAnnotation
|
|
||||||
class RuntimeUsage
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
annotation class DefaultAnnotation
|
|
||||||
|
|
||||||
@Retention(AnnotationRetention.SOURCE)
|
|
||||||
annotation class SourceAnnotation
|
|
||||||
|
|
||||||
@Retention(AnnotationRetention.BINARY)
|
|
||||||
annotation class BinaryAnnotation
|
|
||||||
|
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
|
||||||
annotation class RuntimeAnnotation
|
|
||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
a java.lang.annotation.Retention 0
|
|
||||||
c 0 DefaultAnnotation
|
|
||||||
a kotlin.annotation.Retention 1
|
|
||||||
c 1 SourceAnnotation
|
|
||||||
c 0 SourceAnnotation
|
|
||||||
c 1 BinaryAnnotation
|
|
||||||
c 0 BinaryAnnotation
|
|
||||||
c 1 RuntimeAnnotation
|
|
||||||
c 0 RuntimeAnnotation
|
|
||||||
a DefaultAnnotation 2
|
|
||||||
c 2 DafaultUsage
|
|
||||||
a SourceAnnotation 3
|
|
||||||
c 3 SourceUsage
|
|
||||||
a BinaryAnnotation 4
|
|
||||||
c 4 BinaryUsage
|
|
||||||
a RuntimeAnnotation 5
|
|
||||||
c 5 RuntimeUsage
|
|
||||||
plugins/annotation-collector/testData/collectToFile/retentionPoliciesKotlinAnnotationsStubs/usage.kt
Vendored
-11
@@ -1,11 +0,0 @@
|
|||||||
@DefaultAnnotation
|
|
||||||
class DafaultUsage
|
|
||||||
|
|
||||||
@SourceAnnotation
|
|
||||||
class SourceUsage
|
|
||||||
|
|
||||||
@BinaryAnnotation
|
|
||||||
class BinaryUsage
|
|
||||||
|
|
||||||
@RuntimeAnnotation
|
|
||||||
class RuntimeUsage
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
a java.lang.annotation.Retention 0
|
|
||||||
p org.test 0
|
|
||||||
c 0 0/Ann
|
|
||||||
a org.test.Ann 1
|
|
||||||
m 1 0/TopLevelAnnotatedKt someAnnotatedFunction
|
|
||||||
m 1 0/TopLevelAnnotatedKt someAnnotatedValue$annotations
|
|
||||||
-9
@@ -1,9 +0,0 @@
|
|||||||
package org.test
|
|
||||||
|
|
||||||
annotation class Ann
|
|
||||||
|
|
||||||
@Ann
|
|
||||||
fun someAnnotatedFunction() {}
|
|
||||||
|
|
||||||
@Ann
|
|
||||||
val someAnnotatedValue = 4
|
|
||||||
Reference in New Issue
Block a user