From d9a05a052f2b1abae2eee3fbd8f90ee8f8124da4 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Fri, 29 Sep 2023 16:54:36 +0200 Subject: [PATCH] cleanup --- core/src/main/java/org/lflang/TargetProperty.java | 4 ++-- core/src/main/java/org/lflang/TargetPropertyConfig.java | 8 ++++---- .../java/org/lflang/target/property/type/ArrayType.java | 9 +++------ .../org/lflang/target/property/type/DictionaryType.java | 2 +- .../lflang/target/property/type/TargetPropertyType.java | 4 ++-- .../java/org/lflang/target/property/type/UnionType.java | 2 +- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/org/lflang/TargetProperty.java b/core/src/main/java/org/lflang/TargetProperty.java index a5095b9d45..118afbdd44 100644 --- a/core/src/main/java/org/lflang/TargetProperty.java +++ b/core/src/main/java/org/lflang/TargetProperty.java @@ -405,8 +405,8 @@ public static void validate( .findAny(); if (match.isPresent()) { var p = match.get(); - p.property.of(config).checkSupport(pair, config, reporter); - p.property.of(config).checkType(pair, config, reporter); + p.property.of(config).checkSupport(pair, config.target, reporter); + p.property.of(config).checkType(pair, reporter); p.property.of(config).validate(pair, ast, config, reporter); } else { reporter diff --git a/core/src/main/java/org/lflang/TargetPropertyConfig.java b/core/src/main/java/org/lflang/TargetPropertyConfig.java index 35fc6936a5..4a41df7b39 100644 --- a/core/src/main/java/org/lflang/TargetPropertyConfig.java +++ b/core/src/main/java/org/lflang/TargetPropertyConfig.java @@ -78,19 +78,19 @@ public void validate( // FIXME: consider not passing in config } - public void checkSupport(KeyValuePair pair, TargetConfig config, MessageReporter reporter) { - if (!this.isSupported(config.target)) { + public void checkSupport(KeyValuePair pair, Target target, MessageReporter reporter) { + if (!this.isSupported(target)) { reporter .at(pair, Literals.KEY_VALUE_PAIR__NAME) .warning( String.format( "The target parameter: %s is not supported by the %s target and will thus be" + " ignored.", - pair.getName(), config.target)); + pair.getName(), target)); } } - public void checkType(KeyValuePair pair, TargetConfig config, MessageReporter reporter) { + public void checkType(KeyValuePair pair, MessageReporter reporter) { if (!this.type.check(pair.getValue(), pair.getName(), reporter)) { reporter .at(pair, Literals.KEY_VALUE_PAIR__VALUE) diff --git a/core/src/main/java/org/lflang/target/property/type/ArrayType.java b/core/src/main/java/org/lflang/target/property/type/ArrayType.java index 742292c3c7..96d176f54d 100644 --- a/core/src/main/java/org/lflang/target/property/type/ArrayType.java +++ b/core/src/main/java/org/lflang/target/property/type/ArrayType.java @@ -15,14 +15,14 @@ public enum ArrayType implements TargetPropertyType { FILE_ARRAY(PrimitiveType.FILE); /** Type parameter of this array type. */ - public TargetPropertyType type; + public final TargetPropertyType type; /** * Private constructor to create a new array type. * * @param type The type of elements in the array. */ - private ArrayType(TargetPropertyType type) { + ArrayType(TargetPropertyType type) { this.type = type; } @@ -47,10 +47,7 @@ public boolean check(Element e, String name, MessageReporter r) { /** Return true of the given element is an array. */ @Override public boolean validate(Element e) { - if (e.getArray() != null) { - return true; - } - return false; + return e.getArray() != null; } /** Return a human-readable description of this type. */ diff --git a/core/src/main/java/org/lflang/target/property/type/DictionaryType.java b/core/src/main/java/org/lflang/target/property/type/DictionaryType.java index cbcb58d4c8..0c15ffe0be 100644 --- a/core/src/main/java/org/lflang/target/property/type/DictionaryType.java +++ b/core/src/main/java/org/lflang/target/property/type/DictionaryType.java @@ -36,7 +36,7 @@ public enum DictionaryType implements TargetPropertyType { * * @param options The dictionary elements allowed by this type. */ - private DictionaryType(List options) { + DictionaryType(List options) { this.options = options; } diff --git a/core/src/main/java/org/lflang/target/property/type/TargetPropertyType.java b/core/src/main/java/org/lflang/target/property/type/TargetPropertyType.java index d4c5009262..7c555e743c 100644 --- a/core/src/main/java/org/lflang/target/property/type/TargetPropertyType.java +++ b/core/src/main/java/org/lflang/target/property/type/TargetPropertyType.java @@ -16,7 +16,7 @@ public interface TargetPropertyType { * @param e The Element to validate. * @return True if the element conforms to this type, false otherwise. */ - public boolean validate(Element e); + boolean validate(Element e); /** * Check (recursively) the given Element against its associated type(s) and add found problems to @@ -26,5 +26,5 @@ public interface TargetPropertyType { * @param name The name of the target property. * @param r A reference to the validator to report errors to. */ - public boolean check(Element e, String name, MessageReporter r); + boolean check(Element e, String name, MessageReporter r); } diff --git a/core/src/main/java/org/lflang/target/property/type/UnionType.java b/core/src/main/java/org/lflang/target/property/type/UnionType.java index a4f1cdbb36..979a6b7011 100644 --- a/core/src/main/java/org/lflang/target/property/type/UnionType.java +++ b/core/src/main/java/org/lflang/target/property/type/UnionType.java @@ -46,7 +46,7 @@ public enum UnionType implements TargetPropertyType { * @param options The types that that are part of the union. * @param defaultOption The default type. */ - private UnionType(List> options, Enum defaultOption) { + UnionType(List> options, Enum defaultOption) { this.options = options; this.defaultOption = defaultOption; }