当前位置: 首页>>代码示例>>Java>>正文


Java NotificationMessage类代码示例

本文整理汇总了Java中org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage的典型用法代码示例。如果您正苦于以下问题:Java NotificationMessage类的具体用法?Java NotificationMessage怎么用?Java NotificationMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NotificationMessage类属于org.eclipse.lsp4j.jsonrpc.messages包,在下文中一共展示了NotificationMessage类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleCancellation

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
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 disabled, since the '" + MessageJsonHandler.CANCEL_METHOD.getMethodName() + "' method has been registered explicitly.");
				return false;
			}
		} else {
			LOG.warning("Missing 'params' attribute of cancel notification.");
		}
	}
	return false;
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:25,代码来源:RemoteEndpoint.java

示例2: testNotification_AllOrders

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
@Test
public void testNotification_AllOrders() {
	Map<String, JsonRpcMethod> supportedMethods = new LinkedHashMap<>();
	supportedMethods.put("foo", JsonRpcMethod.request("foo",
			new TypeToken<Void>() {}.getType(),
			new TypeToken<Location>() {
			}.getType()));
	DebugMessageJsonHandler handler = new DebugMessageJsonHandler(supportedMethods);
	handler.setMethodProvider((id) -> "foo");
	String[] properties = new String[] {
			"\"seq\":2",
			"\"type\":\"event\"",
			"\"event\":\"foo\"",
			"\"body\": {\"uri\": \"dummy://mymodel.mydsl\"}"
			};
	testAllPermutations(properties, json -> {
		NotificationMessage message = (NotificationMessage) handler.parseMessage(json);
		Object params = message.getParams();
		Class<? extends Object> class1 = params.getClass();
		Assert.assertEquals(Location.class, class1);
		Assert.assertEquals("dummy://mymodel.mydsl", ((Location)params).uri);
	});
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:24,代码来源:DebugMessageJsonHandlerTest.java

示例3: testNotification_AllOrders

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
@Test
public void testNotification_AllOrders() {
	Map<String, JsonRpcMethod> supportedMethods = new LinkedHashMap<>();
	supportedMethods.put("foo", JsonRpcMethod.request("foo",
			new TypeToken<Void>() {}.getType(),
			new TypeToken<Location>() {
			}.getType()));
	MessageJsonHandler handler = new MessageJsonHandler(supportedMethods);
	handler.setMethodProvider((id) -> "foo");
	String[] properties = new String[] {
			"\"jsonrpc\":\"2.0\"",
			"\"method\":\"foo\"",
			"\"params\": {\"uri\": \"dummy://mymodel.mydsl\"}"
			};
	testAllPermutations(properties, json -> {
		NotificationMessage message = (NotificationMessage) handler.parseMessage(json);
		Object params = message.getParams();
		Class<? extends Object> class1 = params.getClass();
		Assert.assertEquals(Location.class, class1);
		Assert.assertEquals("dummy://mymodel.mydsl", ((Location)params).uri);
	});
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:23,代码来源:MessageJsonHandlerTest.java

示例4: testNotification

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
@Test public void testNotification() {
	TestEndpoint endp = new TestEndpoint();
	TestMessageConsumer consumer = new TestMessageConsumer();
	RemoteEndpoint endpoint = new RemoteEndpoint(consumer, endp);
	
	endpoint.consume(new NotificationMessage() {{
		setMethod("foo");
		setParams("myparam");
	}});
	
	NotificationMessage notificationMessage = endp.notifications.get(0);
	assertEquals("foo", notificationMessage.getMethod());
	assertEquals("myparam", notificationMessage.getParams());
	assertTrue(consumer.messages.isEmpty());
}
 
开发者ID:tracymiranda,项目名称:dsp4e,代码行数:16,代码来源:DebugRemoteEndpointTest.java

示例5: notify

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
@Override
public void notify(String method, Object parameter) {
	NotificationMessage notificationMessage = new NotificationMessage();
	notificationMessage.setJsonrpc(MessageConstants.JSONRPC_VERSION);
	notificationMessage.setMethod(method);
	notificationMessage.setParams(parameter);
	out.consume(notificationMessage);
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:9,代码来源:RemoteEndpoint.java

示例6: consume

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
@Override
public void consume(Message message) {
	if (message instanceof NotificationMessage) {
		NotificationMessage notificationMessage = (NotificationMessage) message;
		handleNotification(notificationMessage);
	} else if (message instanceof RequestMessage) {
		RequestMessage requestMessage = (RequestMessage) message;
		handleRequest(requestMessage);
	} else if (message instanceof ResponseMessage) {
		ResponseMessage responseMessage = (ResponseMessage) message;
		handleResponse(responseMessage);
	}
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:14,代码来源:RemoteEndpoint.java

示例7: handleNotification

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
protected void handleNotification(NotificationMessage notificationMessage) {
	if (!handleCancellation(notificationMessage)) {
		try {
			localEndpoint.notify(notificationMessage.getMethod(), notificationMessage.getParams());
		} catch (RuntimeException e) {
			LOG.log(Level.WARNING, "Notification threw an exception: " + notificationMessage, e);
		}
	}
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:10,代码来源:RemoteEndpoint.java

示例8: testTelemetry

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
@Test
public void testTelemetry() {
  NotificationMessage _notificationMessage = new NotificationMessage();
  final Procedure1<NotificationMessage> _function = (NotificationMessage it) -> {
    it.setJsonrpc("2.0");
    it.setMethod(MessageMethods.TELEMETRY_EVENT);
    JsonSerializeTest.TestObject _testObject = new JsonSerializeTest.TestObject();
    it.setParams(_testObject);
  };
  final NotificationMessage message = ObjectExtensions.<NotificationMessage>operator_doubleArrow(_notificationMessage, _function);
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("{");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("\"jsonrpc\": \"2.0\",");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("\"method\": \"telemetry/event\",");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("\"params\": {");
  _builder.newLine();
  _builder.append("    ");
  _builder.append("\"foo\": 12.3,");
  _builder.newLine();
  _builder.append("    ");
  _builder.append("\"bar\": \"qwertz\"");
  _builder.newLine();
  _builder.append("  ");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  this.assertSerialize(message, _builder);
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:36,代码来源:JsonSerializeTest.java

示例9: testTelemetry

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
@Test
public void testTelemetry() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("{");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("\"jsonrpc\": \"2.0\",");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("\"method\": \"telemetry/event\",");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("\"params\": {");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("\"foo\": 12.3,");
  _builder.newLine();
  _builder.append("\t\t");
  _builder.append("\"bar\": \"qwertz\"");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("}");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  NotificationMessage _notificationMessage = new NotificationMessage();
  final Procedure1<NotificationMessage> _function = (NotificationMessage it) -> {
    it.setJsonrpc("2.0");
    it.setMethod(MessageMethods.TELEMETRY_EVENT);
    Pair<String, Double> _mappedTo = Pair.<String, Double>of("foo", Double.valueOf(12.3));
    Pair<String, String> _mappedTo_1 = Pair.<String, String>of("bar", "qwertz");
    it.setParams(CollectionLiterals.<String, Object>newLinkedHashMap(_mappedTo, _mappedTo_1));
  };
  NotificationMessage _doubleArrow = ObjectExtensions.<NotificationMessage>operator_doubleArrow(_notificationMessage, _function);
  this.assertParse(_builder, _doubleArrow);
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:37,代码来源:JsonParseTest.java

示例10: testNotification

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
@Test public void testNotification() {
	TestEndpoint endp = new TestEndpoint();
	TestMessageConsumer consumer = new TestMessageConsumer();
	RemoteEndpoint endpoint = new DebugRemoteEndpoint(consumer, endp);

	endpoint.consume(new NotificationMessage() {{
		setMethod("foo");
		setParams("myparam");
	}});

	NotificationMessage notificationMessage = endp.notifications.get(0);
	assertEquals("foo", notificationMessage.getMethod());
	assertEquals("myparam", notificationMessage.getParams());
	assertTrue(consumer.messages.isEmpty());
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:16,代码来源:DebugRemoteEndpointTest.java

示例11: createNotificationMessage

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
protected NotificationMessage createNotificationMessage(String method, Object parameter) {
	NotificationMessage notificationMessage = new NotificationMessage();
	notificationMessage.setJsonrpc(MessageConstants.JSONRPC_VERSION);
	notificationMessage.setMethod(method);
	notificationMessage.setParams(parameter);
	return notificationMessage;
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:8,代码来源:RemoteEndpoint.java

示例12: notify

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
public void notify(String method, Object parameter) {
	notifications.add(new NotificationMessage() {{
		setMethod(method);
		setParams(parameter);
	}});
}
 
开发者ID:tracymiranda,项目名称:dsp4e,代码行数:7,代码来源:DebugRemoteEndpointTest.java

示例13: notify

import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage; //导入依赖的package包/类
@Override
public void notify(String method, Object parameter) {
	NotificationMessage notificationMessage = createNotificationMessage(method, parameter);
	out.consume(notificationMessage);
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:6,代码来源:RemoteEndpoint.java


注:本文中的org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。