org.eclipse.lsp4j.jsonrpc.messages.Either#isRight ( )源码实例Demo

下面列出了org.eclipse.lsp4j.jsonrpc.messages.Either#isRight ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xtext-core   文件: RenameService2.java
private boolean shouldPrepareRename(ILanguageServerAccess access) {
	Either<Boolean, RenameOptions> provider = null;
	if (access != null) {
		InitializeResult initializeResult = access.getInitializeResult();
		if (initializeResult != null) {
			ServerCapabilities capabilities = initializeResult.getCapabilities();
			if (capabilities != null) {
				provider = capabilities.getRenameProvider();
			}
		}
	}
	if (provider != null && provider.isRight()) {
		return Boolean.TRUE.equals(provider.getRight().getPrepareProvider());
	} else {
		return false;
	}
}
 
源代码2 项目: lsp4intellij   文件: EditorEventManager.java
private String extractLabel(SignatureInformation signatureInformation, Either<String, Tuple.Two<Integer, Integer>> label) {
    if (label.isLeft()) {
        return label.getLeft();
    } else if (label.isRight()) {
        return signatureInformation.getLabel().substring(label.getRight().getFirst(), label.getRight().getSecond());
    } else {
        return "";
    }
}
 
public void documentSaved(long timestamp) {
    this.modificationStamp = timestamp;
    ServerCapabilities serverCapabilities = languageServerWrapper.getServerCapabilities();
    if(serverCapabilities != null ) {
        Either<TextDocumentSyncKind, TextDocumentSyncOptions> textDocumentSync = serverCapabilities.getTextDocumentSync();
        if(textDocumentSync.isRight() && textDocumentSync.getRight().getSave() == null) {
            return;
        }
    }
    TextDocumentIdentifier identifier = new TextDocumentIdentifier(fileUri.toString());
    DidSaveTextDocumentParams params = new DidSaveTextDocumentParams(identifier, document.getText());
    languageServerWrapper.getInitializedServer().thenAcceptAsync(ls -> ls.getTextDocumentService().didSave(params));
}
 
源代码4 项目: eclipse.jdt.ls   文件: AbstractQuickFixTest.java
/**
 * Checks if the action has the same title as this. If it has, then assert that
 * that action is equivalent to this in kind and content.
 */
public void assertEquivalent(Either<Command, CodeAction> action) throws Exception {
	String title = getTitle(action);
	assertEquals("Unexpected command :", name, title);
	if (!ALL_KINDS.equals(kind) && action.isRight()) {
		assertEquals(title + " has the wrong kind ", kind, action.getRight().getKind());
	}
	String actionContent = evaluateCodeActionCommand(action);
	assertEquals(title + " has the wrong content ", content, actionContent);
}
 
源代码5 项目: lsp4j   文件: DebugMessageTypeAdapter.java
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());
}
 
源代码6 项目: lsp4j   文件: MessageTypeAdapter.java
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());
}
 
源代码7 项目: lsp4intellij   文件: DefaultRequestManager.java
private boolean checkCodeActionProvider(Either<Boolean, CodeActionOptions> provider) {
    return provider != null && ((provider.isLeft() && provider.getLeft()) || (provider.isRight()
            && provider.getRight() != null));
}
 
源代码8 项目: MSPaintIDE   文件: DefaultRequestManager.java
private boolean checkProvider(Either<Boolean, StaticRegistrationOptions> provider) {
    return provider != null && ((provider.isLeft() && provider.getLeft()) || (provider.isRight()
            && provider.getRight() != null));
}
 
源代码9 项目: MSPaintIDE   文件: DefaultRequestManager.java
private boolean checkCodeActionProvider(Either<Boolean, CodeActionOptions> provider) {
    return provider != null && ((provider.isLeft() && provider.getLeft()) || (provider.isRight()
            && provider.getRight() != null));
}
 
源代码10 项目: lsp4j   文件: ReflectiveMessageValidator.java
/**
 * Validate all fields of the given object.
 */
protected void validate(Object object, List<MessageIssue> issues, Deque<Object> objectStack, Deque<Object> accessorStack) throws Exception {
	if (object == null 
			|| object instanceof Enum<?> 
			|| object instanceof String 
			|| object instanceof Number
			|| object instanceof Boolean
			|| object instanceof JsonElement
			|| object instanceof Throwable) {
		return;
	}
	if (objectStack.contains(object)) {
		issues.add(new MessageIssue("An element of the message has a direct or indirect reference to itself."
				+ " Path: " + createPathString(accessorStack),
				ResponseErrorCode.InvalidParams.getValue()));
		return;
	}
	objectStack.push(object);
	if (object instanceof List<?>) {
		ListIterator<?> iter = ((List<?>) object).listIterator();
		while (iter.hasNext()) {
			accessorStack.push(iter.nextIndex());
			Object element = iter.next();
			if (element == null) {
				issues.add(new MessageIssue("Lists must not contain null references."
						+ " Path: " + createPathString(accessorStack),
						ResponseErrorCode.InvalidParams.getValue()));
			}
			validate(element, issues, objectStack, accessorStack);
			accessorStack.pop();
		}
	} else if (object instanceof Either<?, ?>) {
		Either<?, ?> either = (Either<?, ?>) object;
		if (either.isLeft()) {
			validate(either.getLeft(), issues, objectStack, accessorStack);
		} else if (either.isRight()) {
			validate(either.getRight(), issues, objectStack, accessorStack);
		} else {
			issues.add(new MessageIssue("An Either instance must not be empty."
					 + " Path: " + createPathString(accessorStack),
					ResponseErrorCode.InvalidParams.getValue()));
		}
	} else {
		for (Method method : object.getClass().getMethods()) {
			if (isGetter(method)) {
				accessorStack.push(method);
				Object value = method.invoke(object);
				if (value == null && method.getAnnotation(NonNull.class) != null) {
					issues.add(new MessageIssue("The accessor '" + method.getDeclaringClass().getSimpleName()
							 + "." + method.getName() + "()' must return a non-null value."
							 + " Path: " + createPathString(accessorStack),
							ResponseErrorCode.InvalidParams.getValue()));
				}
				validate(value, issues, objectStack, accessorStack);
				accessorStack.pop();
			}
		}
	}
	objectStack.pop();
}