Skip to content

Commit

Permalink
fix: Pages inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
bamthomas committed Oct 28, 2024
1 parent d741672 commit 81705c5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/icij/ftm/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Model {
private final static Logger logger = LoggerFactory.getLogger(Model.class);
final Map<String, Model> parents;
private final Map<String, Object> yaml;
private static final Set<String> mixins = new LinkedHashSet<>(List.of("Asset"));
private static final Set<String> mixins = new LinkedHashSet<>(List.of("Asset", "Folder", "PlainText", "HyperText"));

public Model(Map<String, Object> modelMap, Map<String, Model> parents) {
this.yaml = Collections.unmodifiableMap(modelMap);
Expand Down Expand Up @@ -92,7 +92,7 @@ public String label() {
}

public boolean isConcrete() {
return !mixins.contains(name()) && !getRequired().isEmpty();
return !(mixins.contains(name()) || (getRequired().isEmpty() && getConcreteParent().isEmpty()));
}

private Map<String, Object> getProperty(String prop, Model model) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/icij/ftm/SourceGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public String generate(Path path) throws IOException {

String parentsStringProperties = new AttributeHandlerForSignature(model).generateFor(parentsAttributes);
String stringProperties = new AttributeHandlerForSignature(model).generateFor(modelAttributes);
String classAttributes = new AttributeHandlerForAttrs(model, parents).generateFor(modelAttributes);
String classAttributes = new AttributeHandlerForAttrs(model).generateFor(modelAttributes);
String classAttributesAssignation = getConstructor(model);

if (parents.containsKey(model.name()) || inheritanceString.contains("extends")) {
Expand Down Expand Up @@ -182,7 +182,7 @@ protected void addPropertyForNativeType(StringBuilder stringProperties, String p
}

static class AttributeHandlerForAttrs extends AttributeHandlerForSignature {
public AttributeHandlerForAttrs(Model model, Map<String, Model> parents) {
public AttributeHandlerForAttrs(Model model) {
super(model);
}

Expand Down
1 change: 0 additions & 1 deletion src/test/java/org/icij/ftm/SourceGeneratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ public void test_license_bug() throws Exception {
}

@Test
@Ignore
public void test_generate_class_if_extends_class_ex_Pages() throws Exception {
Path path = getPath("Pages.yaml");
SourceGenerator sourceGenerator = new SourceGenerator(propertiesFromMap(of("parents", Utils.findParents(new File[]{
Expand Down

0 comments on commit 81705c5

Please sign in to comment.