public T3 getThird() { Either<T2, T3> right = getRight(); if (right == null) return null; else return right.getRight(); }
public T3 getThird() { Either<T2, T3> right = getRight(); if (right == null) return null; else return right.getRight(); }
private void writeIntId(JsonWriter out, Either<String, Number> id) throws IOException { if (id == null) writeNullValue(out); else if (id.isLeft()) out.value(Integer.parseInt(id.getLeft())); else if (id.isRight()) out.value(id.getRight()); } }
public String getId() { if (id == null) return null; if (id.isLeft()) return id.getLeft(); if (id.isRight()) return id.getRight().toString(); return null; }
public String getResponseId() { if (responseId == null) return null; if (responseId.isLeft()) return responseId.getLeft(); if (responseId.isRight()) return responseId.getRight().toString(); return null; }
public String getId() { if (id == null) return null; if (id.isLeft()) return id.getLeft(); if (id.isRight()) return id.getRight().toString(); return null; }
public String getId() { if (id == null) return null; if (id.isLeft()) return id.getLeft(); if (id.isRight()) return id.getRight().toString(); return null; }
protected void writeId(JsonWriter out, Either<String, Number> id) throws IOException { if (id == null) writeNullValue(out); else if (id.isLeft()) out.value(id.getLeft()); else if (id.isRight()) out.value(id.getRight()); }
protected void writeId(JsonWriter out, Either<String, Number> id) throws IOException { if (id == null) writeNullValue(out); else if (id.isLeft()) out.value(id.getLeft()); else if (id.isRight()) out.value(id.getRight()); }
private static Boolean getCodeActionProvider(ServerCapabilities cap) { Either<Boolean, CodeActionOptions> codeActionProvider = cap.getCodeActionProvider(); if (codeActionProvider == null) { return false; } if (codeActionProvider.isRight()) { return codeActionProvider.getRight() != null; } else { return codeActionProvider.getLeft(); } }
@NonNull public String getId() { if (id == null) return null; if (id.isLeft()) return id.getLeft(); if (id.isRight()) return id.getRight().toString(); return null; }
private static Boolean getRenameProvider(ServerCapabilities cap) { Either<Boolean, RenameOptions> provider = cap.getRenameProvider(); if (provider == null) { return false; } if (provider.isRight()) { return provider.getRight() != null; } else { return provider.getLeft(); } } }
@NonNull public String getId() { if (id == null) return null; if (id.isLeft()) return id.getLeft(); if (id.isRight()) return id.getRight().toString(); return null; }
@Override public void write(JsonWriter out, Either<L, R> value) throws IOException { if (value == null) { out.nullValue(); } else if (value.isLeft()) { left.write(out, value.getLeft()); } else { right.write(out, value.getRight()); } }
private <T> boolean isImplemented(Either<Boolean, T> capability) { if (capability.isLeft()) { return truish(capability.getLeft()); } else { return capability.getRight() != null; } } }
@Override public void write(JsonWriter out, Either<L, R> value) throws IOException { if (value == null) { out.nullValue(); } else if (value.isLeft()) { left.write(out, value.getLeft()); } else { right.write(out, value.getRight()); } }
public static String getDocString(CompletionItem completion) { if (completion!=null) { Either<String, MarkupContent> doc = completion.getDocumentation(); if (doc.isLeft()) { return doc.getLeft(); } else { return doc.getRight().getValue(); } } return null; }
@Test public void testCompletion_noSymbols() throws InterruptedException, ExecutionException { String uri = workspace.getRoot().toPath().resolve("somethingthatdoesntexist.groovy").toString(); TextDocumentPositionParams params = new TextDocumentPositionParams(new TextDocumentIdentifier(uri), uri, new Position(5, 5)); CompletableFuture<Either<List<CompletionItem>, CompletionList>> response = service.completion(params); assertThat(response.get().getRight().isIncomplete(), is(false)); assertThat(response.get().getRight().getItems(), is(Lists.newArrayList())); }
@Test public void testCompletion() throws InterruptedException, ExecutionException { String uri = filePath.toAbsolutePath().toString(); TextDocumentPositionParams params = new TextDocumentPositionParams(new TextDocumentIdentifier(uri), uri, new Position(5, 5)); CompletableFuture<Either<List<CompletionItem>, CompletionList>> response = service.completion(params); assertThat(response.get().getRight().isIncomplete(), is(expectedCompletionList.isIncomplete())); assertThat(Sets.newHashSet(response.get().getRight().getItems()), is(Sets.newHashSet(expectedCompletionList.getItems()))); }
public CompletionList getCompletions(TextDocumentInfo doc, Position cursor) throws Exception { CompletionParams params = new CompletionParams(); params.setPosition(cursor); params.setTextDocument(doc.getId()); waitForReconcile(); Either<List<CompletionItem>, CompletionList> completions = getServer().getTextDocumentService().completion(params).get(); if (completions.isLeft()) { List<CompletionItem> list = completions.getLeft(); return new CompletionList(false, list); } else /* sompletions.isRight() */ { return completions.getRight(); } }