use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection 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.wrangler.refactoring.selection.IErlMemberSelection 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 org.erlide.wrangler.refactoring.selection.IErlMemberSelection in project erlide_eclipse by erlang.
the class ExpressionSearchAction method callRefactoring.
@Override
protected IResultParser callRefactoring() throws WranglerRpcParsingException {
final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
final WranglerRefactoringBackend backend = WranglerBackendManager.getRefactoringBackend();
final RpcResult result = backend.callWithoutParser(WranglerRefactoringBackend.UNLIMITED_TIMEOUT, "expr_search_eclipse", "sxxi", sel.getFilePath(), sel.getSelectionRange().getStartPos(), sel.getSelectionRange().getEndPos(), GlobalParameters.getTabWidth());
if (result.isOk()) {
return new ExpressionSearchParser(result.getValue());
}
throw new WranglerRpcParsingException("RPC error");
}
use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection in project erlide_eclipse by erlang.
the class FoldAgainstMacro method checkInitialConditions.
@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
final IErlSelection selection = GlobalParameters.getWranglerSelection();
/*
* if (!((selection instanceof IErlMemberSelection) && (selection
* .getKind() == SelectionKind.FUNCTION || selection.getKind() ==
* SelectionKind.FUNCTION_CLAUSE))) return RefactoringStatus
* .createFatalErrorStatus("Please select an expression!");
*/
final IErlMemberSelection sel = (IErlMemberSelection) selection;
ExpressionPosRpcMessage m = new ExpressionPosRpcMessage();
m = (ExpressionPosRpcMessage) WranglerBackendManager.getRefactoringBackend().callWithParser(m, "fold_against_macro_eclipse", "siixi", sel.getFilePath(), sel.getMemberRange().getStartLine(), sel.getMemberRange().getStartCol(), sel.getSearchPath(), GlobalParameters.getTabWidth());
if (m.isSuccessful()) {
syntaxTree = m.getSyntaxTree();
positions = m.getPositionDefinitions(sel.getDocument());
selectedPositions = new ArrayList<>();
} else {
return RefactoringStatus.createFatalErrorStatus(m.getMessageString());
}
return new RefactoringStatus();
}
use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection in project erlide_eclipse by erlang.
the class GeneraliseFunctionRefactoring method createPositionList.
/**
* Returns IErlRange, OtpErlangTuple pairs, which are represents the same
* position in a module
*
* @param thePositions
* @return
*/
protected HashMap<IErlRange, OtpErlangTuple> createPositionList(final OtpErlangList thePositions) {
try {
final HashMap<IErlRange, OtpErlangTuple> ret = new HashMap<>();
final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
for (final OtpErlangObject o : thePositions) {
// {{sl, sc}, {el,ec}}
final OtpErlangTuple pos = (OtpErlangTuple) o;
ret.put(new ErlRange(new Range(pos), sel.getDocument()), pos);
}
return ret;
} catch (final OtpErlangException e) {
ErlLogger.error(e);
return null;
}
}
Aggregations