use of org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException in project erlide_eclipse by erlang.
the class AbstractDuplicatesSearcherAction method run.
/**
* Runs the refactoring.
*/
public void run() {
// TODO: run it in a new thread
selectionChanged();
if (getUserInput()) {
final IProgressMonitor monitor = new NullProgressMonitor();
try {
IResultParser result;
monitor.beginTask("Detecting..", 0);
result = callRefactoring();
if (result.isSuccessful()) {
showDuplicatesView();
addDuplicates(result.getDuplicates());
} else {
DuplicatesUIManager.closeDuplicatesView();
displayErrorNotification(result.getErrorMessage());
}
} catch (final WranglerWarningException e) {
} catch (final WranglerRpcParsingException e) {
displayErrorNotification(rpcErrorMsg);
} catch (final CoreException e) {
displayErrorNotification(rpcErrorMsg);
} catch (final IOException e) {
displayErrorNotification(rpcErrorMsg);
} finally {
monitor.done();
}
}
}
use of org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException in project erlide_eclipse by erlang.
the class DuplicateDetectionAction method callRefactoring.
@SuppressWarnings("boxing")
@Override
protected IResultParser callRefactoring() throws WranglerRpcParsingException, CoreException, IOException, WranglerWarningException {
String functionName;
RpcResult result;
// getting the path of the fragment
final String suffixPath = getSuffixPath();
ErlLogger.debug("Suffix binary at: " + suffixPath);
final WranglerRefactoringBackend backend = WranglerBackendManager.getRefactoringBackend();
final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
if (onlyInfile) {
functionName = "duplicated_code_eclipse";
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, "xiiis", fpl, minToks, minClones, GlobalParameters.getTabWidth(), suffixPath);
} else {
functionName = "duplicated_code_eclipse";
result = backend.callWithoutParser(WranglerRefactoringBackend.UNLIMITED_TIMEOUT, functionName, "xiiis", sel.getSearchPath(), minToks, minClones, GlobalParameters.getTabWidth(), suffixPath);
}
if (!result.isOk()) {
throw new WranglerRpcParsingException("Rpc error");
}
return new DuplicateDetectionParser(result.getValue());
}
use of org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException 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.wrangler.refactoring.exception.WranglerRpcParsingException 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.wrangler.refactoring.exception.WranglerRpcParsingException 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());
}
}
Aggregations