public T2 getSecond() { Either<T2, T3> right = getRight(); if (right == null) return null; else return right.getLeft(); }
public T2 getSecond() { Either<T2, T3> right = getRight(); if (right == null) return null; else return right.getLeft(); }
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; }
private TextDocumentSyncKind getDocumentSyncMode() { if (initResult!=null) { Either<TextDocumentSyncKind, TextDocumentSyncOptions> mode = initResult.getCapabilities().getTextDocumentSync(); if (mode.isLeft()) { return mode.getLeft(); } else { throw new IllegalStateException("Harness doesn't support fancy Sync options yet!"); } } return TextDocumentSyncKind.None; }
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()); }
public List<CodeAction> getCodeActions(TextDocumentInfo doc, Diagnostic problem) throws Exception { CodeActionContext context = new CodeActionContext(ImmutableList.of(problem)); List<Either<Command, org.eclipse.lsp4j.CodeAction>> actions = getServer().getTextDocumentService().codeAction(new CodeActionParams(doc.getId(), problem.getRange(), context)).get(); return actions.stream() .map(e -> e.getLeft()) .map((command) -> new CodeAction(this, command)) .collect(Collectors.toList()); }
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; }
@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(); } } }
public void assertNoHover(String hoverOver, int occurence) throws Exception { int hoverPosition = getHoverPosition(hoverOver,occurence); Hover hover = harness.getHover(doc, doc.toPosition(hoverPosition)); List<Either<String, MarkedString>> contents = hover.getContents().getLeft(); assertTrue(contents.toString(), contents.isEmpty()); }
@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()); } }
@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; } } }
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; }
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(); } }