From a7766de0a2d62cf6dd0476020115a728bc67ae5d Mon Sep 17 00:00:00 2001 From: Steve Hickman Date: Fri, 16 Feb 2024 11:10:39 -0800 Subject: [PATCH] ModelFilters to utils package; clean compile warnings; --- .../src/com/epistimis/uddl/DefaultValue.xtend | 17 +++++++++++------ .../epistimis/uddl/LogicalEntityProcessor.java | 1 - .../epistimis/uddl/RealizationProcessor.java | 3 +-- .../CommonDataStructureGenerator.xtend | 7 +++---- .../generator/IDLDataStructureGenerator.xtend | 2 +- .../uddl/scoping/UddlScopeProvider.java | 12 ++++-------- .../unrolled/UnrolledComposableElementP.java | 13 ++++--------- .../uddl/unrolled/UnrolledComposition.java | 4 +--- .../uddl/unrolled/UnrollingFactory.java | 1 + .../epistimis/uddl/{ => util}/ModelFilters.java | 3 +-- .../uddl/util/NavigationUtilities.java | 5 +---- 11 files changed, 28 insertions(+), 40 deletions(-) rename com.epistimis.uddl/src/com/epistimis/uddl/{ => util}/ModelFilters.java (99%) diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/DefaultValue.xtend b/com.epistimis.uddl/src/com/epistimis/uddl/DefaultValue.xtend index 9e004b3..79b91e0 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/DefaultValue.xtend +++ b/com.epistimis.uddl/src/com/epistimis/uddl/DefaultValue.xtend @@ -3,18 +3,21 @@ */ package com.epistimis.uddl +import java.text.MessageFormat +import java.util.List import com.google.inject.Inject +import org.eclipse.emf.ecore.EObject +import org.eclipse.xtext.naming.QualifiedName + import com.epistimis.uddl.uddl.PlatformLongDouble import com.epistimis.uddl.uddl.LogicalEnumerated import com.epistimis.uddl.uddl.PlatformDouble import com.epistimis.uddl.uddl.PlatformLongLong import com.epistimis.uddl.uddl.PlatformULongLong import com.epistimis.uddl.uddl.PlatformChar -import org.eclipse.xtext.naming.QualifiedName import com.epistimis.uddl.uddl.PlatformSequence import com.epistimis.uddl.uddl.PlatformOctet import com.epistimis.uddl.uddl.PlatformFloat -import java.util.List import com.epistimis.uddl.uddl.PlatformStruct import com.epistimis.uddl.uddl.PlatformEnumeration import com.epistimis.uddl.uddl.PlatformULong @@ -28,9 +31,7 @@ import com.epistimis.uddl.uddl.PlatformBoolean import com.epistimis.uddl.uddl.PlatformArray import com.epistimis.uddl.uddl.LogicalValueTypeUnit import com.epistimis.uddl.uddl.LogicalEnumeratedBase - -import java.text.MessageFormat -import org.eclipse.emf.ecore.EObject +import com.epistimis.uddl.util.ModelFilters /** * We can extract landmarks from the Measurement system associated with the measurement and use those for default values, if @@ -65,6 +66,10 @@ class DefaultValue { return (leb === null) ? QualifiedName.EMPTY : qnp.minimalReferenceQN(leb,ctx); } + /** + * Getting an enum value staring from a PlatformEnumeration requires backtracking to find the related LogicalEnumerated. + * We just need a value, so pick the first one. + */ def LogicalEnumeratedBase getEnumValue(PlatformEnumeration value) { /** * Get the actual enumeration being used and pick a value from that. @@ -90,7 +95,7 @@ class DefaultValue { * @param value * @return */ - def dispatch Object getDefaultValue( PlatformStruct value) + def dispatch Object getDefaultValue( PlatformStruct value, EObject ctx) { /** * Go through all the structure members and get default values for each one. This may be recursive. diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/LogicalEntityProcessor.java b/com.epistimis.uddl/src/com/epistimis/uddl/LogicalEntityProcessor.java index 8cc96b7..89ab593 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/LogicalEntityProcessor.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/LogicalEntityProcessor.java @@ -6,7 +6,6 @@ import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; -import com.epistimis.uddl.uddl.ConceptualCharacteristic; import com.epistimis.uddl.uddl.LogicalAssociation; import com.epistimis.uddl.uddl.LogicalCharacteristic; import com.epistimis.uddl.uddl.LogicalComposableElement; diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/RealizationProcessor.java b/com.epistimis.uddl/src/com/epistimis/uddl/RealizationProcessor.java index 46f79df..27dbbe8 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/RealizationProcessor.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/RealizationProcessor.java @@ -11,7 +11,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import org.apache.log4j.Logger; import org.eclipse.emf.ecore.EObject; @@ -19,8 +18,8 @@ import org.eclipse.xtext.naming.IQualifiedNameConverter; import org.eclipse.xtext.naming.IQualifiedNameProvider; -import com.epistimis.uddl.util.IndexUtilities; import com.epistimis.uddl.uddl.UddlElement; +import com.epistimis.uddl.util.IndexUtilities; import com.google.inject.Inject; /** diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/generator/CommonDataStructureGenerator.xtend b/com.epistimis.uddl/src/com/epistimis/uddl/generator/CommonDataStructureGenerator.xtend index 39aa1d3..38fe1e0 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/generator/CommonDataStructureGenerator.xtend +++ b/com.epistimis.uddl/src/com/epistimis/uddl/generator/CommonDataStructureGenerator.xtend @@ -9,22 +9,21 @@ import com.epistimis.uddl.uddl.PlatformDataType import com.epistimis.uddl.uddl.PlatformEntity import com.epistimis.uddl.uddl.PlatformParticipant import com.epistimis.uddl.uddl.UddlElement +import com.epistimis.uddl.unrolled.UnrolledComposableElement import com.google.inject.Inject +import java.lang.invoke.MethodHandles import java.util.ArrayList import java.util.Collection import java.util.HashMap import java.util.List import java.util.Map +import org.apache.log4j.Logger import org.eclipse.emf.ecore.EObject import org.eclipse.emf.ecore.resource.Resource import org.eclipse.xtext.generator.IFileSystemAccess2 import org.eclipse.xtext.generator.IGenerator2 import org.eclipse.xtext.generator.IGeneratorContext import org.eclipse.xtext.naming.IQualifiedNameProvider -import com.epistimis.uddl.unrolled.UnrolledComposableElementP -import org.apache.log4j.Logger -import java.lang.invoke.MethodHandles -import com.epistimis.uddl.unrolled.UnrolledComposableElement /** * NOTE: Need to handle attribute cardinality in a general way - 2 parts of this: determining cardinality and then rendering. diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/generator/IDLDataStructureGenerator.xtend b/com.epistimis.uddl/src/com/epistimis/uddl/generator/IDLDataStructureGenerator.xtend index d9065e1..3045734 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/generator/IDLDataStructureGenerator.xtend +++ b/com.epistimis.uddl/src/com/epistimis/uddl/generator/IDLDataStructureGenerator.xtend @@ -1,6 +1,6 @@ package com.epistimis.uddl.generator -import com.epistimis.uddl.ModelFilters +import com.epistimis.uddl.util.ModelFilters import com.epistimis.uddl.uddl.LogicalValueTypeUnit import com.epistimis.uddl.uddl.PlatformArray import com.epistimis.uddl.uddl.PlatformBoolean diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/scoping/UddlScopeProvider.java b/com.epistimis.uddl/src/com/epistimis/uddl/scoping/UddlScopeProvider.java index 721a8e2..ee8ab6b 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/scoping/UddlScopeProvider.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/scoping/UddlScopeProvider.java @@ -6,32 +6,29 @@ */ package com.epistimis.uddl.scoping; -import java.util.ArrayList; import java.util.List; -import org.eclipse.emf.common.util.EList; +//import org.eclipse.emf.common.util.EList; //import java.util.List; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.resource.Resource; +//import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.xtext.EcoreUtil2; -import org.eclipse.xtext.resource.IEObjectDescription; //import org.eclipse.xtext.EcoreUtil2; //import org.eclipse.xtext.resource.IEObjectDescription; import org.eclipse.xtext.scoping.IScope; import org.eclipse.xtext.scoping.Scopes; import org.eclipse.xtext.scoping.impl.FilteringScope; -import org.eclipse.xtext.scoping.impl.MapBasedScope; +//import org.eclipse.xtext.scoping.impl.MapBasedScope; import com.epistimis.uddl.ConceptualEntityProcessor; import com.epistimis.uddl.LogicalEntityProcessor; import com.epistimis.uddl.PlatformEntityProcessor; import com.epistimis.uddl.UddlQNP; -import com.epistimis.uddl.uddl.ConceptualComposition; +//import com.epistimis.uddl.uddl.ConceptualComposition; import com.epistimis.uddl.uddl.ConceptualEntity; -import com.epistimis.uddl.uddl.LogicalComposition; //import com.epistimis.uddl.uddl.LogicalComposition; import com.epistimis.uddl.uddl.LogicalEntity; import com.epistimis.uddl.uddl.LogicalEnumeratedBase; @@ -41,7 +38,6 @@ //import com.epistimis.uddl.uddl.PlatformDataType; import com.epistimis.uddl.uddl.PlatformEntity; -//import org.eclipse.emf.ecore.resource.Resource; import com.epistimis.uddl.uddl.UddlPackage; import com.epistimis.uddl.util.IndexUtilities; diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/unrolled/UnrolledComposableElementP.java b/com.epistimis.uddl/src/com/epistimis/uddl/unrolled/UnrolledComposableElementP.java index f373a3b..35226db 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/unrolled/UnrolledComposableElementP.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/unrolled/UnrolledComposableElementP.java @@ -16,15 +16,10 @@ public class UnrolledComposableElementP extends UnrolledComposableElement { /** - * This is, essentially, a compiler name table. It contains the results of processing all the composable elements in the model to - * get the net realization. This can be used as is, or can be used by the QueryProcessor when selecting Entities, Associations, and Compositions. - * - * Note that this contains Platform level info - * NOTE also that the 'Object' side of each map contains UnrolledComposableElement(s) or their their 'derivative's. - * Because of how Java generics work, UnrolledComposableElementP, UnrolledEntityP, and UnrolledAssociationP aren't - * considered 'compatible' - at least not in their current form. For now just use type checking to figure out what - * we have and convert as appropriate. - * TODO: fix this so we don't lose type safety. + * This is, essentially, a compiler name table. It contains the results of processing all the composable elements in the model to get the + * net of unrolling. This can be used as is, or can be used by the QueryProcessor when selecting Entities, Associations, and Compositions. + * + * Note that this contains Platform level info only */ public static Map> allComposable2Unrolled = new HashMap<>(); public static Map,PlatformComposableElement> allUnrolled2Composable = new HashMap<>(); diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/unrolled/UnrolledComposition.java b/com.epistimis.uddl/src/com/epistimis/uddl/unrolled/UnrolledComposition.java index 4c68c37..626deab 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/unrolled/UnrolledComposition.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/unrolled/UnrolledComposition.java @@ -6,10 +6,8 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.jdt.annotation.NonNull; -import com.epistimis.uddl.util.IndexUtilities; -import com.epistimis.uddl.uddl.PlatformComposableElement; -import com.epistimis.uddl.uddl.PlatformComposition; import com.epistimis.uddl.uddl.UddlElement; +import com.epistimis.uddl.util.IndexUtilities; public abstract class UnrolledComposition ConceptualEntity to determine what is available. The results * can then be used to create instances, generate code, or .... */ + @SuppressWarnings("unchecked") final Iterable elements = Iterables.filter( IteratorExtensions.toIterable(res.getAllContents()), getComposableElementType()); // When we create the Unrolled objects, they are automatically cached - we don't need to do anything diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/ModelFilters.java b/com.epistimis.uddl/src/com/epistimis/uddl/util/ModelFilters.java similarity index 99% rename from com.epistimis.uddl/src/com/epistimis/uddl/ModelFilters.java rename to com.epistimis.uddl/src/com/epistimis/uddl/util/ModelFilters.java index 5c1de8b..bdb6760 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/ModelFilters.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/util/ModelFilters.java @@ -1,4 +1,4 @@ -package com.epistimis.uddl; +package com.epistimis.uddl.util; import java.text.MessageFormat; import java.util.ArrayList; @@ -19,7 +19,6 @@ import com.epistimis.uddl.uddl.ConceptualEntity; import com.epistimis.uddl.uddl.LogicalAbstractMeasurement; import com.epistimis.uddl.uddl.LogicalAbstractMeasurementSystem; -import com.epistimis.uddl.uddl.LogicalElement; import com.epistimis.uddl.uddl.LogicalEntity; import com.epistimis.uddl.uddl.LogicalLandmark; import com.epistimis.uddl.uddl.LogicalMeasurement; diff --git a/com.epistimis.uddl/src/com/epistimis/uddl/util/NavigationUtilities.java b/com.epistimis.uddl/src/com/epistimis/uddl/util/NavigationUtilities.java index 9265b29..e15c618 100644 --- a/com.epistimis.uddl/src/com/epistimis/uddl/util/NavigationUtilities.java +++ b/com.epistimis.uddl/src/com/epistimis/uddl/util/NavigationUtilities.java @@ -7,9 +7,6 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.jdt.annotation.NonNull; -import com.epistimis.uddl.util.IndexUtilities; -import com.google.inject.Inject; - /** * General Utilities that can be used to navigate around the model. These replicate some functionality already in OCL * @@ -18,7 +15,7 @@ */ public class NavigationUtilities { - @Inject IndexUtilities iu; + //@Inject IndexUtilities iu; /** * Walk up the containment hierarchy until we find a container that fails the test.