use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class SimilarDetectionAction method callRefactoring.
@Override
protected IResultParser callRefactoring() throws WranglerRpcParsingException, CoreException, IOException, WranglerWarningException {
final WranglerRefactoringBackend backend = WranglerBackendManager.getRefactoringBackend();
final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
RpcResult result;
final String functionName = "sim_code_detection_eclipse";
if (onlyInFile) {
final OtpErlangString fp = new OtpErlangString(sel.getFilePath());
final OtpErlangString[] fpa = new OtpErlangString[1];
fpa[0] = fp;
final OtpErlangList fpl = new OtpErlangList(fpa);
result = backend.callWithoutParser(WranglerRefactoringBackend.UNLIMITED_TIMEOUT, functionName, "xiiiidxi", fpl, minLen, minToks, minFreq, maxNewVars, simScore, sel.getSearchPath(), GlobalParameters.getTabWidth());
} else {
result = backend.callWithoutParser(WranglerRefactoringBackend.UNLIMITED_TIMEOUT, functionName, "xiiiidxi", sel.getSearchPath(), minLen, minToks, minFreq, maxNewVars, simScore, sel.getSearchPath(), GlobalParameters.getTabWidth());
}
if (!result.isOk()) {
throw new WranglerRpcParsingException("Rpc error");
}
return new DuplicateDetectionParser(result.getValue());
}
use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class SimilarSearchAction method callRefactoring.
@Override
protected IResultParser callRefactoring() throws WranglerRpcParsingException, CoreException, IOException, WranglerWarningException {
final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
final WranglerRefactoringBackend backend = WranglerBackendManager.getRefactoringBackend();
RpcResult result = null;
String functionName;
if (onlyInFile) {
functionName = "simi_expr_search_in_buffer_eclipse";
} else {
functionName = "simi_expr_search_in_dirs_eclipse";
}
result = backend.callWithoutParser(WranglerRefactoringBackend.UNLIMITED_TIMEOUT, functionName, "sxxxxi", sel.getFilePath(), sel.getSelectionRange().getStartPos(), sel.getSelectionRange().getEndPos(), new OtpErlangFloat(simScore), sel.getSearchPath(), GlobalParameters.getTabWidth());
if (result.isOk()) {
return new SimilarExpressionSearchParser(result.getValue());
}
throw new WranglerRpcParsingException("RPC error");
}
use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class UserRefactoringsManager method scanForUserRefactorings.
/**
* Looks for user defined refactorings (in order to generate menu items for
* them)
*/
@SuppressWarnings("rawtypes")
private void scanForUserRefactorings() {
elementaryRefacs = new LinkedList<>();
compositeRefacs = new LinkedList<>();
myElementaryRefacs = new LinkedList<>();
myCompositeRefacs = new LinkedList<>();
final Bundle coreBundle = Platform.getBundle(Activator.CORE_ID);
final Enumeration modules = coreBundle.findEntries("wrangler/ebin", "*.beam", false);
// modules that origin from repository
final List<OtpErlangObject> erlModules = new LinkedList<>();
while (modules != null && modules.hasMoreElements()) {
final String next = modules.nextElement().toString();
final String module = next.substring(next.lastIndexOf('/') + 1, next.lastIndexOf('.'));
erlModules.add(new OtpErlangString(module));
}
RpcResult res = WranglerBackendManager.getRefactoringBackend().callWithoutParser("get_user_refactorings", "x", new OtpErlangList(erlModules.toArray(new OtpErlangObject[0])));
if (res.isOk() && res.getValue() instanceof OtpErlangList) {
final OtpErlangList genRefac = (OtpErlangList) ((OtpErlangTuple) ((OtpErlangList) res.getValue()).elementAt(0)).elementAt(1);
final OtpErlangList genCompositeRefac = (OtpErlangList) ((OtpErlangTuple) ((OtpErlangList) res.getValue()).elementAt(1)).elementAt(1);
for (final OtpErlangObject obj : genRefac) {
elementaryRefacs.add(new UserRefactoringInfo(obj.toString()));
}
for (final OtpErlangObject obj : genCompositeRefac) {
compositeRefacs.add(new UserRefactoringInfo(obj.toString()));
}
}
ErlLogger.info("Refac modules found " + res.toString());
// user's own refactoring
final Enumeration userModules = coreBundle.findEntries("wrangler/ebin/my_gen_refac", "*.beam", false);
while (userModules != null && userModules.hasMoreElements()) {
final String next = userModules.nextElement().toString();
myElementaryRefacs.add(new UserRefactoringInfo(next.substring(next.lastIndexOf('/') + 1, next.lastIndexOf('.'))));
}
// user's own composite refactorings
final Enumeration userCompositeModules = coreBundle.findEntries("wrangler/ebin/my_gen_composite_refac", "*.beam", false);
while (userCompositeModules != null && userCompositeModules.hasMoreElements()) {
final String next = userCompositeModules.nextElement().toString();
myCompositeRefacs.add(new UserRefactoringInfo(next.substring(next.lastIndexOf('/') + 1, next.lastIndexOf('.'))));
}
// load refactorings
res = WranglerBackendManager.getRefactoringBackend().callWithoutParser("load_user_refactorings", "s", getEbinPath());
ErlLogger.debug(res.toString());
}
use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class WranglerSyntaxBackend method varToPos.
protected SyntaxInfo varToPos(final OtpErlangTuple syntaxTree, final int line, final int col) {
final OtpErlangInt[] position = new OtpErlangInt[2];
position[0] = new OtpErlangInt(line);
position[1] = new OtpErlangInt(col);
final RpcResult res = backend.call_noexception(WranglerSyntaxBackend.INTERFACE_MODULE, WranglerSyntaxBackend.VAR_FUNCTION, "xx", syntaxTree, new OtpErlangTuple(position));
return parseVarInfo(res.getValue());
}
use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class Activator method initWrangler.
/**
* Loads the necessary *.ebin files to the Erlang node for the plug-in.
*
* @throws CoreException
* detailed exception about the loading process errors
*/
private void initWrangler() throws CoreException {
final IOtpRpc mb = getBackend();
RpcResult res = mb.call_noexception("wrangler_refacs", "init_eclipse", "", new Object[0]);
ErlLogger.debug("Wrangler app started:\n" + res);
res = mb.call_noexception("wrangler_error_logger", "init", "x", new OtpErlangList());
ErlLogger.debug("Error logger started:" + res);
}
Aggregations