use of org.erlide.util.erlang.SignatureException in project erlide_eclipse by erlang.
the class ErlangDebugTarget method getProjectDirs.
private OtpErlangList getProjectDirs(final IProject project) {
final IErlModel model = ErlangEngine.getInstance().getModel();
final ErlangProjectProperties properties = model.findProject(project).getProperties();
final String ebin = properties.getOutputDir().toPortableString();
final Collection<IPath> srcs = properties.getSourceDirs();
try {
return (OtpErlangList) OtpErlang.format("[{ebin_dir, ~s}, {src_dirs, ~ls}]", ebin, srcs);
} catch (final OtpParserException e) {
ErlLogger.warn(e);
} catch (final SignatureException e) {
ErlLogger.warn(e);
}
return new OtpErlangList();
}
use of org.erlide.util.erlang.SignatureException in project erlide_eclipse by erlang.
the class OtpRpc method convertArgs.
private OtpErlangObject[] convertArgs(final String signature, final Object... args) throws SignatureException {
final Object[] args0 = args == null ? new OtpErlangObject[] {} : args;
Signature[] type;
type = Signature.parse(signature);
if (type == null) {
type = new Signature[args0.length];
for (int i = 0; i < args0.length; i++) {
type[i] = new Signature('x');
}
}
if (type.length != args0.length) {
throw new SignatureException("Signature doesn't match parameter number: " + type.length + "/" + args0.length);
}
final OtpErlangObject[] args1 = new OtpErlangObject[args0.length];
for (int i = 0; i < args1.length; i++) {
args1[i] = TypeConverter.java2erlang(args0[i], type[i]);
}
return args1;
}
use of org.erlide.util.erlang.SignatureException in project erlide_eclipse by erlang.
the class OtpRpc method async_call_result.
@Override
public void async_call_result(final IRpcResultCallback cb, final String m, final String f, final String signature, final Object... args) throws RpcException {
final OtpErlangAtom gleader = OtpRpc.USER_ATOM;
try {
final Object[] args1 = new Object[args.length + 1];
System.arraycopy(args, 0, args1, 1, args.length);
final OtpMbox mbox = localNode.createMbox();
args1[0] = mbox.self();
new RpcResultReceiver(mbox, cb);
rpcCast(localNode, nodeName, false, gleader, m, f, signature, args1);
} catch (final SignatureException e) {
throw new RpcException(e);
}
}
use of org.erlide.util.erlang.SignatureException in project erlide_eclipse by erlang.
the class OtpRpc method async_call_cb.
@Override
public void async_call_cb(final IRpcCallback cb, final long timeout, final OtpErlangObject gleader, final String module, final String fun, final String signature, final Object... args) throws RpcException {
checkConnected();
try {
final RpcFuture future = sendRpcCall(localNode, nodeName, false, gleader, module, fun, signature, args);
final Runnable target = new Runnable() {
@Override
public void run() {
OtpErlangObject result;
try {
result = future.checkedGet(timeout, TimeUnit.MILLISECONDS);
cb.onSuccess(result);
} catch (final Exception e) {
ErlLogger.error("Could not execute RPC " + module + ":" + fun + " : " + e.getMessage());
cb.onFailure(e);
}
}
};
// We can't use jobs here, it's an Eclipse dependency
OtpRpc.threadPool.execute(target);
} catch (final SignatureException e) {
throw new RpcException(e);
}
}
use of org.erlide.util.erlang.SignatureException in project erlide_eclipse by erlang.
the class OtpRpc method call.
@Override
public OtpErlangObject call(final long timeout, final OtpErlangObject gleader, final String module, final String fun, final String signature, final Object... args0) throws RpcException {
checkConnected();
OtpErlangObject result = null;
try {
final RpcFuture future = sendRpcCall(localNode, nodeName, false, gleader, module, fun, signature, args0);
result = future.checkedGet(timeout, TimeUnit.MILLISECONDS);
if (OtpRpc.CHECK_RPC) {
ErlLogger.debug("RPC result:: " + result);
}
if (isBadRpc(result)) {
throw new RpcException("Bad RPC: " + result);
}
} catch (final SignatureException e) {
throw new RpcException(e);
} catch (final TimeoutException e) {
throw new RpcTimeoutException(e.getMessage());
}
return result;
}
Aggregations