Browse Source

Add warning to auto generated LaF classes.

pull/245/head
weisj 4 years ago
parent
commit
140b3c3d7a
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 20
      annotations-processor/src/main/java/com/github/weisj/darklaf/annotations/processor/SynthesiseLafProcessor.java

20
annotations-processor/src/main/java/com/github/weisj/darklaf/annotations/processor/SynthesiseLafProcessor.java

@ -38,6 +38,9 @@ import javax.tools.JavaFileObject;
import com.github.weisj.darklaf.annotations.SynthesiseLaf;
/**
* @deprecated Auto-Generated class. Use LafManager.installTheme(Theme) instead.
*/
@SupportedAnnotationTypes("com.github.weisj.darklaf.annotations.SynthesiseLaf")
public class SynthesiseLafProcessor extends AbstractProcessor {
@ -57,11 +60,18 @@ public class SynthesiseLafProcessor extends AbstractProcessor {
String synthesisedName = packageName + "." + synthesisedClassName;
StringBuilder builder = new StringBuilder();
builder.append("package ").append(packageName).append(";\n\n").append("import ").append(themePath)
.append(";\n\n").append("public class ").append(synthesisedClassName).append(" extends ")
.append(baseClassName).append(" {\n\n").append(IDENT).append("public ").append(synthesisedClassName)
.append("() {\n").append(IDENT).append(IDENT).append("super(new ").append(themeName)
.append("());\n").append(IDENT).append("}\n").append("}");
builder.append("package ").append(packageName).append(";\n\n");
builder.append("import ").append(themePath).append(";\n\n");
builder.append("/**\n");
builder.append(" * @deprecated Auto-Generated class. Use LafManager.installTheme(Theme) instead.\n");
builder.append(" */\n");
builder.append("@Deprecated\n");
builder.append("public class ").append(synthesisedClassName).append(" extends ").append(baseClassName);
builder.append(" {\n\n");
builder.append(IDENT).append("public ").append(synthesisedClassName).append("() {\n");
builder.append(IDENT).append(IDENT).append("super(new ").append(themeName).append("());\n");
builder.append(IDENT).append("}\n").append("}");
try {
JavaFileObject javaFileObject = processingEnv.getFiler().createSourceFile(synthesisedName, typeElement);

Loading…
Cancel
Save