use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class WranglerRefactoringBackend method callWithParser.
/**
* Send an RPC, and allow to define a costum parser
*
* @param parser
* parser object
* @param functionName
* function name in wrangler_refacs.erl
* @param signature
* parameters signature
* @param parameters
* parameters array
* @return parsed RPC message
*/
public IRpcMessage callWithParser(final IRpcMessage parser, final String functionName, final String signature, final Object... parameters) {
final RpcResult res = callWithoutParser(functionName, signature, parameters);
parser.parse(res);
return parser;
}
use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class WranglerRefactoringBackend method call.
/**
* Send an RPC and parses it with the default parser
*
* @param functionName
* function name in wrangler.erl
* @param signature
* parameters signature
* @param parameters
* parameters in an array
* @return parsed RPC message
* @noreference This method is not intended to be referenced by clients.
*/
public AbstractRefactoringRpcMessage call(final String functionName, final String signature, final Object... parameters) {
final RpcResult res = callWithoutParser(functionName, signature, parameters);
final AbstractRefactoringRpcMessage message = new RefactoringRpcMessage();
message.parse(res);
return message;
}
use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class RenameVariableRefactoring method getDefaultValue.
@Override
public String getDefaultValue() {
final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
if (sel == null) {
return "";
}
final RpcResult res = WranglerBackendManager.getRefactoringBackend().callWithoutParser("get_var_name_eclipse", "siixi", sel.getFilePath(), sel.getSelectionRange().getStartLine(), sel.getSelectionRange().getStartCol(), sel.getSearchPath(), GlobalParameters.getTabWidth());
if (res.getValue().getClass().equals(OtpErlangString.class)) {
return ((OtpErlangString) res.getValue()).stringValue();
}
return "";
}
use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class UserAdhocRefactoring method load.
/**
* Loading user's callback module
*
* @return
*/
public boolean load() {
String callbackPath;
try {
if (ErlangEngine.getInstance().getModel().findModule(refac.getCallbackModule()) == null) {
return false;
}
final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(ErlangEngine.getInstance().getModel().findModule(refac.getCallbackModule()));
callbackPath = project.getWorkspaceProject().getLocation().append(project.getProperties().getOutputDir()).toString();
} catch (final ErlModelException e) {
return false;
}
final RpcResult res = WranglerBackendManager.getRefactoringBackend().callWithoutParser("load_callback_mod_eclipse", "ss", refac.getCallbackModule(), callbackPath);
if (!res.isOk()) {
return false;
}
return true;
}
use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class SimpleCodeInspectionHandler method handleLargeModulesCall.
private void handleLargeModulesCall(final IErlSelection wranglerSelection, final Shell shell) {
CodeInspectionViewsManager.hideView(CodeInspectionViewsManager.CODE_INSPECTION_VIEW, SimpleCodeInspectionHandler.LARGE_MODULES_VIEW_ID);
final InputDialog dialog = new InputDialog(shell, "Lines of a large module", "Lines of a large module:", "", new IntegerInputValidator());
final int ret = dialog.open();
if (ret == Window.CANCEL) {
return;
}
final int lines = Integer.parseInt(dialog.getValue());
final RpcResult res = WranglerBackendManager.getRefactoringBackend().callInspection("large_modules_eclipse", "ixi", lines, wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
ArrayList<IErlElement> modules = new ArrayList<>();
try {
final OtpErlangObject obj = res.getValue();
final OtpErlangTuple restuple = (OtpErlangTuple) obj;
final OtpErlangAtom resindicator = (OtpErlangAtom) restuple.elementAt(0);
if ("ok".equals(resindicator.atomValue())) {
final OtpErlangList modList = (OtpErlangList) restuple.elementAt(1);
modules = createErlModuleList(modList);
} else {
final OtpErlangString s = (OtpErlangString) restuple.elementAt(1);
MessageDialog.openError(shell, "Error", s.stringValue());
return;
}
} catch (final Exception e) {
ErlLogger.error(e);
}
if (!modules.isEmpty()) {
CodeInspectionViewsManager.showErlElements("Large modules", modules, SimpleCodeInspectionHandler.LARGE_MODULES_VIEW_ID);
} else {
MessageDialog.openInformation(shell, "No result", "There is no large module with the specified parameter!");
}
}
Aggregations