Skip to content

Commit

Permalink
complete_LogicalParticipant, complete_PlatformParticipant
Browse files Browse the repository at this point in the history
completeLogicalParticipant_Type, completePlatformParticipant_Type

Also: UnrolledEntity uses LinkedHashSet for consistent ordering
  • Loading branch information
steve-hickman-epistimis committed Feb 29, 2024
1 parent 47fae58 commit 676012a
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@
import com.epistimis.uddl.PlatformEntityProcessor;
import com.epistimis.uddl.UddlQNP;
import com.epistimis.uddl.util.IndexUtilities;
import com.epistimis.uddl.uddl.LogicalAssociation;
import com.epistimis.uddl.uddl.LogicalComposition;
import com.epistimis.uddl.uddl.LogicalEntity;
import com.epistimis.uddl.uddl.LogicalMeasurement;
import com.epistimis.uddl.uddl.LogicalMeasurementAttribute;
import com.epistimis.uddl.uddl.LogicalMeasurementAxis;
import com.epistimis.uddl.uddl.LogicalParticipant;
import com.epistimis.uddl.uddl.PlatformAssociation;
import com.epistimis.uddl.uddl.PlatformComposableElement;
import com.epistimis.uddl.uddl.PlatformComposition;
import com.epistimis.uddl.uddl.PlatformEntity;
import com.epistimis.uddl.uddl.PlatformParticipant;
import com.epistimis.uddl.uddl.PlatformStruct;
import com.epistimis.uddl.uddl.UddlElement;
import com.epistimis.uddl.uddl.UddlPackage;
Expand All @@ -58,7 +62,7 @@ public class UddlProposalProvider extends AbstractUddlProposalProvider {
final static String INDENT = "\t";
final static String MEMBER_DISPLAY_FMT = "{0}" ;
final static String REALIZE_ALL = "<<Default Realize All>>";
final static String STRUCT_REALIZATION_ERR = "PlatformStruct {0} must realize a LogicalMeasurement with 2+ axes / attributes. {1} only has {2}";
final static String STRUCT_REALIZATION_ERR = "PlatformStruct {0} must realize a LogicalMeasurement with 2+ axes / attributes. {1} has {2}";
final static String STRUCT_AXIS_FMT = "{0} {1} ( {2} ) ;" ;
final static String STRUCT_ATTRIBUTE_FMT = "{0} {1} ( {2} ) -> {3} ;" ;
final static String GENERIC_REF_DISPLAY_FMT = "{0} - {1}";
Expand Down Expand Up @@ -186,12 +190,32 @@ public void complete_LogicalComposition(EObject obj, RuleCall ruleCall, ContentA
clrpproc.complete_Composition(this,clrproc, ent, ruleCall, context, acceptor);
}

@Override
public void complete_LogicalParticipant(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
LogicalAssociation assoc = null;
if (model instanceof LogicalAssociation) { assoc = (LogicalAssociation)model; }
else if (model instanceof LogicalParticipant) { assoc = (LogicalAssociation)model.eContainer(); }
else {
throw new RuntimeException("Can't cast to LogicalAssociation:" + model.eClass().toString());
}
clrpproc.complete_Participant(this,clrproc, assoc, ruleCall, context, acceptor);

}
// @Override
// public void completeLogicalComposition_Type(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
//// lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor);
// clrpproc.completeComposition_Type(this, (LogicalEntity)model, assignment, context, acceptor);
//
// public void completeLogicalEntity_Composition(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
// }
// @Override
// public void completeLogicalAssociation_Composition(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
// }

@Override
public void completeLogicalComposition_Type(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor);
clrpproc.completeComposition_Type(this, (LogicalEntity)model, assignment, context, acceptor);

}
/**
* The only way to force calling a super class method is by calling from the derived class. So we create this callback to
* be used by clrpproc to force the call to the super class method
Expand All @@ -216,6 +240,13 @@ public void completeLogicalComposition_Realizes(EObject obj, Assignment assignme
clrpproc.completeComposition_Realizes(this, clrproc, (LogicalEntity)obj.eContainer(), assignment, context, acceptor);
}

@Override
public void completeLogicalParticipant_Type(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor);
clrpproc.completeParticipant_Type(this, (LogicalAssociation)model, assignment, context, acceptor);

}

@Override
public void completeLogicalMeasurement_Realizes(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// Do I need to call super? Don't think so
Expand All @@ -227,6 +258,7 @@ public void completeLogicalMeasurement_Realizes(EObject model, Assignment assign

/** Platform -> Logical */

/** Rule methods */
/**
* The only way to force calling a super class method is by calling from the derived class. So we create this callback to
* be used by clrpproc to force the call to the super class method
Expand All @@ -252,12 +284,36 @@ public void complete_PlatformComposition(EObject obj, RuleCall ruleCall, Content

}

@Override
public void complete_PlatformParticipant(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
PlatformAssociation assoc = null;
if (model instanceof PlatformAssociation) { assoc = (PlatformAssociation)model; }
else if (model instanceof PlatformParticipant) { assoc = (PlatformAssociation)model.eContainer(); }
else {
throw new RuntimeException("Can't cast to PlatformAssociation:" + model.eClass().toString());
}
lprpproc.complete_Participant(this,lprproc, assoc, ruleCall, context, acceptor);

}

/** Feature Methods */

// @Override
// public void completePlatformComposition_Type(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
//// lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor);
// lprpproc.completeComposition_Type(this, (PlatformEntity)model, assignment, context, acceptor);
//
// public void completePlatformEntity_Composition(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
// }

// @Override
// public void completePlatformAssociation_Composition(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
// }

@Override
public void completePlatformComposition_Type(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor);
lprpproc.completeComposition_Type(this, (PlatformEntity)model, assignment, context, acceptor);

}
/**
* The only way to force calling a super class method is by calling from the derived class. So we create this callback to
* be used by clrpproc to force the call to the super class method
Expand All @@ -284,6 +340,12 @@ public void completePlatformComposition_Realizes(EObject obj, Assignment assignm

}

@Override
public void completePlatformParticipant_Type(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor);
lprpproc.completeParticipant_Type(this, (PlatformAssociation)model, assignment, context, acceptor);

}

@Override
public void completePlatformStruct_Member(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
Expand Down
3 changes: 2 additions & 1 deletion com.epistimis.uddl/src/com/epistimis/uddl/Uddl.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@ LogicalCharacteristic:
LogicalParticipant
;

/** A logical Entity “realizes” a conceptual Entity in terms of Measurements and other logical Entities. Since a logical Entity is built from
/**
* A logical Entity “realizes” a conceptual Entity in terms of Measurements and other logical Entities. Since a logical Entity is built from
* logical Measurements, it is independent of any specific platform data representation. A logical Entity's composition hierarchy is consistent
* with the composition hierarchy of the conceptual Entity that it realizes. The logical Entity’s composed Entities realize one to one the conceptual
* Entity’s composed Entities; the logical Entity’s composed Measurements realize many to one the conceptual Entity’s composed Observables.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.epistimis.uddl.unrolled;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import org.eclipse.emf.common.util.EList;
Expand Down Expand Up @@ -83,7 +84,7 @@ protected Map<String, UComposition> processSpecializationForCompositions(Entity
if (specializedEntity != null) {
compositionSoFar = processSpecializationForCompositions(specializedEntity);
} else {
compositionSoFar = new HashMap<String, UComposition>();
compositionSoFar = new LinkedHashMap<String, UComposition>();
}
setDescription(pe);
return processLocalCompositions(pe,compositionSoFar);
Expand All @@ -97,8 +98,10 @@ protected Map<String, UComposition> processLocalCompositions(Entity pe, Map<Stri
* or not, because we wouldn't know if the 'results' map entry was an updated version reusing a name.
* By keeping the maps separate, we we can do that safely. Then, at the very end, we merge what is left
* of compositionSoFar into results - everything we want to 'override' has already been removed from it.
*
* NOTE: Using LinkedHashMap to get predictable ordering (ordered by insertion)
*/
Map<String,UComposition> results = new HashMap<>();
Map<String,UComposition> results = new LinkedHashMap<>();
for (Composition pc: getComposition(pe)) {
UComposition rc = null;
@SuppressWarnings("unchecked") // OCL invariants say that compositions can only specialize compositions
Expand Down

0 comments on commit 676012a

Please sign in to comment.