From 51109130169bdbb495960583ccdc24dc80d48a1a Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Wed, 3 Jun 2020 12:40:35 +0300 Subject: [PATCH] Changed SCLTypeUtils to not log warnings for non-property relations For example procedural UCs and their substructure requests would report tons of these all the time, which is worthless. Also added an SCL type for MOD.ChangeInformation to avoid having to see warnings about the SCL type of MOD.ChangeInformation not being available: ``` WARN [...] org.simantics.modeling.SCLTypeUtils: SCLTypeUtils.getType cannot transform data type '{ createdBy : String, createdAt : Long, modifiedBy : String, modifiedAt : Long }' to type. Returns a as default. ``` gitlab #546 Change-Id: I30210fb3055a4d844fe6e9b07c64490a45c14ecd (cherry picked from commit b055bfb36cca301ceed0591028d245e152c8c32d) --- .../graph/Modeling.pgraph | 1 + .../scl/Simantics/ChangeInformation.scl | 2 ++ .../org/simantics/modeling/SCLTypeUtils.java | 19 ++++++++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 bundles/org.simantics.modeling/scl/Simantics/ChangeInformation.scl diff --git a/bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph b/bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph index 82808f837..865f03e98 100644 --- a/bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph +++ b/bundles/org.simantics.modeling.ontology/graph/Modeling.pgraph @@ -375,6 +375,7 @@ MOD.HasSourceInformation --> MOD.SourceInformation TYPE_MAP = new THashMap(); + private static final TVar STAR = Types.var(Kinds.STAR); + private static void add(TCon type) { TYPE_MAP.put(type.name, type); } @@ -66,6 +69,7 @@ public class SCLTypeUtils { Types.functionE(new Type[] {variable, Types.RESOURCE}, Types.READ_GRAPH, Types.RESOURCE)); add((TCon)Types.RESOURCE); + add(Types.con("Simantics/ChangeInformation", "ChangeInformation")); // MOD.ChangeInformation add(Types.con("Simantics/GUID", "GUID")); // L0.GUID add(Types.con("Simantics/Variables", "StructuredProperty")); // L0.methods add(Types.con("Simantics/Variables", "ValueAccessor")); // L0.ValueAccessor @@ -81,7 +85,7 @@ public class SCLTypeUtils { Type type = TYPE_MAP.get(typeText); if(type == null) { LOGGER.warn("SCLTypeUtils.getType cannot transform '" + typeText + "' to type. Returns a as default."); - return Types.var(Kinds.STAR); + return STAR; } return type; } @@ -105,18 +109,23 @@ public class SCLTypeUtils { return Types.list(getType(((ArrayType)dataType).componentType)); else { LOGGER.warn("SCLTypeUtils.getType cannot transform data type '" + dataType + "' to type. Returns a as default."); - return Types.var(Kinds.STAR); + return STAR; } } - public static Type getType(PropertyInfo propertyInfo) { + public static Type getType(PropertyInfo propertyInfo, boolean warnOfNoTypeInformation) { if(propertyInfo.requiredValueType != null) return getType(propertyInfo.requiredValueType); else if(propertyInfo.requiredDatatype != null) return getType(propertyInfo.requiredDatatype); else { - LOGGER.warn(propertyInfo.name + " doesn't have type information. Returns a as default."); - return Types.var(Kinds.STAR); + if (warnOfNoTypeInformation) + LOGGER.warn(propertyInfo.name + " doesn't have type information. Returns a as default."); + return STAR; } } + + public static Type getType(PropertyInfo propertyInfo) { + return getType(propertyInfo, propertyInfo.isHasProperty); + } } -- 2.47.1