use of javax.tools.JavaFileObject in project epoxy by airbnb.
the class ConfigTest method testConfigRequireHashCodeIterableFails.
@Test
public void testConfigRequireHashCodeIterableFails() {
JavaFileObject model = forResource("ModelRequiresHashCodeIterableFails.java");
assert_().about(javaSources()).that(asList(CONFIG_CLASS_REQUIRE_HASH, model)).processedWith(new EpoxyProcessor()).failsToCompile().withErrorContaining("Type in Iterable does not implement hashCode");
}
use of javax.tools.JavaFileObject in project epoxy by airbnb.
the class EpoxyProcessorTest method testModelWithFinalClassFails.
@Test
public void testModelWithFinalClassFails() {
JavaFileObject model = JavaFileObjects.forResource("ModelWithFinalClass.java");
assert_().about(javaSource()).that(model).processedWith(new EpoxyProcessor()).failsToCompile();
}
use of javax.tools.JavaFileObject in project immutables by immutables.
the class Processor method generateTemplateType.
private void generateTemplateType(TypeElement templateType) throws IOException, Exception {
SwissArmyKnife knife = new SwissArmyKnife(processingEnv, templateType);
String string = readTemplateResource(templateType, knife);
Unit unit = parseUnit(string);
Unit resolved = transformUnit(knife, unit);
TemplateWriter writingTransformer = new TemplateWriter(knife, templateType, GeneratedTypes.getSimpleName(templateType));
CharSequence template = writingTransformer.toCharSequence(resolved);
JavaFileObject templateFile = knife.environment.getFiler().createSourceFile(GeneratedTypes.getQualifiedName(knife.elements, templateType), templateType);
try (Writer writer = templateFile.openWriter()) {
writer.append(template);
}
}
use of javax.tools.JavaFileObject in project jsonschema2pojo by joelittlejohn.
the class CompilerWarningIT method checkWarnings.
@Test
public void checkWarnings() {
schemaRule.generate(schema, "com.example", config);
schemaRule.compile(compiler, new NullWriter(), new ArrayList<File>(), config);
List<Diagnostic<? extends JavaFileObject>> warnings = warnings(schemaRule.getDiagnostics());
assertThat(warnings, matcher);
}
use of javax.tools.JavaFileObject in project jsonschema2pojo by joelittlejohn.
the class Jsonschema2PojoRule method apply.
@Override
public Statement apply(final Statement base, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
active = true;
diagnostics = new ArrayList<Diagnostic<? extends JavaFileObject>>();
boolean captureDiagnosticsStart = captureDiagnostics;
try {
File testRoot = methodNameDir(classNameDir(rootDirectory(), description.getClassName()), description.getMethodName());
generateDir = new File(testRoot, "generate");
compileDir = new File(testRoot, "compile");
base.evaluate();
} finally {
generateDir = null;
compileDir = null;
classLoader = null;
sourceDirInitialized = false;
classesDirInitialized = false;
captureDiagnostics = captureDiagnosticsStart;
diagnostics = null;
active = false;
}
}
};
}
Aggregations