// Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinderProcessor.java
// @SupportedAnnotationTypes({
//         "it.codingjam.lifecyclebinder.BindLifeCycle",
//         "it.codingjam.lifecyclebinder.RetainedObjectProvider",
//         "it.codingjam.lifecyclebinder.BindEvent"
// })
// public class LifeCycleBinderProcessor extends AbstractProcessor {
// 
//     private Types types;
//     private Elements elements;
//     private Filer filer;
//     private Messager messager;
// 
//     private ElementsCollector elementsCollector;
// 
//     private BinderGenerator binderGenerator;
// 
//     @Override
//     public synchronized void init(ProcessingEnvironment processingEnv) {
//         super.init(processingEnv);
//         types = processingEnv.getTypeUtils();
//         elements = processingEnv.getElementUtils();
//         filer = processingEnv.getFiler();
//         messager = processingEnv.getMessager();
//         elementsCollector = new ElementsCollector(messager, types, elements);
//         binderGenerator = new BinderGenerator(processingEnv, types, messager, elements);
//     }
// 
//     @Override
//     public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//         List<LifeCycleAwareInfo> elementsByClass = elementsCollector.createLifeCycleAwareElements(
//                 roundEnv.getElementsAnnotatedWith(BindLifeCycle.class),
//                 roundEnv.getElementsAnnotatedWith(RetainedObjectProvider.class),
//                 roundEnv.getElementsAnnotatedWith(BindEvent.class)
//         );
// 
//         if (elementsByClass == null) {
//             return true;
//         }
// 
//         elementsCollector.calculateNestedElements(elementsByClass);
// 
//         for (LifeCycleAwareInfo entry : elementsByClass) {
//             binderGenerator.generateBinder(entry);
//         }
//         return false;
//     }
// 
//     @Override public SourceVersion getSupportedSourceVersion() {
//         return SourceVersion.latestSupported();
//     }
// }


import com.google.testing.compile.JavaFileObjects;
import com.google.testing.compile.JavaSourceSubjectFactory;
import org.truth0.Truth;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import javax.tools.JavaFileObject;
import it.codingjam.lifecyclebinder.LifeCycleBinderProcessor;
            StringBuilder b = new StringBuilder();
            String s;
            while ((s = reader.readLine()) != null) {
                b.append(s).append("\n");
            }
            return JavaFileObjects.forSourceString(source, b.toString());
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException ignored) {
                }
            }
        }
    }

    public static void check(String name) {
        check(name, name);
    }

    public static void check(String name, String expected) {
        checkSingleFile(name, expected + "$LifeCycleBinder");
    }

    private static void checkSingleFile(String name, String expected) {
        JavaFileObject target = loadClass(name);
        Truth.ASSERT.about(JavaSourceSubjectFactory.javaSource())
                .that(target)
// Path: lifecyclebinder-processor/src/main/java/it/codingjam/lifecyclebinder/LifeCycleBinderProcessor.java
// @SupportedAnnotationTypes({
//         "it.codingjam.lifecyclebinder.BindLifeCycle",
//         "it.codingjam.lifecyclebinder.RetainedObjectProvider",
//         "it.codingjam.lifecyclebinder.BindEvent"
// })
// public class LifeCycleBinderProcessor extends AbstractProcessor {
// 
//     private Types types;
//     private Elements elements;
//     private Filer filer;
//     private Messager messager;
// 
//     private ElementsCollector elementsCollector;
// 
//     private BinderGenerator binderGenerator;
// 
//     @Override
//     public synchronized void init(ProcessingEnvironment processingEnv) {
//         super.init(processingEnv);
//         types = processingEnv.getTypeUtils();
//         elements = processingEnv.getElementUtils();
//         filer = processingEnv.getFiler();
//         messager = processingEnv.getMessager();
//         elementsCollector = new ElementsCollector(messager, types, elements);
//         binderGenerator = new BinderGenerator(processingEnv, types, messager, elements);
//     }
// 
//     @Override
//     public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
//         List<LifeCycleAwareInfo> elementsByClass = elementsCollector.createLifeCycleAwareElements(
//                 roundEnv.getElementsAnnotatedWith(BindLifeCycle.class),
//                 roundEnv.getElementsAnnotatedWith(RetainedObjectProvider.class),
//                 roundEnv.getElementsAnnotatedWith(BindEvent.class)
//         );
// 
//         if (elementsByClass == null) {
//             return true;
//         }
// 
//         elementsCollector.calculateNestedElements(elementsByClass);
// 
//         for (LifeCycleAwareInfo entry : elementsByClass) {
//             binderGenerator.generateBinder(entry);
//         }
//         return false;
//     }
// 
//     @Override public SourceVersion getSupportedSourceVersion() {
//         return SourceVersion.latestSupported();
//     }
// }


// Path: lifecyclebinder-processor/src/test/java/it/codingjam/lifecyclebinder/test/FileLoader.java
import com.google.testing.compile.JavaFileObjects;
import com.google.testing.compile.JavaSourceSubjectFactory;
import org.truth0.Truth;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import javax.tools.JavaFileObject;
import it.codingjam.lifecyclebinder.LifeCycleBinderProcessor;

            StringBuilder b = new StringBuilder();
            String s;
            while ((s = reader.readLine()) != null) {
                b.append(s).append("\n");
            }
            return JavaFileObjects.forSourceString(source, b.toString());
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException ignored) {
                }
            }
        }
    }

    public static void check(String name) {
        check(name, name);
    }

    public static void check(String name, String expected) {
        checkSingleFile(name, expected + "$LifeCycleBinder");
    }

    private static void checkSingleFile(String name, String expected) {
        JavaFileObject target = loadClass(name);
        Truth.ASSERT.about(JavaSourceSubjectFactory.javaSource())
                .that(target)
                .processedWith(new LifeCycleBinderProcessor())