mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
#2398 - Fix compiler warning for annotation processing query bean generators
This commit is contained in:
1 parent
1a34a56351
commit
033c579984
4 files changed
+47
-12
No files matched your search
+21
-4
@@ -6,6 +6,7 @@ import javax.annotation.processing.RoundEnvironment;
|
|||||||
import javax.lang.model.SourceVersion;
|
import javax.lang.model.SourceVersion;
|
||||||
import javax.lang.model.element.Element;
|
import javax.lang.model.element.Element;
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ public class Processor extends AbstractProcessor implements Constants {
|
|||||||
private static final String KAPT_KOTLIN_GENERATED_OPTION = "kapt.kotlin.generated";
|
private static final String KAPT_KOTLIN_GENERATED_OPTION = "kapt.kotlin.generated";
|
||||||
|
|
||||||
private ProcessingContext processingContext;
|
private ProcessingContext processingContext;
|
||||||
|
private SimpleModuleInfoWriter moduleWriter;
|
||||||
|
|
||||||
public Processor() {
|
public Processor() {
|
||||||
}
|
}
|
||||||
@@ -55,11 +57,11 @@ public class Processor extends AbstractProcessor implements Constants {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
|
||||||
|
|
||||||
processingContext.readModuleInfo();
|
processingContext.readModuleInfo();
|
||||||
int count = processEntities(roundEnv);
|
int count = processEntities(roundEnv);
|
||||||
processOthers(roundEnv);
|
processOthers(roundEnv);
|
||||||
final int loaded = processingContext.complete();
|
final int loaded = processingContext.complete();
|
||||||
|
initModuleInfoBean();
|
||||||
if (roundEnv.processingOver()) {
|
if (roundEnv.processingOver()) {
|
||||||
writeModuleInfoBean();
|
writeModuleInfoBean();
|
||||||
}
|
}
|
||||||
@@ -96,12 +98,27 @@ public class Processor extends AbstractProcessor implements Constants {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initModuleInfoBean() {
|
||||||
|
try {
|
||||||
|
if (moduleWriter == null) {
|
||||||
|
moduleWriter = new SimpleModuleInfoWriter(processingContext);
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
processingContext.logError(null, "Failed to initialise ModuleInfoLoader error:" + e + " stack:" + Arrays.toString(e.getStackTrace()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void writeModuleInfoBean() {
|
private void writeModuleInfoBean() {
|
||||||
try {
|
try {
|
||||||
SimpleModuleInfoWriter writer = new SimpleModuleInfoWriter(processingContext);
|
if (moduleWriter == null) {
|
||||||
writer.write();
|
processingContext.logError(null, "ModuleInfoLoader was not initialised and not written");
|
||||||
|
} else {
|
||||||
|
moduleWriter.write();
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
processingContext.logError(null, "Failed to write ModuleInfoLoader " + e.getMessage());
|
e.printStackTrace();
|
||||||
|
processingContext.logError(null, "Failed to write ModuleInfoLoader error:" + e + " stack:" + Arrays.toString(e.getStackTrace()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-3
@@ -18,14 +18,16 @@ class SimpleModuleInfoWriter {
|
|||||||
private final String factoryPackage;
|
private final String factoryPackage;
|
||||||
private final String factoryShortName;
|
private final String factoryShortName;
|
||||||
private final String factoryFullName;
|
private final String factoryFullName;
|
||||||
|
private final JavaFileObject javaFileObject;
|
||||||
|
|
||||||
private Append writer;
|
private Append writer;
|
||||||
|
|
||||||
SimpleModuleInfoWriter(ProcessingContext processingContext) {
|
SimpleModuleInfoWriter(ProcessingContext processingContext) throws IOException {
|
||||||
this.processingContext = processingContext;
|
this.processingContext = processingContext;
|
||||||
this.factoryPackage = processingContext.getFactoryPackage();
|
this.factoryPackage = processingContext.getFactoryPackage();
|
||||||
this.factoryShortName = "_Ebean$ModuleInfo";
|
this.factoryShortName = "_Ebean$ModuleInfo";
|
||||||
this.factoryFullName = factoryPackage + "." + factoryShortName;
|
this.factoryFullName = factoryPackage + "." + factoryShortName;
|
||||||
|
this.javaFileObject = processingContext.createWriter(factoryFullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write() throws IOException {
|
void write() throws IOException {
|
||||||
@@ -208,7 +210,6 @@ class SimpleModuleInfoWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Writer createFileWriter() throws IOException {
|
private Writer createFileWriter() throws IOException {
|
||||||
JavaFileObject jfo = processingContext.createWriter(factoryFullName);
|
return javaFileObject.openWriter();
|
||||||
return jfo.openWriter();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@ import java.util.Set;
|
|||||||
public class Processor extends AbstractProcessor implements Constants {
|
public class Processor extends AbstractProcessor implements Constants {
|
||||||
|
|
||||||
private ProcessingContext processingContext;
|
private ProcessingContext processingContext;
|
||||||
|
private SimpleModuleInfoWriter moduleWriter;
|
||||||
|
|
||||||
public Processor() {
|
public Processor() {
|
||||||
}
|
}
|
||||||
@@ -48,6 +49,7 @@ public class Processor extends AbstractProcessor implements Constants {
|
|||||||
int count = processEntities(roundEnv);
|
int count = processEntities(roundEnv);
|
||||||
processOthers(roundEnv);
|
processOthers(roundEnv);
|
||||||
final int loaded = processingContext.complete();
|
final int loaded = processingContext.complete();
|
||||||
|
initModuleInfoBean();
|
||||||
if (roundEnv.processingOver()) {
|
if (roundEnv.processingOver()) {
|
||||||
writeModuleInfoBean();
|
writeModuleInfoBean();
|
||||||
}
|
}
|
||||||
@@ -84,10 +86,24 @@ public class Processor extends AbstractProcessor implements Constants {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initModuleInfoBean() {
|
||||||
|
try {
|
||||||
|
if (moduleWriter == null) {
|
||||||
|
moduleWriter = new SimpleModuleInfoWriter(processingContext);
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
processingContext.logError(null, "Failed to initialise ModuleInfoLoader error:" + e + " stack:" + Arrays.toString(e.getStackTrace()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void writeModuleInfoBean() {
|
private void writeModuleInfoBean() {
|
||||||
try {
|
try {
|
||||||
SimpleModuleInfoWriter writer = new SimpleModuleInfoWriter(processingContext);
|
if (moduleWriter == null) {
|
||||||
writer.write();
|
processingContext.logError(null, "ModuleInfoLoader was not initialised and not written");
|
||||||
|
} else {
|
||||||
|
moduleWriter.write();
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
processingContext.logError(null, "Failed to write ModuleInfoLoader error:" + e + " stack:" + Arrays.toString(e.getStackTrace()));
|
processingContext.logError(null, "Failed to write ModuleInfoLoader error:" + e + " stack:" + Arrays.toString(e.getStackTrace()));
|
||||||
|
|||||||
+4
-3
@@ -18,14 +18,16 @@ class SimpleModuleInfoWriter {
|
|||||||
private final String factoryPackage;
|
private final String factoryPackage;
|
||||||
private final String factoryShortName;
|
private final String factoryShortName;
|
||||||
private final String factoryFullName;
|
private final String factoryFullName;
|
||||||
|
private final JavaFileObject javaFileObject;
|
||||||
|
|
||||||
private Append writer;
|
private Append writer;
|
||||||
|
|
||||||
SimpleModuleInfoWriter(ProcessingContext processingContext) {
|
SimpleModuleInfoWriter(ProcessingContext processingContext) throws IOException {
|
||||||
this.processingContext = processingContext;
|
this.processingContext = processingContext;
|
||||||
this.factoryPackage = processingContext.getFactoryPackage();
|
this.factoryPackage = processingContext.getFactoryPackage();
|
||||||
this.factoryShortName = "_Ebean$ModuleInfo";
|
this.factoryShortName = "_Ebean$ModuleInfo";
|
||||||
this.factoryFullName = factoryPackage + "." + factoryShortName;
|
this.factoryFullName = factoryPackage + "." + factoryShortName;
|
||||||
|
this.javaFileObject = processingContext.createWriter(factoryFullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write() throws IOException {
|
void write() throws IOException {
|
||||||
@@ -208,7 +210,6 @@ class SimpleModuleInfoWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Writer createFileWriter() throws IOException {
|
private Writer createFileWriter() throws IOException {
|
||||||
JavaFileObject jfo = processingContext.createWriter(factoryFullName);
|
return javaFileObject.openWriter();
|
||||||
return jfo.openWriter();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user