Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/GenerateTTCN3.mwe2 +3 −3 Original line number Diff line number Diff line Loading @@ -129,10 +129,10 @@ Workflow { fragment = refactoring.RefactorElementNameFragment auto-inject {} // provides the necessary bindings for java types integration fragment = types.TypesGeneratorFragment auto-inject {} // fragment = types.TypesGeneratorFragment auto-inject {} // generates the required bindings only if the grammar inherits from Xbase fragment = xbase.XbaseGeneratorFragment auto-inject {} // fragment = xbase.XbaseGeneratorFragment auto-inject {} // provides a preference page for template proposals fragment = templates.CodetemplatesGeneratorFragment auto-inject {} Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3.xtext +28 −24 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ ExtConstDef: EXTKEYWORD CONSTKEYWORD type=Type id=IdentifierList; ImportDef: IMPORTKEYWORD FROMKEYWORD importedModule=IDENTIFIER spec=LanguageSpec? RECURSIVEKEYWORD? (all=AllWithExcepts | IMPORTKEYWORD FROMKEYWORD moduleNamespace=IDENTIFIER spec=LanguageSpec? RECURSIVEKEYWORD? (all=AllWithExcepts | LBRACKET importSpec=ImportSpec RBRACKET); AllWithExcepts: Loading Loading @@ -186,7 +186,7 @@ ConfigSpec: runsOn=RunsOnSpec systemSpec=SystemSpec?; SystemSpec: SYSTEMKEYWORD component=[ComponentDef|IDENTIFIER]; SYSTEMKEYWORD component=[ComponentDef|QualifiedIdentifier]; SignatureDef: SIGNATUREKEYWORD name=IDENTIFIER LPAREN paramList=SignatureFormalParList? RPAREN (return=ReturnType | Loading Loading @@ -257,7 +257,7 @@ AltConstruct: ALTKEYWORD LBRACKET agList=AltGuardList RBRACKET; AltGuardList: {AltGuardList} (guardList+=GuardStatement | elseList+=ElseStatement SEMICOLON?)*; {AltGuardList} (guardList+=GuardStatement | elseList+=ElseStatement)* SEMICOLON?; ElseStatement: SQUAREOPEN ELSEKEYWORD SQUARECLOSE block=StatementBlock; Loading Loading @@ -392,17 +392,17 @@ AltGuardChar: {AltGuardChar} SQUAREOPEN expr=BooleanExpression? SQUARECLOSE; AltstepInstance: ref=[AltstepDef|IDENTIFIER] LPAREN list=FunctionActualParList? RPAREN; ref=[AltstepDef|QualifiedIdentifier] LPAREN list=FunctionActualParList? RPAREN; FunctionInstance: ref=[FunctionRef|IDENTIFIER] LPAREN params=FunctionActualParList? RPAREN; ref=[FunctionRef|QualifiedIdentifier] LPAREN params=FunctionActualParList? RPAREN; //TODO: check references // scope fore something like this: foo.bar.func // ext ref ok? // usage / semantic of PreDefFunctionIdentifier? FunctionRef: FunctionDef | ExtFunctionDef; FunctionDef | ExtFunctionDef | BaseTemplate; //(IDENTIFIER DOT)? IDENTIFIER; FunctionActualParList: Loading Loading @@ -430,7 +430,7 @@ ComponentOrDefaultReference: variable=VariableRef | function=FunctionInstance /*| preFunction=PreDefFunction*/; TestcaseInstance: EXECUTEKEYWORD LPAREN ref=[TestcaseDef|IDENTIFIER] LPAREN tcParams=TestcaseActualParList? RPAREN (COMMA EXECUTEKEYWORD LPAREN ref=[TestcaseDef|QualifiedIdentifier] LPAREN tcParams=TestcaseActualParList? RPAREN (COMMA (expr=Expression | MINUS) (COMMA sexpr=SingleExpression)?)? RPAREN; TestcaseActualParList: Loading @@ -444,16 +444,16 @@ TimeoutStatement: ref=TimerRefOrAny DOT TIMEOUTKEYWORD; StartTimerStatement: ref=[SingleVarInstance|IDENTIFIER] arryRefs+=ArrayOrBitRef* DOT STARTKEYWORD (LPAREN expr=Expression RPAREN)?; ref=[TimerVarInstance|IDENTIFIER] arryRefs+=ArrayOrBitRef* DOT STARTKEYWORD (LPAREN expr=Expression RPAREN)?; StopTimerStatement: ref=TimerRefOrAll DOT STOPKEYWORD; TimerRefOrAny: ref=[SingleVarInstance|IDENTIFIER] | {TimerRefOrAny} ANYKEYWORD timer=TIMERKEYWORD; ref=[TimerVarInstance|IDENTIFIER] | {TimerRefOrAny} ANYKEYWORD timer=TIMERKEYWORD; TimerRefOrAll: ref=[SingleVarInstance|IDENTIFIER] | {TimerRefOrAll} ALLKEYWORD timer=TIMERKEYWORD; ref=[TimerVarInstance|IDENTIFIER] | {TimerRefOrAll} ALLKEYWORD timer=TIMERKEYWORD; //TODO: references ArrayIdentifierRef: Loading Loading @@ -563,7 +563,7 @@ RaiseStatement: array=ArrayIdentifierRef DOT op=PortRaiseOp; PortRaiseOp: RAISEKEYWORD LPAREN signature=[SignatureDef|IDENTIFIER] COMMA template=InLineTemplate RPAREN to=ToClause?; RAISEKEYWORD LPAREN signature=[SignatureDef|QualifiedIdentifier] COMMA template=InLineTemplate RPAREN to=ToClause?; ReplyStatement: array=ArrayIdentifierRef DOT op=PortReplyOp; Loading Loading @@ -722,14 +722,14 @@ ProcedureAttribs: RBRACKET; ComponentDef: COMPONENTKEYWORD name=IDENTIFIER (EXTENDSKEYWORD extends+=[ComponentDef|IDENTIFIER] (COMMA extends+=[ComponentDef|IDENTIFIER])*)? LBRACKET defs+=ComponentDefList* RBRACKET; COMPONENTKEYWORD name=IDENTIFIER (EXTENDSKEYWORD extends+=[ComponentDef|QualifiedIdentifier] (COMMA extends+=[ComponentDef|QualifiedIdentifier])*)? LBRACKET defs+=ComponentDefList* RBRACKET; ComponentDefList: element=ComponentElementDef wst=WithStatement? sc=SEMICOLON?; PortInstance: PORTKEYWORD ref=[PortDef|IDENTIFIER] instances+=PortElement (COMMA instances+=PortElement)*; PORTKEYWORD ref=[PortDef|QualifiedIdentifier] instances+=PortElement (COMMA instances+=PortElement)*; PortElement: name=IDENTIFIER array=ArrayDef?; Loading Loading @@ -838,7 +838,7 @@ TemplateDef: TEMPLATEKEYWORD res=TemplateRestriction? base=BaseTemplate derived=DerivedDef? ASSIGNMENTCHAR body=TemplateBody; DerivedDef: MODIFIESKEYWORD template=[BaseTemplate|IDENTIFIER]; MODIFIESKEYWORD template=[BaseTemplate|QualifiedIdentifier]; /// changed Signature -> Type BaseTemplate: Loading @@ -847,6 +847,9 @@ BaseTemplate: TempVarList: variables+=SingleTempVarInstance (COMMA variables+=SingleTempVarInstance)*; TimerVarInstance: SingleVarInstance | FormalTimerPar; SingleVarInstance: name=IDENTIFIER array=ArrayDef? (ac=ASSIGNMENTCHAR expr=Expression)?; Loading Loading @@ -879,11 +882,11 @@ SimpleTemplateSpec: expr=SingleTemplateExpression (STRINGOP spec=SimpleSpec)?; SingleTemplateExpression: symbol=MatchingSymbol | list=TemplateRefWithParList ref+=ExtendedFieldReference; symbol=MatchingSymbol | list=TemplateRefWithParList extended=ExtendedFieldReference?; // TODO: test this! TemplateRefWithParList: template=[TemplateBody|IDENTIFIER] list=TemplateActualParList?; template=[TemplateBody|QualifiedIdentifier] list=TemplateActualParList?; TemplateActualParList: {TemplateActualParList} LPAREN (actual+=TemplateInstanceActualPar (COMMA actual+=TemplateInstanceActualPar)* | Loading Loading @@ -925,7 +928,7 @@ ConfigurationOps: alive=AliveOp | running=RunningOp; CreateOp: type=[ComponentDef|IDENTIFIER] DOT CREATEKEYWORD (LPAREN (expr1=SingleExpression | MINUS) (COMMA type=[ComponentDef|QualifiedIdentifier] DOT CREATEKEYWORD (LPAREN (expr1=SingleExpression | MINUS) (COMMA expr2=SingleExpression)? RPAREN)? ALIVEKEYWORD?; RunningOp: Loading @@ -945,8 +948,9 @@ TemplateListItem: AllElementsFrom: ALLKEYWORD FROMKEYWORD body=TemplateBody; // TODO: remove this rule? Signature: ref=[SignatureDef|IDENTIFIER]; ref=[SignatureDef|QualifiedIdentifier]; TemplateInstanceAssignment: name=IDENTIFIER ASSIGNMENTCHAR template=InLineTemplate; Loading Loading @@ -1046,14 +1050,14 @@ ConstList: list+=SingleConstDef (COMMA list+=SingleConstDef)*; Value: PredefinedValue | ReferencedValue; predef=PredefinedValue | ref=ReferencedValue; ReferencedValue: ref=[RefValue|QualifiedIdentifier] fieldRefs+=ExtendedFieldReference*; RefValue: SingleConstDef | ModuleParameter | SingleVarInstance | FieldReference | FormalTemplatePar | SingleTempVarInstance | BaseTemplate | Enumeration; SingleConstDef | ModuleParameter | FieldReference | FormalTemplatePar | SingleTempVarInstance | Enumeration | FunctionRef | TimerVarInstance | FormalPortPar; // IDENTIFIER omitted PredefinedValue: Loading Loading @@ -1201,7 +1205,7 @@ FunctionDef: system=SystemSpec? returnType=ReturnType? statement=StatementBlock; MtcSpec: MTCKEYWORD type=[ComponentDef|IDENTIFIER]; MTCKEYWORD component=[ComponentDef|QualifiedIdentifier]; FunctionFormalParList: params+=FunctionFormalPar (COMMA params+=FunctionFormalPar)*; Loading @@ -1224,7 +1228,7 @@ FormalTemplatePar: name=IDENTIFIER (ASSIGNMENTCHAR (templ=InLineTemplate | MINUS))?; RunsOnSpec: RUNSKEYWORD ONKEYWORD component=[ComponentDef|IDENTIFIER]; RUNSKEYWORD ONKEYWORD component=[ComponentDef|QualifiedIdentifier]; ReturnType: RETURNKEYWORD (TEMPLATEKEYWORD | RestrictedTemplate)? type=Type; Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3RuntimeModule.java +9 −1 Original line number Diff line number Diff line Loading @@ -3,9 +3,17 @@ */ package de.ugoe.cs.swe; import org.eclipse.xtext.naming.IQualifiedNameProvider; import de.ugoe.cs.swe.common.TTCN3DeclarativeQualifiedNameProvider; /** * Use this class to register components to be used at runtime / without the Equinox extension registry. */ public class TTCN3RuntimeModule extends de.ugoe.cs.swe.AbstractTTCN3RuntimeModule { public class TTCN3RuntimeModule extends AbstractTTCN3RuntimeModule { @Override public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() { return TTCN3DeclarativeQualifiedNameProvider.class; } } de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/TTCN3DeclarativeQualifiedNameProvider.java 0 → 100644 +39 −0 Original line number Diff line number Diff line package de.ugoe.cs.swe.common; import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider; import org.eclipse.xtext.naming.IQualifiedNameConverter; import org.eclipse.xtext.naming.QualifiedName; import com.google.inject.Inject; import de.ugoe.cs.swe.tTCN3.FormalPortPar; import de.ugoe.cs.swe.tTCN3.FormalTemplatePar; import de.ugoe.cs.swe.tTCN3.FormalTimerPar; import de.ugoe.cs.swe.tTCN3.FormalValuePar; /** * * @author Daniel Honsel * */ public class TTCN3DeclarativeQualifiedNameProvider extends DefaultDeclarativeQualifiedNameProvider { @Inject private IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl(); protected QualifiedName qualifiedName(FormalValuePar ele){ return converter.toQualifiedName(ele.getName()); } protected QualifiedName qualifiedName(FormalTemplatePar ele){ return converter.toQualifiedName(ele.getName()); } protected QualifiedName qualifiedName(FormalTimerPar ele){ return converter.toQualifiedName(ele.getName()); } protected QualifiedName qualifiedName(FormalPortPar ele){ return converter.toQualifiedName(ele.getName()); } } de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/TTCN3ScopeHelper.xtend +39 −3 Original line number Diff line number Diff line Loading @@ -49,14 +49,19 @@ import java.util.ArrayList import org.eclipse.emf.ecore.EObject import de.ugoe.cs.swe.tTCN3.GroupDef import de.ugoe.cs.swe.tTCN3.TTCN3Module import org.eclipse.xtext.scoping.IScope import de.ugoe.cs.swe.tTCN3.FunctionDef import static org.eclipse.xtext.scoping.Scopes.* import de.ugoe.cs.swe.tTCN3.TestcaseDef class TTCN3ScopeHelper { def static Object findDesiredParent(EObject o, Class<?> t) { def static <T extends EObject> T findDesiredParent(EObject o, Class<T> t) { if (o.eContainer == null) null else if (t.isAssignableFrom(o.eContainer.class)) o.eContainer o.eContainer as T else o.eContainer.findDesiredParent(t) } Loading Loading @@ -269,6 +274,37 @@ class TTCN3ScopeHelper { } } def static dispatch IScope scopeTimerSpec(FunctionDef function) { val list = newArrayList if (function.runsOn != null) { componentScopeValueRefs(function.runsOn.component, list, true, false) } if (function.mtc != null) { componentScopeValueRefs(function.mtc.component, list, true, false) } if (function.system != null) { componentScopeValueRefs(function.system.component, list, true, false) } scopeFor(list) } def static dispatch IScope scopeTimerSpec(AltstepDef altstep) { val list = newArrayList if (altstep.spec != null) { componentScopeValueRefs(altstep.spec.component, list, true, false) } scopeFor(list) } def static dispatch IScope scopeTimerSpec(TestcaseDef testcase) { val list = newArrayList componentScopeValueRefs(testcase.spec.runsOn.component, list, true, false) if (testcase.spec.systemSpec != null) { componentScopeValueRefs(testcase.spec.systemSpec.component, list, true, false) } scopeFor(list) } def static void componentScopeValueRefs(ComponentDef component, ArrayList<EObject> list, boolean searchTimer, boolean searchVar) { if (searchVar) { Loading Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/GenerateTTCN3.mwe2 +3 −3 Original line number Diff line number Diff line Loading @@ -129,10 +129,10 @@ Workflow { fragment = refactoring.RefactorElementNameFragment auto-inject {} // provides the necessary bindings for java types integration fragment = types.TypesGeneratorFragment auto-inject {} // fragment = types.TypesGeneratorFragment auto-inject {} // generates the required bindings only if the grammar inherits from Xbase fragment = xbase.XbaseGeneratorFragment auto-inject {} // fragment = xbase.XbaseGeneratorFragment auto-inject {} // provides a preference page for template proposals fragment = templates.CodetemplatesGeneratorFragment auto-inject {} Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3.xtext +28 −24 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ ExtConstDef: EXTKEYWORD CONSTKEYWORD type=Type id=IdentifierList; ImportDef: IMPORTKEYWORD FROMKEYWORD importedModule=IDENTIFIER spec=LanguageSpec? RECURSIVEKEYWORD? (all=AllWithExcepts | IMPORTKEYWORD FROMKEYWORD moduleNamespace=IDENTIFIER spec=LanguageSpec? RECURSIVEKEYWORD? (all=AllWithExcepts | LBRACKET importSpec=ImportSpec RBRACKET); AllWithExcepts: Loading Loading @@ -186,7 +186,7 @@ ConfigSpec: runsOn=RunsOnSpec systemSpec=SystemSpec?; SystemSpec: SYSTEMKEYWORD component=[ComponentDef|IDENTIFIER]; SYSTEMKEYWORD component=[ComponentDef|QualifiedIdentifier]; SignatureDef: SIGNATUREKEYWORD name=IDENTIFIER LPAREN paramList=SignatureFormalParList? RPAREN (return=ReturnType | Loading Loading @@ -257,7 +257,7 @@ AltConstruct: ALTKEYWORD LBRACKET agList=AltGuardList RBRACKET; AltGuardList: {AltGuardList} (guardList+=GuardStatement | elseList+=ElseStatement SEMICOLON?)*; {AltGuardList} (guardList+=GuardStatement | elseList+=ElseStatement)* SEMICOLON?; ElseStatement: SQUAREOPEN ELSEKEYWORD SQUARECLOSE block=StatementBlock; Loading Loading @@ -392,17 +392,17 @@ AltGuardChar: {AltGuardChar} SQUAREOPEN expr=BooleanExpression? SQUARECLOSE; AltstepInstance: ref=[AltstepDef|IDENTIFIER] LPAREN list=FunctionActualParList? RPAREN; ref=[AltstepDef|QualifiedIdentifier] LPAREN list=FunctionActualParList? RPAREN; FunctionInstance: ref=[FunctionRef|IDENTIFIER] LPAREN params=FunctionActualParList? RPAREN; ref=[FunctionRef|QualifiedIdentifier] LPAREN params=FunctionActualParList? RPAREN; //TODO: check references // scope fore something like this: foo.bar.func // ext ref ok? // usage / semantic of PreDefFunctionIdentifier? FunctionRef: FunctionDef | ExtFunctionDef; FunctionDef | ExtFunctionDef | BaseTemplate; //(IDENTIFIER DOT)? IDENTIFIER; FunctionActualParList: Loading Loading @@ -430,7 +430,7 @@ ComponentOrDefaultReference: variable=VariableRef | function=FunctionInstance /*| preFunction=PreDefFunction*/; TestcaseInstance: EXECUTEKEYWORD LPAREN ref=[TestcaseDef|IDENTIFIER] LPAREN tcParams=TestcaseActualParList? RPAREN (COMMA EXECUTEKEYWORD LPAREN ref=[TestcaseDef|QualifiedIdentifier] LPAREN tcParams=TestcaseActualParList? RPAREN (COMMA (expr=Expression | MINUS) (COMMA sexpr=SingleExpression)?)? RPAREN; TestcaseActualParList: Loading @@ -444,16 +444,16 @@ TimeoutStatement: ref=TimerRefOrAny DOT TIMEOUTKEYWORD; StartTimerStatement: ref=[SingleVarInstance|IDENTIFIER] arryRefs+=ArrayOrBitRef* DOT STARTKEYWORD (LPAREN expr=Expression RPAREN)?; ref=[TimerVarInstance|IDENTIFIER] arryRefs+=ArrayOrBitRef* DOT STARTKEYWORD (LPAREN expr=Expression RPAREN)?; StopTimerStatement: ref=TimerRefOrAll DOT STOPKEYWORD; TimerRefOrAny: ref=[SingleVarInstance|IDENTIFIER] | {TimerRefOrAny} ANYKEYWORD timer=TIMERKEYWORD; ref=[TimerVarInstance|IDENTIFIER] | {TimerRefOrAny} ANYKEYWORD timer=TIMERKEYWORD; TimerRefOrAll: ref=[SingleVarInstance|IDENTIFIER] | {TimerRefOrAll} ALLKEYWORD timer=TIMERKEYWORD; ref=[TimerVarInstance|IDENTIFIER] | {TimerRefOrAll} ALLKEYWORD timer=TIMERKEYWORD; //TODO: references ArrayIdentifierRef: Loading Loading @@ -563,7 +563,7 @@ RaiseStatement: array=ArrayIdentifierRef DOT op=PortRaiseOp; PortRaiseOp: RAISEKEYWORD LPAREN signature=[SignatureDef|IDENTIFIER] COMMA template=InLineTemplate RPAREN to=ToClause?; RAISEKEYWORD LPAREN signature=[SignatureDef|QualifiedIdentifier] COMMA template=InLineTemplate RPAREN to=ToClause?; ReplyStatement: array=ArrayIdentifierRef DOT op=PortReplyOp; Loading Loading @@ -722,14 +722,14 @@ ProcedureAttribs: RBRACKET; ComponentDef: COMPONENTKEYWORD name=IDENTIFIER (EXTENDSKEYWORD extends+=[ComponentDef|IDENTIFIER] (COMMA extends+=[ComponentDef|IDENTIFIER])*)? LBRACKET defs+=ComponentDefList* RBRACKET; COMPONENTKEYWORD name=IDENTIFIER (EXTENDSKEYWORD extends+=[ComponentDef|QualifiedIdentifier] (COMMA extends+=[ComponentDef|QualifiedIdentifier])*)? LBRACKET defs+=ComponentDefList* RBRACKET; ComponentDefList: element=ComponentElementDef wst=WithStatement? sc=SEMICOLON?; PortInstance: PORTKEYWORD ref=[PortDef|IDENTIFIER] instances+=PortElement (COMMA instances+=PortElement)*; PORTKEYWORD ref=[PortDef|QualifiedIdentifier] instances+=PortElement (COMMA instances+=PortElement)*; PortElement: name=IDENTIFIER array=ArrayDef?; Loading Loading @@ -838,7 +838,7 @@ TemplateDef: TEMPLATEKEYWORD res=TemplateRestriction? base=BaseTemplate derived=DerivedDef? ASSIGNMENTCHAR body=TemplateBody; DerivedDef: MODIFIESKEYWORD template=[BaseTemplate|IDENTIFIER]; MODIFIESKEYWORD template=[BaseTemplate|QualifiedIdentifier]; /// changed Signature -> Type BaseTemplate: Loading @@ -847,6 +847,9 @@ BaseTemplate: TempVarList: variables+=SingleTempVarInstance (COMMA variables+=SingleTempVarInstance)*; TimerVarInstance: SingleVarInstance | FormalTimerPar; SingleVarInstance: name=IDENTIFIER array=ArrayDef? (ac=ASSIGNMENTCHAR expr=Expression)?; Loading Loading @@ -879,11 +882,11 @@ SimpleTemplateSpec: expr=SingleTemplateExpression (STRINGOP spec=SimpleSpec)?; SingleTemplateExpression: symbol=MatchingSymbol | list=TemplateRefWithParList ref+=ExtendedFieldReference; symbol=MatchingSymbol | list=TemplateRefWithParList extended=ExtendedFieldReference?; // TODO: test this! TemplateRefWithParList: template=[TemplateBody|IDENTIFIER] list=TemplateActualParList?; template=[TemplateBody|QualifiedIdentifier] list=TemplateActualParList?; TemplateActualParList: {TemplateActualParList} LPAREN (actual+=TemplateInstanceActualPar (COMMA actual+=TemplateInstanceActualPar)* | Loading Loading @@ -925,7 +928,7 @@ ConfigurationOps: alive=AliveOp | running=RunningOp; CreateOp: type=[ComponentDef|IDENTIFIER] DOT CREATEKEYWORD (LPAREN (expr1=SingleExpression | MINUS) (COMMA type=[ComponentDef|QualifiedIdentifier] DOT CREATEKEYWORD (LPAREN (expr1=SingleExpression | MINUS) (COMMA expr2=SingleExpression)? RPAREN)? ALIVEKEYWORD?; RunningOp: Loading @@ -945,8 +948,9 @@ TemplateListItem: AllElementsFrom: ALLKEYWORD FROMKEYWORD body=TemplateBody; // TODO: remove this rule? Signature: ref=[SignatureDef|IDENTIFIER]; ref=[SignatureDef|QualifiedIdentifier]; TemplateInstanceAssignment: name=IDENTIFIER ASSIGNMENTCHAR template=InLineTemplate; Loading Loading @@ -1046,14 +1050,14 @@ ConstList: list+=SingleConstDef (COMMA list+=SingleConstDef)*; Value: PredefinedValue | ReferencedValue; predef=PredefinedValue | ref=ReferencedValue; ReferencedValue: ref=[RefValue|QualifiedIdentifier] fieldRefs+=ExtendedFieldReference*; RefValue: SingleConstDef | ModuleParameter | SingleVarInstance | FieldReference | FormalTemplatePar | SingleTempVarInstance | BaseTemplate | Enumeration; SingleConstDef | ModuleParameter | FieldReference | FormalTemplatePar | SingleTempVarInstance | Enumeration | FunctionRef | TimerVarInstance | FormalPortPar; // IDENTIFIER omitted PredefinedValue: Loading Loading @@ -1201,7 +1205,7 @@ FunctionDef: system=SystemSpec? returnType=ReturnType? statement=StatementBlock; MtcSpec: MTCKEYWORD type=[ComponentDef|IDENTIFIER]; MTCKEYWORD component=[ComponentDef|QualifiedIdentifier]; FunctionFormalParList: params+=FunctionFormalPar (COMMA params+=FunctionFormalPar)*; Loading @@ -1224,7 +1228,7 @@ FormalTemplatePar: name=IDENTIFIER (ASSIGNMENTCHAR (templ=InLineTemplate | MINUS))?; RunsOnSpec: RUNSKEYWORD ONKEYWORD component=[ComponentDef|IDENTIFIER]; RUNSKEYWORD ONKEYWORD component=[ComponentDef|QualifiedIdentifier]; ReturnType: RETURNKEYWORD (TEMPLATEKEYWORD | RestrictedTemplate)? type=Type; Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3RuntimeModule.java +9 −1 Original line number Diff line number Diff line Loading @@ -3,9 +3,17 @@ */ package de.ugoe.cs.swe; import org.eclipse.xtext.naming.IQualifiedNameProvider; import de.ugoe.cs.swe.common.TTCN3DeclarativeQualifiedNameProvider; /** * Use this class to register components to be used at runtime / without the Equinox extension registry. */ public class TTCN3RuntimeModule extends de.ugoe.cs.swe.AbstractTTCN3RuntimeModule { public class TTCN3RuntimeModule extends AbstractTTCN3RuntimeModule { @Override public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() { return TTCN3DeclarativeQualifiedNameProvider.class; } }
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/TTCN3DeclarativeQualifiedNameProvider.java 0 → 100644 +39 −0 Original line number Diff line number Diff line package de.ugoe.cs.swe.common; import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider; import org.eclipse.xtext.naming.IQualifiedNameConverter; import org.eclipse.xtext.naming.QualifiedName; import com.google.inject.Inject; import de.ugoe.cs.swe.tTCN3.FormalPortPar; import de.ugoe.cs.swe.tTCN3.FormalTemplatePar; import de.ugoe.cs.swe.tTCN3.FormalTimerPar; import de.ugoe.cs.swe.tTCN3.FormalValuePar; /** * * @author Daniel Honsel * */ public class TTCN3DeclarativeQualifiedNameProvider extends DefaultDeclarativeQualifiedNameProvider { @Inject private IQualifiedNameConverter converter = new IQualifiedNameConverter.DefaultImpl(); protected QualifiedName qualifiedName(FormalValuePar ele){ return converter.toQualifiedName(ele.getName()); } protected QualifiedName qualifiedName(FormalTemplatePar ele){ return converter.toQualifiedName(ele.getName()); } protected QualifiedName qualifiedName(FormalTimerPar ele){ return converter.toQualifiedName(ele.getName()); } protected QualifiedName qualifiedName(FormalPortPar ele){ return converter.toQualifiedName(ele.getName()); } }
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/TTCN3ScopeHelper.xtend +39 −3 Original line number Diff line number Diff line Loading @@ -49,14 +49,19 @@ import java.util.ArrayList import org.eclipse.emf.ecore.EObject import de.ugoe.cs.swe.tTCN3.GroupDef import de.ugoe.cs.swe.tTCN3.TTCN3Module import org.eclipse.xtext.scoping.IScope import de.ugoe.cs.swe.tTCN3.FunctionDef import static org.eclipse.xtext.scoping.Scopes.* import de.ugoe.cs.swe.tTCN3.TestcaseDef class TTCN3ScopeHelper { def static Object findDesiredParent(EObject o, Class<?> t) { def static <T extends EObject> T findDesiredParent(EObject o, Class<T> t) { if (o.eContainer == null) null else if (t.isAssignableFrom(o.eContainer.class)) o.eContainer o.eContainer as T else o.eContainer.findDesiredParent(t) } Loading Loading @@ -269,6 +274,37 @@ class TTCN3ScopeHelper { } } def static dispatch IScope scopeTimerSpec(FunctionDef function) { val list = newArrayList if (function.runsOn != null) { componentScopeValueRefs(function.runsOn.component, list, true, false) } if (function.mtc != null) { componentScopeValueRefs(function.mtc.component, list, true, false) } if (function.system != null) { componentScopeValueRefs(function.system.component, list, true, false) } scopeFor(list) } def static dispatch IScope scopeTimerSpec(AltstepDef altstep) { val list = newArrayList if (altstep.spec != null) { componentScopeValueRefs(altstep.spec.component, list, true, false) } scopeFor(list) } def static dispatch IScope scopeTimerSpec(TestcaseDef testcase) { val list = newArrayList componentScopeValueRefs(testcase.spec.runsOn.component, list, true, false) if (testcase.spec.systemSpec != null) { componentScopeValueRefs(testcase.spec.systemSpec.component, list, true, false) } scopeFor(list) } def static void componentScopeValueRefs(ComponentDef component, ArrayList<EObject> list, boolean searchTimer, boolean searchVar) { if (searchVar) { Loading