• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Either类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testChangeEventUpdatesStoredText

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@Test
public void testChangeEventUpdatesStoredText() throws Exception {
	CamelLanguageServer camelLanguageServer = initializeLanguageServer("<to uri=\"\" xmlns=\"http://camel.apache.org/schema/blueprint\"></to>\n");
	
	DidChangeTextDocumentParams changeEvent = new DidChangeTextDocumentParams();
	VersionedTextDocumentIdentifier textDocument = new VersionedTextDocumentIdentifier();
	textDocument.setUri(DUMMY_URI);
	changeEvent.setTextDocument(textDocument);
	TextDocumentContentChangeEvent contentChange = new TextDocumentContentChangeEvent("<to xmlns=\"http://camel.apache.org/schema/blueprint\" uri=\"\"></to>\n");
	changeEvent.setContentChanges(Collections.singletonList(contentChange));
	camelLanguageServer.getTextDocumentService().didChange(changeEvent);
	
	//check old position doesn't provide completion
	CompletableFuture<Either<List<CompletionItem>, CompletionList>> completionsAtOldPosition = getCompletionFor(camelLanguageServer, new Position(0, 11));
	assertThat(completionsAtOldPosition.get().getLeft()).isEmpty();
	
	//check new position provides completion
	CompletableFuture<Either<List<CompletionItem>, CompletionList>> completionsAtNewPosition = getCompletionFor(camelLanguageServer, new Position(0, 58));
	assertThat(completionsAtNewPosition.get().getLeft()).isNotEmpty();
	
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:22,代码来源:CamelTextDocumentServiceTest.java


示例2: DSPDebugTarget

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
public DSPDebugTarget(ILaunch launch, Process process, InputStream in, OutputStream out,
		Map<String, Object> launchArguments) throws CoreException {
	super(null);
	this.launch = launch;
	this.process = process;

	DebugLauncher<IDebugProtocolServer> debugProtocolLauncher = DebugLauncher.createLauncher(this,
			IDebugProtocolServer.class, in, out, true, new PrintWriter(System.out));

	debugProtocolFuture = debugProtocolLauncher.startListening();
	debugProtocolServer = debugProtocolLauncher.getRemoteProxy();

	complete(debugProtocolServer.initialize(new InitializeRequestArguments().setClientID("lsp4e")
			.setAdapterID((String) launchArguments.get("type")).setPathFormat("path")));

	Object object = launchArguments.get("program");
	targetName = Objects.toString(object, "Debug Adapter Target");

	complete(debugProtocolServer.launch(Either.forLeft(launchArguments)));
	complete(debugProtocolServer.configurationDone());
	IBreakpointManager breakpointManager = getBreakpointManager();
	breakpointManager.addBreakpointListener(this);
	breakpointManager.addBreakpointManagerListener(this);
	breakpointManagerEnablementChanged(breakpointManager.isEnabled());
}
 
开发者ID:tracymiranda,项目名称:dsp4e,代码行数:26,代码来源:DSPDebugTarget.java


示例3: testEither_02

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
@Test
public void testEither_02() {
	Map<String, JsonRpcMethod> supportedMethods = new LinkedHashMap<>();
	supportedMethods.put("foo", JsonRpcMethod.request("foo",
			new TypeToken<Either<MyEnum, Map<String,String>>>() {}.getType(),
			new TypeToken<Object>() {}.getType()));
	DebugMessageJsonHandler handler = new DebugMessageJsonHandler(supportedMethods);
	handler.setMethodProvider((id) -> "foo");
	Message message = handler.parseMessage("{"
			+ "\"seq\":2,\n"
			+ "\"type\":\"response\",\n"
			+ "\"body\": 2\n"
			+ "}");
	Either<MyEnum, List<Map<String, String>>> result = (Either<MyEnum, List<Map<String,String>>>) ((ResponseMessage)message).getResult();
	Assert.assertTrue(result.isLeft());
	Assert.assertEquals(MyEnum.B, result.getLeft());
}
 
开发者ID:tracymiranda,项目名称:dsp4e,代码行数:19,代码来源:DebugMessageJsonHandlerTest.java


示例4: create

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected Either<L, R> create(JsonToken nextToken, JsonReader in) throws IOException {
	if (left.isAssignable(nextToken)) {
		if (Either3.class.isAssignableFrom(typeToken.getRawType()))
			return (Either<L, R>) Either3.forLeft3(left.read(in));
		else
			return Either.forLeft(left.read(in));
	}
	if (right.isAssignable(nextToken)) {
		if (Either3.class.isAssignableFrom(typeToken.getRawType()))
			return (Either<L, R>) Either3.forRight3((Either<?, ?>) right.read(in));
		else
			return Either.forRight(right.read(in));
	}
	return null;
}
 
开发者ID:smarr,项目名称:SOMns-vscode,代码行数:17,代码来源:EitherTypeAdapter.java


示例5: completion

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
Either<List<CompletionItem>, CompletionList> completion(TextDocumentPositionParams position,
		IProgressMonitor monitor) {
	List<CompletionItem> completionItems = null;
	try {
		ICompilationUnit unit = JDTUtils.resolveCompilationUnit(position.getTextDocument().getUri());
		completionItems = this.computeContentAssist(unit,
				position.getPosition().getLine(),
				position.getPosition().getCharacter(), monitor);
	} catch (OperationCanceledException ignorable) {
		// No need to pollute logs when query is cancelled
		monitor.setCanceled(true);
	} catch (Exception e) {
		JavaLanguageServerPlugin.logException("Problem with codeComplete for " +  position.getTextDocument().getUri(), e);
		monitor.setCanceled(true);
	}
	CompletionList $ = new CompletionList();
	if (monitor.isCanceled()) {
		$.setIsIncomplete(true);
		completionItems = null;
		JavaLanguageServerPlugin.logInfo("Completion request cancelled");
	} else {
		JavaLanguageServerPlugin.logInfo("Completion request completed");
	}
	$.setItems(completionItems == null ? Collections.emptyList() : completionItems);
	return Either.forRight($);
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:27,代码来源:CompletionHandler.java


示例6: completion

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@Override
public CompletableFuture<Either<List<CompletionItem>, CompletionList>> completion(TextDocumentPositionParams position) {
	logInfo(">> document/completion");
	CompletionHandler handler = new CompletionHandler();
	final IProgressMonitor[] monitors = new IProgressMonitor[1];
	CompletableFuture<Either<List<CompletionItem>, CompletionList>> result = computeAsync((cc) -> {
		monitors[0] = toMonitor(cc);
		if (Boolean.getBoolean(JAVA_LSP_JOIN_ON_COMPLETION)) {
			try {
				Job.getJobManager().join(DocumentLifeCycleHandler.DOCUMENT_LIFE_CYCLE_JOBS, monitors[0]);
			} catch (OperationCanceledException ignorable) {
				// No need to pollute logs when query is cancelled
			} catch (InterruptedException e) {
				JavaLanguageServerPlugin.logException(e.getMessage(), e);
			}
		}
		return handler.completion(position, monitors[0]);
	});
	result.join();
	if (monitors[0].isCanceled()) {
		result.cancel(true);
	}
	return result;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:25,代码来源:JDTLanguageServer.java


示例7: _toExpectation

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
protected String _toExpectation(final Either<?, ?> either) {
  StringConcatenation _builder = new StringConcatenation();
  {
    boolean _isLeft = either.isLeft();
    if (_isLeft) {
      String _expectation = this.toExpectation(either.getLeft());
      _builder.append(_expectation);
      _builder.newLineIfNotEmpty();
    } else {
      String _expectation_1 = this.toExpectation(either.getRight());
      _builder.append(_expectation_1);
      _builder.newLineIfNotEmpty();
    }
  }
  return _builder.toString();
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:17,代码来源:AbstractLanguageServerTest.java


示例8: completion

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
protected Either<List<CompletionItem>, CompletionList> completion(final CancelIndicator origialCancelIndicator, final TextDocumentPositionParams params) {
  final LanguageServerImpl.BufferedCancelIndicator cancelIndicator = new LanguageServerImpl.BufferedCancelIndicator(origialCancelIndicator);
  final URI uri = this._uriExtensions.toUri(params.getTextDocument().getUri());
  final IResourceServiceProvider resourceServiceProvider = this.languagesRegistry.getResourceServiceProvider(uri);
  ContentAssistService _get = null;
  if (resourceServiceProvider!=null) {
    _get=resourceServiceProvider.<ContentAssistService>get(ContentAssistService.class);
  }
  final ContentAssistService contentAssistService = _get;
  if ((contentAssistService == null)) {
    CompletionList _completionList = new CompletionList();
    return Either.<List<CompletionItem>, CompletionList>forRight(_completionList);
  }
  final Function2<Document, XtextResource, CompletionList> _function = (Document document, XtextResource resource) -> {
    return contentAssistService.createCompletionList(document, resource, params, cancelIndicator);
  };
  final CompletionList completionList = this.workspaceManager.<CompletionList>doRead(uri, _function);
  return Either.<List<CompletionItem>, CompletionList>forRight(completionList);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:LanguageServerImpl.java


示例9: testRequest

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@Test public void testRequest() throws Exception {
	
	TextDocumentPositionParams p = new TextDocumentPositionParams();
	p.setPosition(new Position(1,1));
	p.setTextDocument(new TextDocumentIdentifier("test/foo.txt"));
	
	CompletionList result = new CompletionList();
	result.setIsIncomplete(true);
	result.setItems(new ArrayList<>());
	
	CompletionItem item = new CompletionItem();
	item.setDetail("test");
	item.setDocumentation("doc");
	item.setFilterText("filter");
	item.setInsertText("insert");
	item.setKind(CompletionItemKind.Field);
	result.getItems().add(item);
	
	server.expectedRequests.put("textDocument/completion", new Pair<>(p, result));
	CompletableFuture<Either<List<CompletionItem>, CompletionList>> future = clientLauncher.getRemoteProxy().getTextDocumentService().completion(p);
	Assert.assertEquals(Either.forRight(result).toString(), future.get(TIMEOUT, TimeUnit.MILLISECONDS).toString());
	client.joinOnEmpty();
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:24,代码来源:LauncherTest.java


示例10: testEither_02

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
@Test
public void testEither_02() {
	Map<String, JsonRpcMethod> supportedMethods = new LinkedHashMap<>();
	supportedMethods.put("foo", JsonRpcMethod.request("foo",
			new TypeToken<Either<Integer, Map<String,String>>>() {}.getType(),
			new TypeToken<Object>() {}.getType()));
	DebugMessageJsonHandler handler = new DebugMessageJsonHandler(supportedMethods);
	handler.setMethodProvider((id) -> "foo");
	Message message = handler.parseMessage("{"
			+ "\"seq\":2,\n"
			+ "\"type\":\"response\",\n"
			+ "\"body\": 2\n"
			+ "}");
	Either<Integer, List<Map<String, String>>> result = (Either<Integer, List<Map<String,String>>>) ((ResponseMessage)message).getResult();
	Assert.assertTrue(result.isLeft());
	Assert.assertEquals(Integer.valueOf(2), result.getLeft());
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:19,代码来源:DebugMessageJsonHandlerTest.java


示例11: testEither_02

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
@Test
public void testEither_02() {
	Map<String, JsonRpcMethod> supportedMethods = new LinkedHashMap<>();
	supportedMethods.put("foo", JsonRpcMethod.request("foo",
			new TypeToken<Either<MyEnum, Map<String,String>>>() {}.getType(),
			new TypeToken<Object>() {}.getType()));
	MessageJsonHandler handler = new MessageJsonHandler(supportedMethods);
	handler.setMethodProvider((id) -> "foo");
	Message message = handler.parseMessage("{\"jsonrpc\":\"2.0\","
			+ "\"id\":\"2\",\n"
			+ "\"result\": 2\n"
			+ "}");
	Either<MyEnum, List<Map<String, String>>> result = (Either<MyEnum, List<Map<String,String>>>) ((ResponseMessage)message).getResult();
	Assert.assertTrue(result.isLeft());
	Assert.assertEquals(MyEnum.B, result.getLeft());
}
 
开发者ID:eclipse,项目名称:lsp4j,代码行数:18,代码来源:MessageJsonHandlerTest.java


示例12: generateToJson

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
private void generateToJson(
    String indent, PrintWriter out, String varName, String valueAccess, Type paramType) {
  if (List.class.isAssignableFrom(getRawClass(paramType))) {
    new ListConverter(varName, valueAccess, paramType).generateListConversion(indent, out);
  } else if (Map.class.isAssignableFrom(getRawClass(paramType))) {
    generateMapConversion(indent, out, varName, valueAccess, paramType);
  } else if (Either.class.isAssignableFrom(getRawClass(paramType))) {
    generateEitherConversion(indent, out, varName, valueAccess, paramType);
  } else {
    out.println(
        String.format(
            indent + "%1$s %2$s = %3$s;",
            json.element(),
            varName,
            jsonValueExpression(getRawClass(paramType), valueAccess)));
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:ToJsonGenerator.java


示例13: generateFromJson

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
private void generateFromJson(
    String indent, PrintWriter out, String varName, String valueAccess, Type paramType) {
  if (List.class.isAssignableFrom(getRawClass(paramType))) {
    generateListConversion(indent, out, varName, valueAccess, paramType);
  } else if (Map.class.isAssignableFrom(getRawClass(paramType))) {
    generateMapConversion(indent, out, varName, valueAccess, paramType);
  } else if (Either.class.isAssignableFrom(getRawClass(paramType))) {
    generateEitherConversion(indent, out, varName, valueAccess, paramType);
  } else {
    out.println(
        indent
            + String.format(
                "%1$s %2$s = %3$s;",
                getRawClass(paramType).getName(),
                varName,
                fromJsonConversion(getRawClass(paramType), valueAccess)));
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:FromJsonGenerator.java


示例14: generateToDto

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
private void generateToDto(
    String indent, PrintWriter out, String varName, String valueAccess, Type paramType) {
  Class<?> rawClass = getRawClass(paramType);
  if (List.class.isAssignableFrom(rawClass)) {
    generateListConversion(indent + INDENT, out, varName, valueAccess, paramType);
  } else if (Map.class.isAssignableFrom(rawClass)) {
    generateMapConversion(indent + INDENT, out, varName, valueAccess, paramType);
  } else if (Either.class.isAssignableFrom(rawClass)) {
    generateEitherConversion(indent + INDENT, out, varName, valueAccess, paramType);
  } else {
    out.println(
        String.format(
            indent + "%1$s %2$s = %3$s;",
            rawClass.getName(),
            varName,
            dtoValueExpression(rawClass, valueAccess)));
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:19,代码来源:ToDtoGenerator.java


示例15: LanguageServerReconcileStrategy

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@Inject
public LanguageServerReconcileStrategy(
    TextDocumentSynchronizeFactory synchronizeFactory,
    @Assisted ServerCapabilities serverCapabilities) {

  Either<TextDocumentSyncKind, TextDocumentSyncOptions> sync =
      serverCapabilities.getTextDocumentSync();
  TextDocumentSyncKind documentSync;
  if (sync.isLeft()) {
    documentSync = sync.getLeft();
  } else {
    documentSync = sync.getRight().getChange();
  }

  synchronize = synchronizeFactory.getSynchronize(documentSync);
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:LanguageServerReconcileStrategy.java


示例16: apply

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@Override
public Hover apply(CamelCatalog camelCatalog) {
	Hover hover = new Hover();
	ComponentModel componentModel = ModelHelper.generateComponentModel(camelCatalog.componentJSonSchema(componentName), true);
	hover.setContents(Collections.singletonList((Either.forLeft(componentModel.getDescription()))));
	return hover;
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:8,代码来源:HoverFuture.java


示例17: testProvideCompletionForCamelBlueprintNamespace

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@Test
public void testProvideCompletionForCamelBlueprintNamespace() throws Exception {
	CamelLanguageServer camelLanguageServer = initializeLanguageServer("<from uri=\"\" xmlns=\"http://camel.apache.org/schema/blueprint\"></from>\n");
	
	CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 11));
	
	assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem);
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:9,代码来源:CamelLanguageServerTest.java


示例18: testProvideCompletionForToCamelBlueprintNamespace

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@Test
public void testProvideCompletionForToCamelBlueprintNamespace() throws Exception {
	CamelLanguageServer camelLanguageServer = initializeLanguageServer("<to uri=\"\" xmlns=\"http://camel.apache.org/schema/blueprint\"></to>\n");
	
	CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 9));
	
	assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem);
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:9,代码来源:CamelLanguageServerTest.java


示例19: testProvideCompletionForCamelSpringNamespace

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@Test
public void testProvideCompletionForCamelSpringNamespace() throws Exception {
	CamelLanguageServer camelLanguageServer = initializeLanguageServer("<from uri=\"\" xmlns=\"http://camel.apache.org/schema/spring\"></from>\n");
	
	CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 11));
	
	assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem);
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:9,代码来源:CamelLanguageServerTest.java


示例20: testProvideCompletionforMultiline

import org.eclipse.lsp4j.jsonrpc.messages.Either; //导入依赖的package包/类
@Test
public void testProvideCompletionforMultiline() throws Exception {
	CamelLanguageServer camelLanguageServer = initializeLanguageServer(
			"<camelContext xmlns=\"http://camel.apache.org/schema/spring\">\n" + 
			"<to uri=\"\" ></to>\n" + 
			"</camelContext>");
	
	CompletableFuture<Either<List<CompletionItem>, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(1, 9));
	
	assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem);
}
 
开发者ID:lhein,项目名称:camel-language-server,代码行数:12,代码来源:CamelLanguageServerTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TNTPrimeSound类代码示例发布时间:2022-05-22
下一篇:
Java HandshakeState类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap