Skip to content

Commit

Permalink
javax @generated replaced with custom @generated annotation (#17)
Browse files Browse the repository at this point in the history
JaCoCo detects and filters out generated methods by any annotation with simple name `Generated` and with retention `CLASS` or higher.
So we have to introduce our own `@Generated` to use on generated source files.
  • Loading branch information
Squiry authored Dec 12, 2022
1 parent 52b3a8f commit fd8156e
Show file tree
Hide file tree
Showing 60 changed files with 94 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ public class CommonClassNames {
public static final ClassName graphInterceptor = ClassName.get("ru.tinkoff.kora.application.graph", "GraphInterceptor");
public static final ClassName promisedProxy = ClassName.get("ru.tinkoff.kora.common", "PromisedProxy");
public static final ClassName refreshListener = ClassName.get("ru.tinkoff.kora.application.graph", "RefreshListener");

public static final ClassName koraGenerated = ClassName.get("ru.tinkoff.kora.common.annotation", "Generated");
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import ru.tinkoff.kora.annotation.processor.common.TagUtils;
import ru.tinkoff.kora.common.Component;
import ru.tinkoff.kora.common.Tag;
import ru.tinkoff.kora.common.annotation.Generated;

import javax.annotation.processing.Generated;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeKind;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import com.squareup.kotlinpoet.ksp.toClassName
import com.squareup.kotlinpoet.ksp.toTypeName
import com.squareup.kotlinpoet.ksp.toTypeVariableName
import ru.tinkoff.kora.common.Component
import ru.tinkoff.kora.common.annotation.Generated
import ru.tinkoff.kora.ksp.common.KoraSymbolProcessingEnv
import ru.tinkoff.kora.ksp.common.exception.ProcessingErrorException
import ru.tinkoff.kora.ksp.common.findMethods
import ru.tinkoff.kora.ksp.common.makeTagAnnotationSpec
import ru.tinkoff.kora.ksp.common.parseTags
import javax.annotation.processing.Generated

@KspExperimental
class AopProcessor(private val aspects: List<KoraAspect>, private val resolver: Resolver) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import ru.tinkoff.kora.annotation.processor.common.AbstractKoraProcessor;
import ru.tinkoff.kora.annotation.processor.common.MethodUtils;
import ru.tinkoff.kora.cache.annotation.*;
import ru.tinkoff.kora.common.annotation.Generated;

import javax.annotation.processing.Filer;
import javax.annotation.processing.Generated;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Element;
Expand Down Expand Up @@ -114,7 +114,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
import java.util.Arrays;
import java.lang.Object;
import ru.tinkoff.kora.cache.CacheKey;
import javax.annotation.processing.Generated;
import ru.tinkoff.kora.common.annotation.Generated;
@%s("%s")
public record %s(%s) implements CacheKey {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.squareup.kotlinpoet.ksp.writeTo
import ru.tinkoff.kora.cache.CacheKey
import ru.tinkoff.kora.cache.annotation.*
import ru.tinkoff.kora.cache.symbol.processor.MethodUtils.Companion.getParameters
import ru.tinkoff.kora.common.annotation.Generated
import ru.tinkoff.kora.ksp.common.BaseSymbolProcessor
import ru.tinkoff.kora.ksp.common.FunctionUtils.isFlow
import ru.tinkoff.kora.ksp.common.FunctionUtils.isFlux
Expand All @@ -22,7 +23,6 @@ import ru.tinkoff.kora.ksp.common.exception.ProcessingError
import ru.tinkoff.kora.ksp.common.exception.ProcessingErrorException
import ru.tinkoff.kora.ksp.common.visitFunction
import java.io.IOException
import javax.annotation.processing.Generated

@KspExperimental
class CacheKeySymbolProcessor(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ru.tinkoff.kora.common.annotation;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* The Generated annotation is used to mark source code that has been generated.
*/
@Retention(RUNTIME)
@Target(TYPE)
public @interface Generated {

/**
* The value element must have the name of the code generator.
* The recommended convention is to use the fully qualified name of the code generator. For example: com.acme.generator.CodeGen.
*
* @return The name of the code generator
*/
String[] value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.tinkoff.kora.annotation.processor.common.CommonUtils;
import ru.tinkoff.kora.common.annotation.Generated;
import ru.tinkoff.kora.config.annotation.processor.exception.NewRoundWantedException;
import ru.tinkoff.kora.config.common.extractor.ConfigValueExtractor;
import ru.tinkoff.kora.config.common.extractor.ConfigValueUtils;
import ru.tinkoff.kora.config.common.extractor.ObjectConfigValueExtractor;

import javax.annotation.Nullable;
import javax.annotation.processing.Generated;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.ExecutableElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import ru.tinkoff.kora.annotation.processor.common.CommonUtils;
import ru.tinkoff.kora.common.Module;
import ru.tinkoff.kora.common.Tag;
import ru.tinkoff.kora.common.annotation.Generated;
import ru.tinkoff.kora.config.annotation.processor.exception.NewRoundWantedException;
import ru.tinkoff.kora.config.common.ConfigRoot;
import ru.tinkoff.kora.config.common.extractor.ConfigValueExtractor;

import javax.annotation.processing.Generated;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import ru.tinkoff.kora.annotation.processor.common.AbstractKoraProcessor;
import ru.tinkoff.kora.annotation.processor.common.CommonUtils;
import ru.tinkoff.kora.common.Module;
import ru.tinkoff.kora.common.annotation.Generated;
import ru.tinkoff.kora.config.common.ConfigSource;
import ru.tinkoff.kora.config.common.extractor.ConfigValueExtractor;

import javax.annotation.processing.Generated;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.Modifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import com.typesafe.config.ConfigList
import com.typesafe.config.ConfigObject
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import ru.tinkoff.kora.common.annotation.Generated
import ru.tinkoff.kora.config.common.extractor.ConfigValueExtractor
import ru.tinkoff.kora.config.common.extractor.ConfigValueUtils
import ru.tinkoff.kora.config.common.extractor.ObjectConfigValueExtractor
Expand All @@ -25,7 +26,6 @@ import ru.tinkoff.kora.ksp.common.getOuterClassesAsPrefix
import java.time.Duration
import java.time.Period
import java.time.temporal.TemporalAmount
import javax.annotation.processing.Generated

class ConfigParserGenerator(
private val resolver: Resolver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import com.squareup.kotlinpoet.ksp.toTypeName
import com.typesafe.config.Config
import ru.tinkoff.kora.common.Module
import ru.tinkoff.kora.common.Tag
import ru.tinkoff.kora.common.annotation.Generated
import ru.tinkoff.kora.config.common.ConfigRoot
import ru.tinkoff.kora.config.common.extractor.ConfigValueExtractor
import ru.tinkoff.kora.config.ksp.exception.NewRoundWantedException
import ru.tinkoff.kora.ksp.common.parseTagValue
import javax.annotation.processing.Generated

@KspExperimental
class ConfigRootModuleGenerator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ import com.google.devtools.ksp.processing.*
import com.google.devtools.ksp.symbol.ClassKind
import com.google.devtools.ksp.symbol.KSAnnotated
import com.google.devtools.ksp.symbol.KSClassDeclaration
import com.google.devtools.ksp.validate
import com.squareup.kotlinpoet.*
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
import com.squareup.kotlinpoet.ksp.addOriginatingKSFile
import com.squareup.kotlinpoet.ksp.toClassName
import com.squareup.kotlinpoet.ksp.writeTo
import com.typesafe.config.Config
import ru.tinkoff.kora.common.Module
import ru.tinkoff.kora.common.annotation.Generated
import ru.tinkoff.kora.config.common.ConfigSource
import ru.tinkoff.kora.config.common.extractor.ConfigValueExtractor
import ru.tinkoff.kora.ksp.common.BaseSymbolProcessor
import ru.tinkoff.kora.ksp.common.visitClass
import java.io.IOException
import javax.annotation.processing.Generated

class ConfigSourceSymbolProcessor(
environment: SymbolProcessorEnvironment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@
import org.slf4j.LoggerFactory;
import ru.tinkoff.kora.annotation.processor.common.CommonUtils;
import ru.tinkoff.kora.annotation.processor.common.ProcessingErrorException;
import ru.tinkoff.kora.common.annotation.Generated;
import ru.tinkoff.kora.database.annotation.processor.cassandra.CassandraRepositoryGenerator;
import ru.tinkoff.kora.database.annotation.processor.jdbc.JdbcRepositoryGenerator;
import ru.tinkoff.kora.database.annotation.processor.r2dbc.R2DbcRepositoryGenerator;
import ru.tinkoff.kora.database.annotation.processor.vertx.VertxRepositoryGenerator;

import javax.annotation.Nullable;
import javax.annotation.processing.Generated;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Types;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.*;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.List;

public class RepositoryBuilder {
private static final Logger log = LoggerFactory.getLogger(RepositoryBuilder.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.squareup.javapoet.*;
import ru.tinkoff.kora.annotation.processor.common.CommonUtils;
import ru.tinkoff.kora.common.annotation.Generated;
import ru.tinkoff.kora.database.annotation.processor.DbEntityReadHelper;
import ru.tinkoff.kora.database.annotation.processor.cassandra.CassandraNativeTypes;
import ru.tinkoff.kora.database.annotation.processor.cassandra.CassandraTypes;
Expand All @@ -11,7 +12,6 @@

import javax.annotation.Nullable;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Generated;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Modifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.squareup.javapoet.*;
import ru.tinkoff.kora.annotation.processor.common.CommonUtils;
import ru.tinkoff.kora.annotation.processor.common.GenericTypeResolver;
import ru.tinkoff.kora.common.annotation.Generated;
import ru.tinkoff.kora.database.annotation.processor.DbEntityReadHelper;
import ru.tinkoff.kora.database.annotation.processor.entity.DbEntity;
import ru.tinkoff.kora.database.annotation.processor.jdbc.JdbcNativeTypes;
Expand All @@ -12,7 +13,6 @@

import javax.annotation.Nullable;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Generated;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.ElementKind;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.squareup.javapoet.*;
import ru.tinkoff.kora.annotation.processor.common.CommonUtils;
import ru.tinkoff.kora.common.annotation.Generated;
import ru.tinkoff.kora.database.annotation.processor.DbEntityReadHelper;
import ru.tinkoff.kora.database.annotation.processor.entity.DbEntity;
import ru.tinkoff.kora.database.annotation.processor.r2dbc.R2dbcNativeTypes;
Expand All @@ -11,7 +12,6 @@

import javax.annotation.Nullable;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Generated;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Modifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.squareup.javapoet.*;
import ru.tinkoff.kora.annotation.processor.common.CommonUtils;
import ru.tinkoff.kora.common.annotation.Generated;
import ru.tinkoff.kora.database.annotation.processor.DbEntityReadHelper;
import ru.tinkoff.kora.database.annotation.processor.entity.DbEntity;
import ru.tinkoff.kora.database.annotation.processor.vertx.VertxNativeTypes;
Expand All @@ -11,7 +12,6 @@

import javax.annotation.Nullable;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Generated;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Modifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
import com.squareup.kotlinpoet.ksp.toClassName
import com.squareup.kotlinpoet.ksp.toTypeName
import com.squareup.kotlinpoet.ksp.writeTo
import ru.tinkoff.kora.common.annotation.Generated
import ru.tinkoff.kora.database.symbol.processor.DbEntityReader
import ru.tinkoff.kora.database.symbol.processor.cassandra.CassandraNativeTypes
import ru.tinkoff.kora.database.symbol.processor.cassandra.CassandraTypes
Expand All @@ -18,7 +19,6 @@ import ru.tinkoff.kora.kora.app.ksp.extension.ExtensionResult
import ru.tinkoff.kora.kora.app.ksp.extension.KoraExtension
import ru.tinkoff.kora.ksp.common.CommonClassNames.isList
import ru.tinkoff.kora.ksp.common.getOuterClassesAsPrefix
import javax.annotation.processing.Generated

//CassandraRowMapper<T>
//CassandraResultSetMapper<List<T>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.squareup.kotlinpoet.*
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
import com.squareup.kotlinpoet.ksp.toTypeName
import com.squareup.kotlinpoet.ksp.writeTo
import ru.tinkoff.kora.common.annotation.Generated
import ru.tinkoff.kora.database.symbol.processor.DbEntityReader
import ru.tinkoff.kora.database.symbol.processor.jdbc.JdbcNativeTypes
import ru.tinkoff.kora.database.symbol.processor.jdbc.JdbcTypes
Expand All @@ -18,7 +19,6 @@ import ru.tinkoff.kora.kora.app.ksp.extension.KoraExtension
import ru.tinkoff.kora.ksp.common.CommonClassNames.isList
import ru.tinkoff.kora.ksp.common.KotlinPoetUtils.controlFlow
import ru.tinkoff.kora.ksp.common.getOuterClassesAsPrefix
import javax.annotation.processing.Generated

// JdbcRowMapper<T>
// JdbcResultSetMapper<List<T>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
import com.squareup.kotlinpoet.ksp.toClassName
import com.squareup.kotlinpoet.ksp.toTypeName
import com.squareup.kotlinpoet.ksp.writeTo
import ru.tinkoff.kora.common.annotation.Generated
import ru.tinkoff.kora.database.symbol.processor.DbEntityReader
import ru.tinkoff.kora.database.symbol.processor.model.DbEntity
import ru.tinkoff.kora.database.symbol.processor.r2dbc.R2dbcNativeTypes
import ru.tinkoff.kora.database.symbol.processor.r2dbc.R2dbcTypes
import ru.tinkoff.kora.kora.app.ksp.extension.ExtensionResult
import ru.tinkoff.kora.kora.app.ksp.extension.KoraExtension
import ru.tinkoff.kora.ksp.common.getOuterClassesAsPrefix
import javax.annotation.processing.Generated

//R2dbcRowMapper<T>
class R2dbcTypesExtension(val resolver: Resolver, val kspLogger: KSPLogger, val codeGenerator: CodeGenerator) : KoraExtension {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.squareup.kotlinpoet.*
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
import com.squareup.kotlinpoet.ksp.toTypeName
import com.squareup.kotlinpoet.ksp.writeTo
import ru.tinkoff.kora.common.annotation.Generated
import ru.tinkoff.kora.database.symbol.processor.DbEntityReader
import ru.tinkoff.kora.database.symbol.processor.model.DbEntity
import ru.tinkoff.kora.database.symbol.processor.vertx.VertxNativeTypes
Expand All @@ -17,7 +18,6 @@ import ru.tinkoff.kora.kora.app.ksp.extension.ExtensionResult
import ru.tinkoff.kora.kora.app.ksp.extension.KoraExtension
import ru.tinkoff.kora.ksp.common.KotlinPoetUtils.controlFlow
import ru.tinkoff.kora.ksp.common.getOuterClassesAsPrefix
import javax.annotation.processing.Generated

//RowMapper<T>
//RowSetMapper<List<T>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import ru.tinkoff.kora.annotation.processor.common.CommonUtils;
import ru.tinkoff.kora.annotation.processor.common.ComparableTypeMirror;
import ru.tinkoff.kora.common.Tag;
import ru.tinkoff.kora.common.annotation.Generated;
import ru.tinkoff.kora.http.client.common.HttpClient;
import ru.tinkoff.kora.http.client.common.HttpClientException;
import ru.tinkoff.kora.http.client.common.HttpClientResponseException;
Expand All @@ -19,7 +20,6 @@
import ru.tinkoff.kora.http.common.annotation.HttpRoute;

import javax.annotation.Nullable;
import javax.annotation.processing.Generated;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.*;
import javax.lang.model.type.DeclaredType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import com.squareup.javapoet.*;
import com.typesafe.config.Config;
import ru.tinkoff.kora.common.Module;
import ru.tinkoff.kora.common.annotation.Generated;
import ru.tinkoff.kora.config.common.extractor.ConfigValueExtractor;
import ru.tinkoff.kora.http.client.common.annotation.HttpClient;

import javax.annotation.processing.Generated;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.squareup.kotlinpoet.ksp.toTypeParameterResolver
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import ru.tinkoff.kora.common.Tag
import ru.tinkoff.kora.common.annotation.Generated
import ru.tinkoff.kora.http.client.common.HttpClient
import ru.tinkoff.kora.http.client.common.HttpClientException
import ru.tinkoff.kora.http.client.common.HttpClientResponseException
Expand All @@ -27,14 +28,15 @@ import ru.tinkoff.kora.http.common.annotation.HttpRoute
import ru.tinkoff.kora.kora.app.ksp.extendsKeepAop
import ru.tinkoff.kora.kora.app.ksp.hasAopAnnotations
import ru.tinkoff.kora.kora.app.ksp.overridingKeepAop
import ru.tinkoff.kora.ksp.common.*
import ru.tinkoff.kora.ksp.common.AnnotationUtils.findAnnotation
import ru.tinkoff.kora.ksp.common.AnnotationUtils.findValue
import ru.tinkoff.kora.ksp.common.KotlinPoetUtils.controlFlow
import ru.tinkoff.kora.ksp.common.KotlinPoetUtils.writeTagValue
import ru.tinkoff.kora.ksp.common.KspCommonUtils.findRepeatableAnnotation
import ru.tinkoff.kora.ksp.common.MappingData
import ru.tinkoff.kora.ksp.common.parseAnnotationValue
import ru.tinkoff.kora.ksp.common.parseMappingData
import java.util.*
import javax.annotation.processing.Generated

@KspExperimental
class ClientClassGenerator(private val resolver: Resolver) {
Expand Down
Loading

0 comments on commit fd8156e

Please sign in to comment.