use of org.eclipse.xtext.xbase.lib.Functions.Function0 in project xtext-core by eclipse.
the class AbstractLanguageServerTest method getServerModule.
protected com.google.inject.Module getServerModule() {
ServerModule _serverModule = new ServerModule();
final com.google.inject.Module _function = (Binder it) -> {
AnnotatedBindingBuilder<RequestManager> _bind = it.<RequestManager>bind(RequestManager.class);
_bind.toInstance(new RequestManager() {
@Override
public <V extends Object> CompletableFuture<V> runRead(final Function1<? super CancelIndicator, ? extends V> request) {
final CompletableFuture<V> result = new CompletableFuture<V>();
try {
final CancelIndicator _function = () -> {
return false;
};
result.complete(request.apply(_function));
} catch (final Throwable _t) {
if (_t instanceof Throwable) {
final Throwable e = (Throwable) _t;
result.completeExceptionally(e);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
return result;
}
@Override
public <U extends Object, V extends Object> CompletableFuture<V> runWrite(final Function0<? extends U> nonCancellable, final Function2<? super CancelIndicator, ? super U, ? extends V> request) {
final CompletableFuture<V> result = new CompletableFuture<V>();
try {
final CancelIndicator _function = () -> {
return false;
};
result.complete(request.apply(_function, nonCancellable.apply()));
} catch (final Throwable _t) {
if (_t instanceof Throwable) {
final Throwable e = (Throwable) _t;
result.completeExceptionally(e);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
return result;
}
});
};
return Modules2.mixin(_serverModule, _function);
}
use of org.eclipse.xtext.xbase.lib.Functions.Function0 in project xtext-eclipse by eclipse.
the class ReplaceFileContentChange method getOldContents.
protected byte[] getOldContents() {
byte[] _xblockexpression = null;
{
final ByteArrayOutputStream oldContentsBAOS = new ByteArrayOutputStream();
final Function0<byte[]> _function = () -> {
try {
byte[] _xblockexpression_1 = null;
{
final InputStream oldContentsIS = this.file.getContents();
final Function0<byte[]> _function_1 = () -> {
try {
int readBytes = 0;
final byte[] buffer = new byte[4096];
while (((readBytes = oldContentsIS.read(buffer)) != (-1))) {
oldContentsBAOS.write(buffer, 0, readBytes);
}
return oldContentsBAOS.toByteArray();
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
_xblockexpression_1 = TryWithResource.<byte[]>tryWith(oldContentsIS, _function_1);
}
return _xblockexpression_1;
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
_xblockexpression = TryWithResource.<byte[]>tryWith(oldContentsBAOS, _function);
}
return _xblockexpression;
}
Aggregations