org.eclipse.lsp4j.jsonrpc.messages.Either.isLeft()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中org.eclipse.lsp4j.jsonrpc.messages.Either.isLeft()方法的一些代码示例,展示了Either.isLeft()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Either.isLeft()方法的具体详情如下:
包路径:org.eclipse.lsp4j.jsonrpc.messages.Either
类名称:Either
方法名:isLeft

Either.isLeft介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.lsp4j/org.eclipse.lsp4j

protected void writeContents(final JsonWriter out, final Either<List<Either<String, MarkedString>>, MarkupContent> contents) throws IOException {
 boolean _isLeft = contents.isLeft();
 if (_isLeft) {
  final List<Either<String, MarkedString>> list = contents.getLeft();
  int _size = list.size();
  boolean _equals = (_size == 1);
  if (_equals) {
   this.gson.toJson(list.get(0), HoverTypeAdapter.STRING_MARKEDSTRING.getType(), out);
  } else {
   this.gson.toJson(list, HoverTypeAdapter.LIST_STRING_MARKEDSTRING.getType(), out);
  }
 } else {
  this.gson.toJson(contents.getRight(), MarkupContent.class, out);
 }
}

代码示例来源:origin: eclipse/lsp4j

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());
  }
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-languageserver

@Override
 public boolean handleResult(
   ExtendedLanguageServer element, List<Either<Command, CodeAction>> res) {
  for (Either<Command, CodeAction> cmd : res) {
   if (cmd.isLeft()) {
    result.add(new CommandDto(cmd.getLeft()));
   } else {
    // see https://github.com/eclipse/che/issues/11140
    LOG.warn("Ignoring code action: {}", cmd.getRight());
   }
  }
  return false;
 }
};

代码示例来源:origin: org.eclipse.lsp4j/org.eclipse.lsp4j.jsonrpc

public boolean isSecond() {
  return isRight() && getRight().isLeft();
}

代码示例来源:origin: eclipse/lsp4j

public boolean isSecond() {
  return isRight() && getRight().isLeft();
}

代码示例来源:origin: org.eclipse.lsp4j/org.eclipse.lsp4j.jsonrpc

public String getId() {
  if (id == null)
    return null;
  if (id.isLeft())
    return id.getLeft();
  if (id.isRight())
    return id.getRight().toString();
  return null;
}

代码示例来源:origin: eclipse/lsp4j

public String getResponseId() {
  if (responseId == null)
    return null;
  if (responseId.isLeft())
    return responseId.getLeft();
  if (responseId.isRight())
    return responseId.getRight().toString();
  return null;
}

代码示例来源:origin: eclipse/lsp4j

public String getId() {
  if (id == null)
    return null;
  if (id.isLeft())
    return id.getLeft();
  if (id.isRight())
    return id.getRight().toString();
  return null;
}

代码示例来源:origin: spring-projects/sts4

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;
}

代码示例来源:origin: eclipse/lsp4j

public String getId() {
  if (id == null)
    return null;
  if (id.isLeft())
    return id.getLeft();
  if (id.isRight())
    return id.getRight().toString();
  return null;
}

代码示例来源:origin: org.eclipse.lsp4j/org.eclipse.lsp4j.jsonrpc

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());
}

代码示例来源:origin: eclipse/lsp4j

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());
}

代码示例来源:origin: org.eclipse.lsp4j/org.eclipse.lsp4j.jsonrpc

@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());
  }
}

代码示例来源:origin: eclipse/lsp4j

@NonNull
public String getId() {
  if (id == null)
    return null;
  if (id.isLeft())
    return id.getLeft();
  if (id.isRight())
    return id.getRight().toString();
  return null;
}

代码示例来源:origin: org.eclipse.lsp4j/org.eclipse.lsp4j.jsonrpc

@NonNull
public String getId() {
  if (id == null)
    return null;
  if (id.isLeft())
    return id.getLeft();
  if (id.isRight())
    return id.getRight().toString();
  return null;
}

代码示例来源:origin: eclipse/lsp4j

@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());
  }
}

代码示例来源:origin: org.eclipse.che.core/che-core-api-languageserver

private <T> boolean isImplemented(Either<Boolean, T> capability) {
  if (capability.isLeft()) {
   return truish(capability.getLeft());
  } else {
   return capability.getRight() != null;
  }
 }
}

代码示例来源:origin: spring-projects/sts4

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;
}

代码示例来源:origin: org.eclipse.che.plugin/che-plugin-java-ext-lang-client

@Override
public void onSelectionChanged(PreviewNode selectedNode) {
 Either<ResourceChange, TextEdit> data = selectedNode.getData();
 if (data != null && data.isLeft()) {
  view.showDiff(null);
  return;
 }
 List<TextEdit> edits = collectTextEditsForSelectedNode(selectedNode);
 updateContentInCompareWidget(selectedNode, edits);
}

代码示例来源:origin: spring-projects/sts4

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();
  }
}

相关文章