Skip to content

Commit

Permalink
[dev] New Legacy feature to force include
Browse files Browse the repository at this point in the history
A boolean is available on Legacy to force include instead of declarating class.

Signed-off-by: Benoit LELANDAIS <[email protected]>
  • Loading branch information
lelandaisb committed May 12, 2022
1 parent 6fbb891 commit dc47f55
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 33 deletions.
1 change: 1 addition & 0 deletions plugins/fr.cea.modane.edit/plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,4 @@ _UI_ArgMultiplicity_Array_literal = [*]
_UI_ArgDefinition_multiplicity_feature = Multiplicity
_UI_UnitTestFunction_description_feature = Description
_UI_ServiceType_application_literal = application
_UI_Legacy_forceInclude_feature = Force Include
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,36 @@ import org.eclipse.uml2.uml.Stereotype
import static extension fr.cea.modane.uml.ArcaneProfileExtensions.*
import static extension fr.cea.modane.uml.EObjectExtensions.*

class ClassExtensions
class ClassExtensions
{
Profile profile

new (Profile arcaneProfile)
{
this.profile = arcaneProfile
}

def getPties(Class it) { ownedMembers.filter(m | m.isStereotypeApplied(profile.ptySt)).filter(x | (x as Property).upperBound != 0) }
def getEntryPoints(Class it) { ownedOperations.filter(o | o.isStereotypeApplied(profile.entryPointSt)) }
def getFuncs(Class it) { ownedOperations.filter(o | o.isStereotypeApplied(profile.funcSt)) }
def getParentStructs(Class it) { parents.filter(s | s.isStereotypeApplied(profile.structSt)) }

def getVarDump(Class it) { getValue(profile.variableSt, "dump") as Boolean }
def getVarExecDep(Class it) { getValue(profile.variableSt, "executionDepend") as Boolean }
def getVarNeedSync(Class it) { getValue(profile.variableSt, "needSync") as Boolean }
def getVarRestore(Class it) { getValue(profile.variableSt, "restore") as Boolean }

def getVarMult(Class it)
{
val umlMult = getValue(profile.variableSt, "multiplicity") as EnumerationLiteral
VariableMultiplicity::getByName(umlMult.name)
}

def getVarSupport(Class it)
{
getSupport(profile.variableSt)
getSupport(profile.variableSt)
}

def getVarItemFamily(Class it)
{
val family = getValue(profile.variableSt, "family") as EObject
Expand All @@ -63,7 +63,7 @@ class ClassExtensions
}

def getVarType(Class it)
{
{
val umlType = getValue(profile.variableSt, "type") as EObject
SimpleType::getByName(umlType.toUmlPrimitiveType.name)
}
Expand All @@ -72,25 +72,26 @@ class ClassExtensions
{
getSupport(profile.itemFamilySt)
}

private def getSupport(Class it, Stereotype s)
{
val umlSupport = getValue(s, "support") as EObject
if (umlSupport === null) ItemType::NO_ITEM
else ItemType::getByName(umlSupport.toUmlPrimitiveType.name)
else ItemType::getByName(umlSupport.toUmlPrimitiveType.name)
}

def getServiceType(Class it)
{
val type = getValue(profile.serviceSt, "type") as EnumerationLiteral
ServiceType::getByName(type.name.toLowerCase)
}

def isSingleton(Class it)
{
getValue(profile.serviceSt, "singleton") as Boolean
}


def getForceInclude(Class it) { getValue(profile.legacySt, "forceInclude") as Boolean }
def getLegacyNamespace(Class it) { getValue(profile.legacySt, "originNamespace") as String }
def getLegacyFile(Class it) { getValue(profile.legacySt, "file") as String }
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ package fr.cea.modane.uml

import com.google.inject.Inject
import fr.cea.modane.ModaneStandaloneSetupGenerated
import fr.cea.modane.generator.ModaneGeneratorMessageDispatcher
import fr.cea.modane.generator.ModaneGeneratorMessageDispatcher.MessageType
import fr.cea.modane.modane.ArgDefinition
import fr.cea.modane.modane.ArgMultiplicity
import fr.cea.modane.modane.Direction
Expand Down Expand Up @@ -62,8 +64,6 @@ import static extension fr.cea.modane.uml.ArcaneProfileExtensions.*
import static extension fr.cea.modane.uml.EObjectExtensions.*
import static extension fr.cea.modane.uml.ElementExtensions.*
import static extension fr.cea.modane.uml.ModelMetricsExtensions.*
import fr.cea.modane.generator.ModaneGeneratorMessageDispatcher
import fr.cea.modane.generator.ModaneGeneratorMessageDispatcher.MessageType

class UmlToModane
{
Expand Down Expand Up @@ -226,6 +226,7 @@ class UmlToModane
description = c.description
originNamespace = c.legacyNamespace
originFile = c.legacyFile
forceInclude = c.forceInclude
}

private def Pty create ModaneFactory::eINSTANCE.createPty toPty(Property p)
Expand Down
1 change: 1 addition & 0 deletions plugins/fr.cea.modane/model/generated/Modane.ecore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<eClassifiers xsi:type="ecore:EClass" name="Legacy" eSuperTypes="#//Referenceable">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="originFile" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="originNamespace" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="forceInclude" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Struct" eSuperTypes="#//Referenceable">
<eStructuralFeatures xsi:type="ecore:EReference" name="parents" unique="false"
Expand Down
1 change: 1 addition & 0 deletions plugins/fr.cea.modane/model/generated/Modane.genmodel
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<genClasses ecoreClass="Modane.ecore#//Legacy">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute Modane.ecore#//Legacy/originFile"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute Modane.ecore#//Legacy/originNamespace"/>
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute Modane.ecore#//Legacy/forceInclude"/>
</genClasses>
<genClasses ecoreClass="Modane.ecore#//Struct">
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference Modane.ecore#//Struct/parents"/>
Expand Down
32 changes: 16 additions & 16 deletions plugins/fr.cea.modane/src/fr/cea/modane/Modane.xtext
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ EnumerationLiteral:

Legacy:
description=STRING?
'Legacy' name=SimpleName 'file' originFile=STRING ('namespace' originNamespace=STRING)? ';';
'Legacy' name=SimpleName 'file' originFile=STRING ('namespace' originNamespace=STRING)? forceInclude?='forceInclude'?';';

// ----------------------------------------------------------------------------------------------------------------- //

Expand All @@ -67,15 +67,15 @@ Struct:
'{'
properties+=Pty*
'}';

Pty:
description=STRING?
('[' ('namefr' '=' namefr=STRING)? ('categories' '=' '(' categories+=[UserCategory|QualifiedName]* (',' categories+=[UserCategory|QualifiedName])* ')')? ']')?
multiplicity=PtyMultiplicity type=PtyOrArgType name=SimpleName ('=' defaultValue=STRING)? ';';

PtyOrArgType:
Simple | Item | ItemGroup | Reference;

// ----------------------------------------------------------------------------------------------------------------- //

Interface:
Expand All @@ -96,7 +96,7 @@ Function:
('call' '(' calls+=[Function|QualifiedName] (',' calls+=[Function|QualifiedName])* ')')? ';';

Arg:
ArgDefinition | VarDefinition;
ArgDefinition | VarDefinition;

ArgDefinition:
direction=Direction multiplicity=ArgMultiplicity? type=PtyOrArgType name=ID ('=' defaultValue=STRING)?;
Expand All @@ -118,7 +118,7 @@ ItemFamily:

ServiceOrModule:
Service | Module;

Service:
description=STRING?
('[' type=ServiceType? singleton?='singleton'? ('namefr' '=' namefr=STRING)? ('categories' '=' '(' categories+=[UserCategory|QualifiedName]* (',' categories+=[UserCategory|QualifiedName])* ')')? classSetUp?='class-set-up'? testSetUp?='test-set-up'? classTearDown?='class-tear-down'? testTearDown?='test-tear-down'? ']')?
Expand All @@ -130,7 +130,7 @@ Service:
functions+=Function*
unitTestFunctions+=UnitTestFunction*
'}';

OverrideFunction:
description=STRING?
'override' func=[Function|QualifiedName]
Expand All @@ -140,7 +140,7 @@ OverrideFunction:
UnitTestFunction:
description=STRING?
'test' name=SimpleName 'label' label=STRING ';';

enum ServiceType:
caseoption | application | session | subdomain;

Expand All @@ -167,10 +167,10 @@ EntryPoint:

enum EntryPointLocation:
ComputeLoop | OnMeshChanged | OnMeshRefinement | Init | ContinueInit | StartInit | Restore | Build | Exit;

enum EntryPointAutoLoad:
NoAutoLoad | AutoLoadBegin | AutoLoadEnd;
NoAutoLoad | AutoLoadBegin | AutoLoadEnd;

UserCategory:
description=STRING?
'UserCategory' name=SimpleName ';';
Expand All @@ -179,10 +179,10 @@ UserCategory:

Simple:
type=SimpleType;

Item:
type=ItemType;

ItemGroup:
type=ItemGroupType;

Expand All @@ -194,9 +194,9 @@ enum ItemType:

enum FunctionItemType:
NoItem | Item | Cell | Node | Face | Particle | MatCell | EnvCell | ComponentCell | AllEnvCell | DoF | ItemTypeSpecialized;

enum ItemGroupType:
NoItemGroup | ItemGroup | CellGroup | NodeGroup | FaceGroup | ParticleGroup | MatCellGroup | EnvCellGroup | ComponentCellGroup | AllEnvCellGroup;
NoItemGroup | ItemGroup | CellGroup | NodeGroup | FaceGroup | ParticleGroup | MatCellGroup | EnvCellGroup | ComponentCellGroup | AllEnvCellGroup;

enum SimpleType:
bool | String| Integer | Int32 | Int64 | Real | Real2 | Real3 | Real2x2 | Real3x3;
Expand All @@ -206,12 +206,12 @@ enum Direction:

enum PtyMultiplicity:
ZeroOne='[0..1]' | OneOne='[1..1]' | ZeroStar='[0..*]' | OneStar='[1..*]';

enum VariableMultiplicity:
Scalar='[1]' | Array='[*]' | Array2='[*,*]';

enum ArgMultiplicity:
Scalar='[1]' | Array='[*]';

// ----------------------------------------------------------------------------------------------------------------- //

Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ class ReferenceableExtensions
if (!originFile.nullOrEmpty)
{
if (context.name.endsWith(GenerationContext::HeaderExtension))
context.addClassDeclaration(originNamespace, referencedName, originFile)
{
if (forceInclude)
context.addInclude(originFile)
else
context.addClassDeclaration(originNamespace, referencedName, originFile)
}
}

if (originNamespace.nullOrEmpty) referencedName
Expand Down

0 comments on commit dc47f55

Please sign in to comment.