/*
 * generated by Xtext
 */
package eu.indenica.config.runtime.scoping;

import org.eclipse.emf.ecore.EReference;
import org.eclipse.xtext.scoping.IScope;
import org.eclipse.xtext.scoping.Scopes;
import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;

import eu.indenica.config.runtime.runtime.EventEmissionDeclaration;

/**
 * This class contains custom scoping description.
 * 
 * see : http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping on
 * how and when to use it
 * 
 */
public class RuntimeScopeProvider extends AbstractDeclarativeScopeProvider {
	IScope scope_EventAttribute(EventEmissionDeclaration ctx, EReference ref) {
		return Scopes.scopeFor(ctx.getEvent().getAttributes());
	}
}

@@ -67,16 +67,127 @@
 oping;%0A%0A
+import java.util.Collection;%0A%0Aimport org.eclipse.emf.ecore.EGenericType;%0Aimport org.eclipse.emf.ecore.EObject;%0A
 import o
@@ -385,67 +385,336 @@
 ort 
-eu.indenica.config.runtime.runtime.EventEmissionDeclaration
+com.google.common.collect.Lists;%0A%0Aimport eu.indenica.config.runtime.runtime.Event;%0Aimport eu.indenica.config.runtime.runtime.EventEmissionDeclaration;%0Aimport eu.indenica.config.runtime.runtime.EventSource;%0Aimport eu.indenica.config.runtime.runtime.EventSourceDeclaration;%0Aimport eu.indenica.config.runtime.runtime.MonitoringRule
 ;%0A%0A/
@@ -1100,11 +1100,522 @@
 s());%0A%09%7D
+%0A%0A%09IScope scope_JvmIdentifiableElement(MonitoringRule ctx, EReference ref) %7B%0A%09%09Collection%3CEObject%3E elements = Lists.newArrayList();%0A%09%09Collection%3CEventSource%3E sources = Lists.newArrayList();%0A%0A%09%09for(EventSourceDeclaration source : ctx.getSources())%0A%09%09%09sources.addAll(source.getSources());%0A%0A%09%09for(EventSource source : sources) %7B%0A%09%09%09elements.add(source);%0A%09%09%09for(Event event : source.getEvents()) %7B%0A%09%09%09%09elements.add(event);%0A%09%09%09%09elements.addAll(event.getAttributes());%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return Scopes.scopeFor(elements);%0A%09%7D
 %0A%7D%0A

Add proper scoping inside rules.