use of org.erlide.wrangler.refactoring.util.Range in project erlide_eclipse by erlang.
the class ExpressionPosRpcMessage method parseRefactoringMessage.
@Override
protected void parseRefactoringMessage(final OtpErlangTuple resultTuple) throws WranglerException {
try {
final OtpErlangObject wranglerResult = resultTuple.elementAt(1);
if ("ok".equals(resultTuple.elementAt(0).toString())) {
OtpErlangList posDefList;
if (wranglerResult instanceof OtpErlangTuple) {
syntaxTree = ((OtpErlangTuple) wranglerResult).elementAt(0);
posDefList = (OtpErlangList) ((OtpErlangTuple) wranglerResult).elementAt(1);
} else {
syntaxTree = null;
posDefList = (OtpErlangList) wranglerResult;
}
positionDefs = new HashMap<>();
final OtpErlangObject[] elements = posDefList.elements();
for (final OtpErlangObject o : elements) {
final OtpErlangTuple value = (OtpErlangTuple) o;
final OtpErlangTuple pos = (OtpErlangTuple) value.elementAt(0);
try {
positionDefs.put(new Range(pos), value);
} catch (final OtpErlangRangeException e) {
ErlLogger.error(e);
setUnsuccessful("Failed to parse the result!");
}
}
setSuccessful();
} else {
final OtpErlangString errorMsg = (OtpErlangString) wranglerResult;
setUnsuccessful(errorMsg.stringValue());
return;
}
} catch (final Exception e) {
throw new WranglerRpcParsingException(resultTuple.toString());
}
}
use of org.erlide.wrangler.refactoring.util.Range 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