net.ltgt.gradle.incap.IncrementalAnnotationProcessorType Java Examples
The following examples show how to use
net.ltgt.gradle.incap.IncrementalAnnotationProcessorType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IncrementalExtensionTest.java From auto with Apache License 2.0 | 6 votes |
@Test public void builtInExtensionsAreIsolating() { ImmutableList<AutoValueExtension> builtInExtensions = AutoValueProcessor.extensionsFromLoader(AutoValueProcessor.class.getClassLoader()); // These are the current built-in extensions. We will update this test if we add more. // The (Object) cast is because otherwise the inferred type is Class<?>, and we can't match // that <?> with the class literals here. Even if we cast them to Class<?> it will be a // different <?>. assertThat(builtInExtensions) .comparingElementsUsing(transforming(e -> (Object) e.getClass(), "is class")) .containsExactly(MemoizeExtension.class, SerializableAutoValueExtension.class); AutoValueProcessor processor = new AutoValueProcessor(builtInExtensions); assertThat(processor.getSupportedOptions()) .contains(IncrementalAnnotationProcessorType.ISOLATING.getProcessorOption()); }
Example #2
Source File: IncrementalAnnotationProcessorProcessor.java From gradle-incap-helper with Apache License 2.0 | 5 votes |
private void processAnnotations(RoundEnvironment roundEnv) { TypeElement processor = processingEnv.getElementUtils().getTypeElement(Processor.class.getCanonicalName()); TypeElement abstractProcessor = processingEnv.getElementUtils().getTypeElement(AbstractProcessor.class.getCanonicalName()); for (Element e : roundEnv.getElementsAnnotatedWith(IncrementalAnnotationProcessor.class)) { if (!checkAnnotatedElement(e, processor)) { continue; } IncrementalAnnotationProcessorType processorType = e.getAnnotation(IncrementalAnnotationProcessor.class).value(); if (processorType == IncrementalAnnotationProcessorType.DYNAMIC && processingEnv.getTypeUtils().isSubtype(e.asType(), abstractProcessor.asType())) { Element getSupportedOptions = processingEnv.getElementUtils().getAllMembers((TypeElement) e).stream() .filter( method -> method.getKind() == ElementKind.METHOD && method.getSimpleName().contentEquals(GET_SUPPORTED_OPTIONS) && ((ExecutableElement) method).getParameters().isEmpty()) .findFirst() .orElseThrow(AssertionError::new); if (abstractProcessor.equals(getSupportedOptions.getEnclosingElement())) { warning( "Dynamic incremental annotation processor should override " + GET_SUPPORTED_OPTIONS + "()", e); } } processors.put( processingEnv.getElementUtils().getBinaryName((TypeElement) e).toString(), processorType); } }
Example #3
Source File: AutoValueProcessor.java From auto with Apache License 2.0 | 5 votes |
private static ImmutableSet<String> optionsFor( AutoValueExtension.IncrementalExtensionType incrementalType) { switch (incrementalType) { case ISOLATING: return ImmutableSet.of(IncrementalAnnotationProcessorType.ISOLATING.getProcessorOption()); case AGGREGATING: return ImmutableSet.of(IncrementalAnnotationProcessorType.AGGREGATING.getProcessorOption()); case UNKNOWN: return ImmutableSet.of(); } throw new AssertionError(incrementalType); }
Example #4
Source File: IncrementalExtensionTest.java From auto with Apache License 2.0 | 5 votes |
@Test public void customExtensionsAreNotIsolatingByDefault() { AutoValueExtension nonIsolatingExtension = new NonIsolatingExtension(); assertThat(nonIsolatingExtension.incrementalType((ProcessingEnvironment) null)) .isEqualTo(IncrementalExtensionType.UNKNOWN); ImmutableList<AutoValueExtension> extensions = ImmutableList.<AutoValueExtension>builder() .addAll(AutoValueProcessor.extensionsFromLoader(AutoValueProcessor.class.getClassLoader())) .add(nonIsolatingExtension) .build(); AutoValueProcessor processor = new AutoValueProcessor(extensions); assertThat(processor.getSupportedOptions()) .doesNotContain(IncrementalAnnotationProcessorType.ISOLATING.getProcessorOption()); }
Example #5
Source File: IncrementalExtensionTest.java From auto with Apache License 2.0 | 5 votes |
@Test public void customExtensionsCanBeIsolating() { AutoValueExtension isolatingExtension = new IsolatingExtension(); assertThat(isolatingExtension.incrementalType((ProcessingEnvironment) null)) .isEqualTo(IncrementalExtensionType.ISOLATING); ImmutableList<AutoValueExtension> extensions = ImmutableList.<AutoValueExtension>builder() .addAll(AutoValueProcessor.extensionsFromLoader(AutoValueProcessor.class.getClassLoader())) .add(isolatingExtension) .build(); AutoValueProcessor processor = new AutoValueProcessor(extensions); assertThat(processor.getSupportedOptions()) .contains(IncrementalAnnotationProcessorType.ISOLATING.getProcessorOption()); }
Example #6
Source File: ButterKnifeProcessor.java From butterknife with Apache License 2.0 | 5 votes |
@Override public Set<String> getSupportedOptions() { ImmutableSet.Builder<String> builder = ImmutableSet.builder(); builder.add(OPTION_SDK_INT, OPTION_DEBUGGABLE); if (trees != null) { builder.add(IncrementalAnnotationProcessorType.ISOLATING.getProcessorOption()); } return builder.build(); }