<commit_before>package pocketknife.internal.codegen;

import com.squareup.javawriter.JavaWriter;
import pocketknife.InjectArgument;
import pocketknife.SaveState;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import javax.tools.JavaFileObject;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import static javax.tools.Diagnostic.Kind.ERROR;

public class PocketKnifeProcessor extends AbstractProcessor {



    private Messager messager;
    private Filer filer;

    private BundleProcessor bundleProcessor;
    private IntentProcessor intentProcessor;

    @Override
    public SourceVersion getSupportedSourceVersion() {
        return SourceVersion.latestSupported();
    }

    @Override
    public synchronized void init(ProcessingEnvironment processingEnv) {
        super.init(processingEnv);
        messager = processingEnv.getMessager();
        filer = processingEnv.getFiler();
        Elements elements = processingEnv.getElementUtils();
        Types types = processingEnv.getTypeUtils();
        bundleProcessor = new BundleProcessor(messager, elements, types);
        intentProcessor = new IntentProcessor(messager, elements, types);
    }

    @Override
    public Set<String> getSupportedAnnotationTypes() {
        return new HashSet<String>(Arrays.asList(SaveState.class.getCanonicalName(), InjectArgument.class.getCanonicalName()));
    }

    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
        // Bundle Injections
        Map<TypeElement, BundleAdapterGenerator> bundleTargetClassMap = bundleProcessor.findAndParseTargets(roundEnv);

        for (Map.Entry<TypeElement, BundleAdapterGenerator> entry : bundleTargetClassMap.entrySet()) {
            TypeElement typeElement = entry.getKey();
            BundleAdapterGenerator bundleAdapterGenerator = entry.getValue();
            JavaWriter javaWriter = null;
            try {
                JavaFileObject jfo = filer.createSourceFile(bundleAdapterGenerator.getFqcn(), typeElement);
                javaWriter = new JavaWriter(jfo.openWriter());<commit_msg>Fixed annotation Processor not running when @InjectExtra is the only annotation used.<commit_after>package pocketknife.internal.codegen;

import com.squareup.javawriter.JavaWriter;
import pocketknife.InjectArgument;
import pocketknife.InjectExtra;
import pocketknife.SaveState;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Filer;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;
import javax.tools.JavaFileObject;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import static javax.tools.Diagnostic.Kind.ERROR;

public class PocketKnifeProcessor extends AbstractProcessor {


    private Messager messager;
    private Filer filer;

    private BundleProcessor bundleProcessor;
    private IntentProcessor intentProcessor;

    @Override
    public SourceVersion getSupportedSourceVersion() {
        return SourceVersion.latestSupported();
    }

    @Override
    public synchronized void init(ProcessingEnvironment processingEnv) {
        super.init(processingEnv);
        messager = processingEnv.getMessager();
        filer = processingEnv.getFiler();
        Elements elements = processingEnv.getElementUtils();
        Types types = processingEnv.getTypeUtils();
        bundleProcessor = new BundleProcessor(messager, elements, types);
        intentProcessor = new IntentProcessor(messager, elements, types);
    }

    @Override
    public Set<String> getSupportedAnnotationTypes() {
        return new HashSet<String>(Arrays.asList(SaveState.class.getCanonicalName(), InjectArgument.class.getCanonicalName(),
                InjectExtra.class.getCanonicalName()));
    }

    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
        // Bundle Injections
        Map<TypeElement, BundleAdapterGenerator> bundleTargetClassMap = bundleProcessor.findAndParseTargets(roundEnv);

        for (Map.Entry<TypeElement, BundleAdapterGenerator> entry : bundleTargetClassMap.entrySet()) {
            TypeElement typeElement = entry.getKey();
            BundleAdapterGenerator bundleAdapterGenerator = entry.getValue();
            JavaWriter javaWriter = null;
            try {
                JavaFileObject jfo = filer.createSourceFile(bundleAdapterGenerator.getFqcn(), typeElement);
                javaWriter = new JavaWriter(jfo.openWriter());
{'fraction_non_alphanumeric': 0.08366234254559128, 'fraction_numerical': 0.0, 'mean_word_length': 4.267326732673268, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6004376', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1308, 'n_words': 289}