public static boolean hasSymbolKeys(OtpErlangMap map) { for (OtpErlangObject key : map.keys()) { if (!(key instanceof OtpErlangAtom) || ((OtpErlangAtom) key).atomValue().startsWith("Elixir.")) return false; } return true; }
@Nullable private static String structType(OtpErlangMap map) { OtpErlangObject structValue = map.get(new OtpErlangAtom("__struct__")); if (structValue instanceof OtpErlangAtom) { return ElixirModulesUtil.INSTANCE.erlangModuleNameToElixir(((OtpErlangAtom) structValue).atomValue()); } else { return null; } }
private static void renderAtom(OtpErlangAtom atom, XValueTextRenderer renderer) { renderer.renderKeywordValue(ElixirModulesUtil.INSTANCE.erlangModuleNameToElixir(atom.atomValue())); }
name = keywordKeyAtom.atomValue(); } else { name = keywordKey.getText();
public static void assertError(PsiFile file) { final String text = file.getText(); try { OtpErlangTuple quotedMessage = Quoter.quote(text); Quoter.assertMessageReceived(quotedMessage); OtpErlangAtom status = (OtpErlangAtom) quotedMessage.elementAt(0); String statusString = status.atomValue(); assertEquals(statusString, "error"); } catch (IOException | OtpErlangDecodeException | OtpErlangExit e) { throw new RuntimeException(e); } }
public static void assertQuotedCorrectly(PsiFile file) { final String text = file.getText(); try { OtpErlangTuple quotedMessage = Quoter.quote(text); Quoter.assertMessageReceived(quotedMessage); OtpErlangAtom status = (OtpErlangAtom) quotedMessage.elementAt(0); String statusString = status.atomValue(); OtpErlangObject expectedQuoted = quotedMessage.elementAt(1); if (statusString.equals("ok")) { OtpErlangObject actualQuoted = ElixirPsiImplUtil.quote(file); assertQuotedCorrectly(expectedQuoted, actualQuoted); } else if (statusString.equals("error")) { OtpErlangTuple error = (OtpErlangTuple) expectedQuoted; OtpErlangLong line = (OtpErlangLong) error.elementAt(0); OtpErlangBinary messageBinary = (OtpErlangBinary) error.elementAt(1); String message = ElixirPsiImplUtil.javaString(messageBinary); OtpErlangBinary tokenBinary = (OtpErlangBinary) error.elementAt(2); String token = ElixirPsiImplUtil.javaString(tokenBinary); throw new AssertionError( "intellij_elixir returned \"" + message + "\" on line " + line + " due to " + token + ", use assertQuotesAroundError if error is expect in Elixir natively, " + "but not in intellij-elixir plugin" ); } } catch (IOException | OtpErlangDecodeException | OtpErlangExit e) { throw new RuntimeException(e); } }
/** * The boolean value of this atom. * * @return the value of this atom expressed as a boolean value. If the atom * consists of the characters "true" (independent of case) the value * will be true. For any other values, the value will be false. * */ public boolean booleanValue() { return Boolean.valueOf(atomValue()).booleanValue(); }
return "yes".equals(a.atomValue()); } catch (final Exception e) { } finally {
public void handleResponseError(String module, String function, OtpErlangObject result) { //{badrpc,{'EXIT',{undef,[{rabbit_access_control,list_users,[[]]},{rpc,'-handle_call/3-fun-0-',5}]}}} if (result instanceof OtpErlangTuple) { OtpErlangTuple msg = (OtpErlangTuple)result; if (msg.elementAt(0) instanceof OtpErlangAtom) { OtpErlangAtom responseAtom = (OtpErlangAtom)msg.elementAt(0); //TODO consider error handler strategy. if (responseAtom.atomValue().equals("badrpc")) { if (msg.elementAt(1) instanceof OtpErlangTuple) { throw new ErlangBadRpcException( (OtpErlangTuple)msg.elementAt(1)); } else { throw new ErlangBadRpcException( msg.elementAt(1).toString()); } } else if (responseAtom.atomValue().equals("error")) { if (msg.elementAt(1) instanceof OtpErlangTuple) { throw new ErlangErrorRpcException( (OtpErlangTuple)msg.elementAt(1)); } else { throw new ErlangErrorRpcException( msg.elementAt(1).toString()); } } } } }
return ((OtpErlangBinary) erlangObject).binaryValue(); } else if (erlangObject instanceof OtpErlangAtom) { return ((OtpErlangAtom) erlangObject).atomValue(); } else if (erlangObject instanceof OtpErlangBinary) { return ((OtpErlangBinary) erlangObject).binaryValue();
if (!cookie.atomValue().equals(localNode.cookie())) { cookieError(localNode, cookie); if (!cookie.atomValue().equals("")) { cookieError(localNode, cookie); if (!cookie.atomValue().equals(localNode.cookie())) { cookieError(localNode, cookie); if (!cookie.atomValue().equals("")) { cookieError(localNode, cookie); toName = (OtpErlangAtom) head.elementAt(3); deliver(new OtpMsg(from, toName.atomValue(), ibuf)); break;