org.eclipse.lsp4j.jsonrpc.messages.CancelParams Java Examples

The following examples show how to use org.eclipse.lsp4j.jsonrpc.messages.CancelParams. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RemoteEndpoint.java    From lsp4j with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Cancellation is handled inside this class and not forwarded to the local endpoint.
 * 
 * @return {@code true} if the given message is a cancellation notification,
 *         {@code false} if it can be handled by the local endpoint
 */
protected boolean handleCancellation(NotificationMessage notificationMessage) {
	if (MessageJsonHandler.CANCEL_METHOD.getMethodName().equals(notificationMessage.getMethod())) {
		Object cancelParams = notificationMessage.getParams();
		if (cancelParams != null) {
			if (cancelParams instanceof CancelParams) {
				synchronized (receivedRequestMap) {
					String id = ((CancelParams) cancelParams).getId();
					CompletableFuture<?> future = receivedRequestMap.get(id);
					if (future != null)
						future.cancel(true);
					else
						LOG.warning("Unmatched cancel notification for request id " + id);
				}
				return true;
			} else {
				LOG.warning("Cancellation support is disabled, since the '" + MessageJsonHandler.CANCEL_METHOD.getMethodName() + "' method has been registered explicitly.");
			}
		} else {
			LOG.warning("Missing 'params' attribute of cancel notification.");
		}
	}
	return false;
}
 
Example #2
Source File: PatchedRemoteEndpoint.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected boolean handleCancellation(NotificationMessage notificationMessage) {
	if (MessageJsonHandler.CANCEL_METHOD.getMethodName().equals(notificationMessage.getMethod())) {
		Object cancelParams = notificationMessage.getParams();
		if (cancelParams != null) {
			if (cancelParams instanceof CancelParams) {
				String id = ((CancelParams) cancelParams).getId();
				LOG.debug("Client cancels: " + id);
				CompletableFuture<?> future;
				synchronized (receivedRequestMap) {
					future = receivedRequestMap.remove(id);
				}
				if (future != null)
					future.cancel(true);
				else
					LOG.debug("Unmatched cancel notification for request id " + id);
				return true;
			} else {
				LOG.warn("Cancellation support is disabled, since the '"
						+ MessageJsonHandler.CANCEL_METHOD.getMethodName()
						+ "' method has been registered explicitly.");
			}
		} else {
			LOG.warn("Missing 'params' attribute of cancel notification.");
		}
	}
	return false;
}
 
Example #3
Source File: RemoteEndpoint.java    From lsp4j with Eclipse Public License 2.0 4 votes vote down vote up
protected void sendCancelNotification(Either<String, Number> id) {
	CancelParams cancelParams = new CancelParams();
	cancelParams.setRawId(id);
	notify(MessageJsonHandler.CANCEL_METHOD.getMethodName(), cancelParams);
}
 
Example #4
Source File: DefaultRequestManager.java    From MSPaintIDE with MIT License 2 votes vote down vote up
@Override
public void cancelRequest(CancelParams params) {

}
 
Example #5
Source File: RequestManager.java    From MSPaintIDE with MIT License votes vote down vote up
void cancelRequest(CancelParams params);