Skip to content

Commit

Permalink
ModelFilters to utils package; clean compile warnings;
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-hickman-epistimis committed Feb 16, 2024
1 parent b5a4185 commit a7766de
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 40 deletions.
17 changes: 11 additions & 6 deletions com.epistimis.uddl/src/com/epistimis/uddl/DefaultValue.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@
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;
import org.eclipse.emf.ecore.resource.ResourceSet;
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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@
public class UnrolledComposableElementP extends UnrolledComposableElement<PlatformComposableElement> {

/**
* 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<PlatformComposableElement,UnrolledComposableElement<PlatformComposableElement>> allComposable2Unrolled = new HashMap<>();
public static Map<UnrolledComposableElement<PlatformComposableElement>,PlatformComposableElement> allUnrolled2Composable = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ComposableElement extends UddlElement,
Characteristic extends EObject,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ private void unroll(ResourceSet rs) {
* LogicalEntity -> ConceptualEntity to determine what is available. The results
* can then be used to create instances, generate code, or ....
*/
@SuppressWarnings("unchecked")
final Iterable<ComposableElement> elements = Iterables.<ComposableElement>filter(
IteratorExtensions.<EObject>toIterable(res.getAllContents()), getComposableElementType());
// When we create the Unrolled objects, they are automatically cached - we don't need to do anything
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.epistimis.uddl;
package com.epistimis.uddl.util;

import java.text.MessageFormat;
import java.util.ArrayList;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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.
Expand Down

0 comments on commit a7766de

Please sign in to comment.