derive4j / derive4j

@@ -19,6 +19,7 @@
Loading
19 19
package org.derive4j.processor;
20 20
21 21
import com.google.auto.service.AutoService;
22 +
import com.squareup.javapoet.AnnotationSpec;
22 23
import com.squareup.javapoet.ClassName;
23 24
import com.squareup.javapoet.JavaFile;
24 25
import com.squareup.javapoet.MethodSpec;
@@ -104,7 +105,10 @@
Loading
104 105
105 106
    deriveConfigBuilder = new DeriveConfigBuilder(processingEnv.getElementUtils());
106 107
107 -
    deriveUtils = new DeriveUtilsImpl(processingEnv.getElementUtils(), processingEnv.getTypeUtils(),
108 +
    deriveUtils = new DeriveUtilsImpl(
109 +
        processingEnv.getElementUtils(),
110 +
        processingEnv.getTypeUtils(),
111 +
        processingEnv.getSourceVersion(),
108 112
        deriveConfigBuilder);
109 113
    builtinDerivator = BuiltinDerivator.derivator(deriveUtils);
110 114
    adtParser = new AdtParser(deriveUtils);
@@ -223,6 +227,11 @@
Loading
223 227
        .addFields(getFields(codeSpec))
224 228
        .addMethods(getMethods(codeSpec));
225 229
230 +
    deriveUtils.generatedAnnotation()
231 +
        .ifPresent(annotation -> builder.addAnnotation(AnnotationSpec.builder(ClassName.get(annotation))
232 +
            .addMember("value", "$S", getClass().getCanonicalName())
233 +
            .build()));
234 +
226 235
    deriveConfig.targetClass().extend().ifPresent(cn -> {
227 236
      if (deriveUtils.findTypeElement(cn).get().getKind().isInterface()) {
228 237
        builder.addSuperinterface(cn);

@@ -18,6 +18,7 @@
Loading
18 18
 */
19 19
package org.derive4j.processor;
20 20
21 +
import com.google.auto.common.GeneratedAnnotations;
21 22
import com.squareup.javapoet.AnnotationSpec;
22 23
import com.squareup.javapoet.ClassName;
23 24
import com.squareup.javapoet.CodeBlock;
@@ -42,6 +43,7 @@
Loading
42 43
import java.util.stream.Collectors;
43 44
import java.util.stream.IntStream;
44 45
import java.util.stream.Stream;
46 +
import javax.lang.model.SourceVersion;
45 47
import javax.lang.model.element.ElementKind;
46 48
import javax.lang.model.element.ExecutableElement;
47 49
import javax.lang.model.element.Modifier;
@@ -145,6 +147,7 @@
Loading
145 147
146 148
  private final Elements            Elements;
147 149
  private final Types               Types;
150 +
  private final SourceVersion       SourceVersion;
148 151
  private final DeriveConfigBuilder deriveConfigBuilder;
149 152
  private final ObjectModel         objectModel;
150 153
@@ -153,10 +156,12 @@
Loading
153 156
  private final Function<Flavour, OptionModel>           optionModel;
154 157
  private final Function<Flavour, Optional<EitherModel>> eitherModel;
155 158
156 -
  DeriveUtilsImpl(Elements Elements, Types Types, DeriveConfigBuilder deriveConfigBuilder) {
159 +
  DeriveUtilsImpl(
160 +
      Elements Elements, Types Types, SourceVersion SourceVersion, DeriveConfigBuilder deriveConfigBuilder) {
157 161
158 162
    this.Elements = Elements;
159 163
    this.Types = Types;
164 +
    this.SourceVersion = SourceVersion;
160 165
    this.deriveConfigBuilder = deriveConfigBuilder;
161 166
162 167
    TypeElement object = Elements.getTypeElement(Object.class.getName());
@@ -383,6 +388,10 @@
Loading
383 388
    return asDeclaredType(typeMirror).map(DeclaredType::asElement).flatMap(asTypeElement::visit);
384 389
  }
385 390
391 +
  public Optional<TypeElement> generatedAnnotation() {
392 +
    return GeneratedAnnotations.generatedAnnotation(Elements, SourceVersion);
393 +
  }
394 +
386 395
  @Override
387 396
  public boolean isWildcarded(TypeMirror typeMirror) {
388 397
    List<? extends TypeMirror> targs = asDeclaredType(typeMirror).map(DeclaredType::getTypeArguments)
Files Complexity Coverage
annotation/src/main/java/org/derive4j 100.00% 85.10%
processor-api/src/main/java/org/derive4j/processor/api 82.96% 69.56%
processor/src/main/java/org/derive4j/processor 83.80% 91.64%
Project Totals (56 files) 83.75% 89.99%
264.2
TRAVIS_JDK_VERSION=openjdk12
TRAVIS_OS_NAME=linux
1
ignore:
2
  - "examples/"
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading