////////////////////// Variable Declaration ////////////////////////////
VariableDeclaration:
name=ID ':'
variable_type = VariableType '=>'
initial_value = Value
";"
;
/////////////////////// Variable Type /////////////////////////////
VariableType:
ref=[aadl2::DataClassifier | QPREF]
QPREF:
ID ('::' ID)?
;
Here is the model:
variables
floatvariable : ldt1 => 6.0;
negvariable : ldt1 => -7;
intvariable : ldt1 => 90909;
bolvariable : ldt1 => true;
bolvariable2 : ldt2 => false;
v12: Base_Types::Float => 10.0;
v1: Test_Types::dt1 => 0.0;
v2: Test_Types::dt1 => 9.0;
The local scoping is working fine as the data components in the same AADL file (ldt1 and ldt2) are referenced properly. But for the data components defined in the Base_Types and Test_Types there are errors like "Couldn't resolve reference to DataClassifier 'Base_Types::Float'." Both Base_Types and Test_Types are added using the with clause.
I believe for Base_Types, it should be straight forward but I have tried to implement global scoping through GlobalScopProvider.xtend, Index.xtend, and RuntimeModule.xtend for global scoping but am still facing the same problem with variable types.
I am using Eclipse Version: 2022-03 (4.23.0), Build id: 20220310-1457
Here is my GlobalScopProvider.xtend,
package org.osate.aadl.devs.scoping
import org.osate.aadl2.modelsupport.scoping.EClassGlobalScopeProvider
import com.google.inject.Inject
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.EReference
import org.eclipse.xtext.resource.IEObjectDescription
import com.google.common.base.Predicate
import org.osate.aadl.devs.dEVS.DEVSPackage
import java.util.List
import org.eclipse.emf.ecore.EObject
import org.eclipse.xtext.scoping.Scopes
import java.util.ArrayList
class DevsGlobalScopeProvider extends EClassGlobalScopeProvider{
@Inject extension DevsIndex
override
getScope(Resource context, EReference reference, Predicate<IEObjectDescription> filter)
{
if(reference == DEVSPackage.eINSTANCE.variableType_Ref)
{
val List<EObject> gvTypes = new ArrayList<EObject>()
for (gvt : context.getVisibleVariableTypes)
gvTypes.add(gvt as EObject)
return Scopes.scopeFor(gvTypes)
}
}
}
Here is the RuntimeModule.xtend:
package org.osate.aadl.devs
import com.google.inject.Module