| /* |
| * generated by Xtext |
| */ |
| package org.eclipse.vorto.fbeditor.scoping |
| |
| import org.eclipse.vorto.functionblock.Entity |
| import org.eclipse.vorto.functionblock.Enum |
| import org.eclipse.vorto.functionblock.FunctionblockModel |
| import org.eclipse.vorto.functionblock.ObjectProperty |
| import java.util.ArrayList |
| import javax.inject.Inject |
| import org.eclipse.emf.ecore.EReference |
| import org.eclipse.xtext.EcoreUtil2 |
| import org.eclipse.xtext.naming.IQualifiedNameProvider |
| import org.eclipse.xtext.resource.EObjectDescription |
| import org.eclipse.xtext.resource.IEObjectDescription |
| import org.eclipse.xtext.scoping.IScope |
| import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider |
| import org.eclipse.xtext.scoping.impl.SimpleScope |
| |
| /** |
| * This class contains custom scoping description. |
| * |
| * see : http://www.eclipse.org/Xtext/documentation.html#scoping |
| * on how and when to use it |
| * |
| */ |
| class FunctionblockScopeProvider extends AbstractDeclarativeScopeProvider { |
| |
| @Inject |
| IQualifiedNameProvider nameProvider; |
| |
| def IScope scope_Property_type(ObjectProperty o, EReference r) { |
| var objects = new ArrayList<IEObjectDescription>(); |
| var model = EcoreUtil2.getContainerOfType(o, typeof(FunctionblockModel)); |
| for (Entity entity : model.elements) { |
| objects.add(EObjectDescription.create(nameProvider.getFullyQualifiedName(entity),entity)); |
| } |
| |
| for (Enum enumeration : model.enums) { |
| objects.add(EObjectDescription.create(nameProvider.getFullyQualifiedName(enumeration),enumeration)); |
| } |
| |
| |
| return new SimpleScope(IScope.NULLSCOPE, objects); |
| } |
| } |