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

[Annotation Processor] Set default int type to BigInteger #433

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
try {
plutusContractBlueprint = PlutusBlueprintLoader.loadBlueprint(blueprintFile);
} catch (Exception e) {
e.printStackTrace();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this for now till we find a better way to notify error during compilation.

error(typeElement, "Error processing blueprint file %s", blueprintFile.getAbsolutePath(), e);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Modifier;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -36,7 +37,7 @@ public FieldSpec processIntegerDataType(String javaDoc, BlueprintSchema schema,
if(schema.getDataType() != integer)
throw new IllegalArgumentException("Schema is not of type integer");
String title = schema.getTitle() == null ? alternativeName : schema.getTitle();
return FieldSpec.builder(int.class, title)
return FieldSpec.builder(BigInteger.class, title)
.addModifiers(Modifier.PRIVATE)
.addJavadoc(javaDoc)
.build();
Expand Down Expand Up @@ -94,7 +95,7 @@ private TypeName getInnerType(String ns, BlueprintSchema items) {
case bytes:
return TypeName.get(byte[].class);
case integer:
return TypeName.get(Integer.class);
return TypeName.get(BigInteger.class);
case string:
return TypeName.get(String.class);
case bool:
Expand Down Expand Up @@ -207,6 +208,8 @@ public FieldSpec processPlutusDataType(String javaDoc, BlueprintSchema schema, S
private String getPackage(String ns) {
String pkg = (ns != null && !ns.isEmpty())? annotation.packageName() + "." + ns + ".model"
: annotation.packageName() + ".model";

pkg = pkg.toLowerCase();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if we should also remove - and _ ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nemo83 . Done.

return pkg;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ public List<FieldSpec> createFieldSpecForDataTypes(String ns, String javaDoc, Bl
private String getPackageName(String ns) {
String pkg = (ns != null && !ns.isEmpty()) ? annotation.packageName() + "." + ns + ".model"
: annotation.packageName() + ".model";

pkg = pkg.toLowerCase();
return pkg;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public void processValidator(Validator validator, PlutusVersion plutusVersion) {
if (pkgSuffix != null)
packageName = packageName + "." + pkgSuffix;

packageName = packageName.toLowerCase();

String title = validatorName;
title = JavaFileUtil.toCamelCase(title);

Expand Down
Loading