use of com.ericsson.otp.erlang.OtpErlangString 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 com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class UserElementaryRefactoring method run.
@Override
public IRefactoringRpcMessage run(final IErlSelection selection) {
final IErlMemberSelection sel = (IErlMemberSelection) selection;
final OtpErlangList pos = new OtpErlangList(new OtpErlangInt[] { new OtpErlangInt(sel.getSelectionRange().getStartLine()), new OtpErlangInt(sel.getSelectionRange().getStartCol()) });
final OtpErlangList selectionBeg = new OtpErlangList(new OtpErlangInt[] { new OtpErlangInt(sel.getSelectionRange().getStartLine()), new OtpErlangInt(sel.getSelectionRange().getStartCol()) });
final OtpErlangList selectionEnd = new OtpErlangList(new OtpErlangInt[] { new OtpErlangInt(sel.getSelectionRange().getEndLine()), new OtpErlangInt(sel.getSelectionRange().getEndCol()) });
final OtpErlangList selectionPos = new OtpErlangList(new OtpErlangObject[] { selectionBeg, selectionEnd });
final OtpErlangList args = new OtpErlangList(new OtpErlangObject[] { new OtpErlangString(sel.getFilePath()), pos, selectionPos, prepareUserInput(), sel.getSearchPath(), new OtpErlangInt(GlobalParameters.getTabWidth()) });
return WranglerBackendManager.getRefactoringBackend().call("run_refac_eclipse", "sx", getCallbackModule(), args);
}
use of com.ericsson.otp.erlang.OtpErlangString 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!");
}
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class SimpleCodeInspectionHandler method extractModule.
private IErlModule extractModule(final OtpErlangObject m) throws ErlModelException {
String name = "";
if (m instanceof OtpErlangString) {
final OtpErlangString element = (OtpErlangString) m;
name = element.stringValue();
} else if (m instanceof OtpErlangAtom) {
final OtpErlangAtom atom = (OtpErlangAtom) m;
name = atom.atomValue();
}
final String[] modNameParts = name.split("/");
final IErlModule mod = ErlangEngine.getInstance().getModel().findModule(modNameParts[modNameParts.length - 1]);
return mod;
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class AbstractRefactoringRpcMessage method parseFileList.
protected ArrayList<ChangedFile> parseFileList(final OtpErlangList fileList) {
final ArrayList<ChangedFile> ret = new ArrayList<>();
OtpErlangTuple e;
OtpErlangString oldPath;
OtpErlangString newPath;
for (int i = 0; i < fileList.arity(); ++i) {
e = (OtpErlangTuple) fileList.elementAt(i);
oldPath = (OtpErlangString) e.elementAt(0);
newPath = (OtpErlangString) e.elementAt(1);
final String newContent = OtpErlang.asString(e.elementAt(2));
ret.add(new ChangedFile(oldPath.stringValue(), newPath.stringValue(), newContent));
}
return ret;
}
Aggregations