Java 类org.eclipse.xtext.util.PolymorphicDispatcher.ErrorHandler 实例源码

项目:bts    文件:AbstractJavaBasedContentProposalProvider.java   
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);
    }
}