Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP Eclipse compatability #183

Open
wants to merge 1 commit into
base: 1.20.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,7 @@ run/

# generated sources
/src/*/generated/
bin/

# Eclipse
.settings/
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ minecraft_version=1.20.2
yarn_mappings=1.20.2+build.1
loader_version=0.14.22
# Mod Properties
mod_version=0.11.3
mod_version=0.11.4
maven_group=io.wispforest
archives_base_name=owo-lib
# Dependencies
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/io/wispforest/owo/config/ConfigAP.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
var wrapperName = annotated.getAnnotation(Config.class).wrapperName();

try {
var file = this.processingEnv.getFiler().createSourceFile(wrapperName);
String packageName = getPackageName(className);
String fqWrapperName = packageName + "." + wrapperName;
var file = this.processingEnv.getFiler().createSourceFile(fqWrapperName);
try (var writer = new PrintWriter(file.openWriter())) {
writer.println(makeWrapper(wrapperName, className, this.collectFields(Option.Key.ROOT, clazz, clazz.getAnnotation(Config.class).defaultHook())));
}
Expand Down Expand Up @@ -356,4 +358,12 @@ public char charAt(int index) {
return this.builder.toString();
}
}

private String getPackageName(String fqn) {
int lastDotIndex = fqn.lastIndexOf('.');
if (lastDotIndex == -1) {
return "";
}
return fqn.substring(0, lastDotIndex);
}
}