generated from Anvil-Dev/ArchitecturyExampleMod
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
62 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package dev.anvilcraft.lib.codec; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.FIELD) | ||
@Retention(RetentionPolicy.SOURCE) | ||
public @interface Codec { | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/dev/anvilcraft/lib/codec/CodecAnnotationProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package dev.anvilcraft.lib.codec; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import javax.annotation.processing.AbstractProcessor; | ||
import javax.annotation.processing.Filer; | ||
import javax.annotation.processing.ProcessingEnvironment; | ||
import javax.annotation.processing.RoundEnvironment; | ||
import javax.annotation.processing.SupportedAnnotationTypes; | ||
import javax.annotation.processing.SupportedSourceVersion; | ||
import javax.lang.model.SourceVersion; | ||
import javax.lang.model.element.Element; | ||
import javax.lang.model.element.TypeElement; | ||
import javax.tools.Diagnostic; | ||
import java.util.Set; | ||
|
||
@SupportedAnnotationTypes("dev.anvilcraft.lib.codec.Codec") | ||
@SupportedSourceVersion(SourceVersion.RELEASE_21) | ||
public class CodecAnnotationProcessor extends AbstractProcessor { | ||
@Override | ||
public synchronized void init(ProcessingEnvironment processingEnv) { | ||
super.init(processingEnv); | ||
} | ||
|
||
@Override | ||
public boolean process(Set<? extends TypeElement> annotations, @NotNull RoundEnvironment roundEnv) { | ||
for (Element element : roundEnv.getElementsAnnotatedWith(Codec.class)) { | ||
TypeElement typeElem = (TypeElement) element; | ||
String typeName = typeElem.getQualifiedName().toString(); | ||
Filer filer = processingEnv.getFiler(); | ||
} | ||
return true; | ||
} | ||
|
||
|
||
private void log(String msg) { | ||
if (processingEnv.getOptions().containsKey("debug")) { | ||
processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, msg); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/main/resources/META-INF/services/javax.annotation.processing.Processor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dev.anvilcraft.lib.codec.CodecAnnotationProcessor |