本文整理匯總了Java中org.eclipse.xtext.util.PolymorphicDispatcher類的典型用法代碼示例。如果您正苦於以下問題:Java PolymorphicDispatcher類的具體用法?Java PolymorphicDispatcher怎麽用?Java PolymorphicDispatcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PolymorphicDispatcher類屬於org.eclipse.xtext.util包,在下文中一共展示了PolymorphicDispatcher類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: polymorphicFindScopeForReferenceName
import org.eclipse.xtext.util.PolymorphicDispatcher; //導入依賴的package包/類
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;
}
示例2: invokeMethod
import org.eclipse.xtext.util.PolymorphicDispatcher; //導入依賴的package包/類
protected void invokeMethod(String methodName, ICompletionProposalAcceptor acceptor, Object... params) {
PolymorphicDispatcher<Void> dispatcher = dispatchers.get(methodName);
if (dispatcher == null) {
ErrorHandler<Void> errorHandler = WarningErrorHandler.get(log);
dispatcher = new PolymorphicDispatcher<Void>(methodName, params.length + 1, params.length + 1,
Collections.singletonList(this), errorHandler) {
@Override
public Class<?> getDefaultClass(int paramIndex) {
if (paramIndex == 0)
return EObject.class;
return super.getDefaultClass(paramIndex);
}
};
dispatchers.put(methodName, dispatcher);
}
Object[] paramAsArray = new Object[params.length + 1];
System.arraycopy(params, 0, paramAsArray, 0, params.length);
paramAsArray[params.length] = acceptor;
if (handledArguments.add(Lists.asList(methodName, paramAsArray))) {
dispatcher.invoke(paramAsArray);
}
}
示例3: getFollowElements
import org.eclipse.xtext.util.PolymorphicDispatcher; //導入依賴的package包/類
@Override
protected Collection<FollowElement> getFollowElements(AbstractInternalContentAssistParser parser) {
if (rule == null || rule.eIsProxy())
return Collections.emptyList();
String methodName = "entryRule" + rule.getName();
PolymorphicDispatcher<Collection<FollowElement>> dispatcher =
new PolymorphicDispatcher<Collection<FollowElement>>(methodName, 0, 0, Collections.singletonList(parser));
dispatcher.invoke();
return parser.getFollowElements();
}
示例4: getInjector
import org.eclipse.xtext.util.PolymorphicDispatcher; //導入依賴的package包/類
@Override
public Injector getInjector() {
if (injector == null) {
stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
try {
this.injector = internalCreateInjector();
} catch (Throwable e) {
// #############################################################################
// IDE-2514: Temporarily exists on exception due to PolymorphicDispatcher problem
boolean polymorphicDispatchProblem = false;
if (e.getMessage().contains("Comparison method violates its general contract!")) {
String pdName = PolymorphicDispatcher.class.getName();
for (StackTraceElement ste : e.getStackTrace()) {
String steName = ste.toString();
if (steName.contains(pdName)) {
polymorphicDispatchProblem = true;
}
}
}
if (polymorphicDispatchProblem) {
String msg = "Comparison method violates its general contract!\n\t";
msg += "at org.eclipse.n4js.N4JSInjectorProvider.getInjector(N4JSInjectorProvider.java:90)\\n\\t";
msg += "Reason might be the PolymorphicDispatcher";
msg += "Exit.";
System.err.println(msg);
System.exit(-1);
} else {
throw e;
}
// Fail fast End
// #############################################################################
}
stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState();
}
return injector;
}
示例5: polymorphicFindScopeForClassName
import org.eclipse.xtext.util.PolymorphicDispatcher; //導入依賴的package包/類
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;
}
示例6: execute
import org.eclipse.xtext.util.PolymorphicDispatcher; //導入依賴的package包/類
public Object execute(Operation definition, Object[] parameter) {
PolymorphicDispatcher<Object> dispatcher = new PolymorphicDispatcher<Object>(definition.getName(), definition
.getParameters().size(), definition.getParameters().size(), callbacks);
try {
return dispatcher.invoke(parameter);
} catch (Exception ex) {
throw new WrappedException("Error during invocation of operation '" + definition.getName()
+ "' with params " + definition.getParameters() + " '", ex);
}
}