use of org.eclipse.xtext.util.PolymorphicDispatcher in project xtext-core by eclipse.
the class AbstractDeclarativeScopeProvider method polymorphicFindScopeForClassName.
protected IScope polymorphicFindScopeForClassName(EObject context, EReference reference) {
IScope scope = null;
PolymorphicDispatcher<IScope> dispatcher = new PolymorphicDispatcher<IScope>(Collections.singletonList(this), getPredicate(context, reference.getEReferenceType()), errorHandler) {
@Override
protected IScope handleNoSuchMethod(Object... params) {
if (PolymorphicDispatcher.NullErrorHandler.class.equals(errorHandler.getClass()))
return null;
return super.handleNoSuchMethod(params);
}
};
EObject current = context;
while (scope == null && current != null) {
scope = dispatcher.invoke(current, reference);
current = current.eContainer();
}
current = context;
while (scope == null && current != null) {
scope = dispatcher.invoke(current, reference.getEReferenceType());
if (scope != null)
logger.warn("scope_<EClass>(EObject,EClass) is deprecated. Use scope_<EClass>(EObject,EReference) instead.");
current = current.eContainer();
}
return scope;
}
use of org.eclipse.xtext.util.PolymorphicDispatcher in project xtext-core by eclipse.
the class AbstractDeclarativeScopeProvider method polymorphicFindScopeForReferenceName.
protected IScope polymorphicFindScopeForReferenceName(EObject context, EReference reference) {
Predicate<Method> predicate = getPredicate(context, reference);
PolymorphicDispatcher<IScope> dispatcher = new PolymorphicDispatcher<IScope>(Collections.singletonList(this), predicate, errorHandler) {
@Override
protected IScope handleNoSuchMethod(Object... params) {
if (PolymorphicDispatcher.NullErrorHandler.class.equals(errorHandler.getClass()))
return null;
return super.handleNoSuchMethod(params);
}
};
EObject current = context;
IScope scope = null;
while (scope == null && current != null) {
scope = dispatcher.invoke(current, reference);
current = current.eContainer();
}
return scope;
}
Aggregations