use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class SimpleCodeInspectionHandler method handleLongFunctions.
private void handleLongFunctions(final IErlSelection wranglerSelection, final Shell shell) {
try {
CodeInspectionViewsManager.hideView(SimpleCodeInspectionHandler.LONG_FUNCTIONS);
// call inputdialog
final InputDialogWithCheckbox dialog = new InputDialogWithCheckbox(shell, "Search for long functions", "Number of lines:", "Search in the project", "", new IntegerInputValidator());
if (Window.OK == dialog.open()) {
final int linesVal = Integer.parseInt(dialog.getValue());
final boolean inProject = dialog.isCheckBoxChecked();
RpcResult res = null;
if (inProject) {
res = WranglerBackendManager.getRefactoringBackend().callInspection("long_functions_in_dirs_eclipse", "ixi", linesVal, wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
} else {
res = WranglerBackendManager.getRefactoringBackend().callInspection("long_functions_in_file_eclipse", "sixi", wranglerSelection.getFilePath(), linesVal, wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
}
// handle rpc
final ArrayList<IErlElement> elements = processFunctionResult(shell, res);
if (elements == null) {
return;
}
// show result
if (!elements.isEmpty()) {
CodeInspectionViewsManager.showErlElements("Long functions", elements, SimpleCodeInspectionHandler.LONG_FUNCTIONS);
} else {
MessageDialog.openInformation(shell, "No result", "Could not found any function which is longer, than " + linesVal + " lines.");
}
}
} catch (final Exception e) {
ErlLogger.error(e);
}
}
use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class SimpleCodeInspectionHandler method handleNotFlushUnknownMessages.
private void handleNotFlushUnknownMessages(final IErlSelection wranglerSelection, final Shell shell) {
final String inFile = "not_flush_unknown_messages_in_file_eclipse";
final String inProject = "not_flush_unknown_messages_in_dirs_eclipse";
CodeInspectionViewsManager.hideView(SimpleCodeInspectionHandler.NOT_FLUSH_UNKNOWN_MESSAGES);
final Boolean answer = MessageDialog.openQuestion(shell, "Find incomplete receive patterns", "Would you like to run the scan in the whole project?");
try {
RpcResult result = null;
String function = "";
if (answer) {
function = inProject;
result = WranglerBackendManager.getRefactoringBackend().callInspection(function, "xi", wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
} else {
function = inFile;
result = WranglerBackendManager.getRefactoringBackend().callInspection(function, "sxi", wranglerSelection.getFilePath(), wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
}
final ArrayList<IErlElement> elements = processFunctionResult(shell, result);
if (elements == null) {
return;
}
if (!elements.isEmpty()) {
CodeInspectionViewsManager.showErlElements("Incomplete receive patterns", elements, SimpleCodeInspectionHandler.NOT_FLUSH_UNKNOWN_MESSAGES);
} else {
MessageDialog.openInformation(shell, "No result", "Could not found any incomplete receive patterns!");
}
} catch (final Exception e) {
ErlLogger.error(e);
}
}
use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class SimpleCodeInspectionHandler method handleDepenenciesCall.
private void handleDepenenciesCall(final IErlSelection wranglerSelection, final Shell shell) {
// hiding the views
CodeInspectionViewsManager.hideView(CodeInspectionViewsManager.CODE_INSPECTION_VIEW, SimpleCodeInspectionHandler.DEPENECIES_1_VIEW_ID);
CodeInspectionViewsManager.hideView(CodeInspectionViewsManager.CODE_INSPECTION_VIEW, SimpleCodeInspectionHandler.DEPENECIES_2_VIEW_ID);
// run the rpc
try {
final RpcResult res = WranglerBackendManager.getRefactoringBackend().callInspection("dependencies_of_a_module_eclipse", "sx", wranglerSelection.getFilePath(), wranglerSelection.getSearchPath());
ArrayList<IErlElement> modules1 = new ArrayList<>();
ArrayList<IErlElement> modules2 = new ArrayList<>();
final OtpErlangObject obj = res.getValue();
final OtpErlangTuple restuple = (OtpErlangTuple) obj;
final OtpErlangAtom resindicator = (OtpErlangAtom) restuple.elementAt(0);
if ("ok".equals(resindicator.atomValue())) {
final OtpErlangTuple listtuple = (OtpErlangTuple) restuple.elementAt(1);
final OtpErlangList modList1 = (OtpErlangList) listtuple.elementAt(0);
final OtpErlangList modList2 = (OtpErlangList) listtuple.elementAt(1);
modules1 = createErlModuleList(modList1);
modules2 = createErlModuleList(modList2);
} else {
final OtpErlangString s = (OtpErlangString) restuple.elementAt(1);
MessageDialog.openError(shell, "Error", s.stringValue());
return;
}
if (!modules1.isEmpty()) {
CodeInspectionViewsManager.showErlElements("Modules which depends on " + wranglerSelection.getErlElement().getAncestorOfKind(ErlElementKind.MODULE).getName(), modules1, SimpleCodeInspectionHandler.DEPENECIES_1_VIEW_ID);
}
if (!modules2.isEmpty()) {
CodeInspectionViewsManager.showErlElements("Modules, on which " + wranglerSelection.getErlElement().getAncestorOfKind(ErlElementKind.MODULE).getName() + " depends", modules2, SimpleCodeInspectionHandler.DEPENECIES_2_VIEW_ID);
} else {
MessageDialog.openInformation(shell, "No result", "There is no large module with the specified parameter!");
}
} catch (final Exception e) {
ErlLogger.error(e);
}
}
use of org.erlide.runtime.rpc.RpcResult in project erlide_eclipse by erlang.
the class SimpleCodeInspectionHandler method handleNested.
private void handleNested(final IErlSelection wranglerSelection, final Shell shell, final String type) {
try {
CodeInspectionViewsManager.hideView(SimpleCodeInspectionHandler.NESTED_EXPRESSIONS + type);
// call inputdialog
final InputDialogWithCheckbox dialog = new InputDialogWithCheckbox(shell, "Search for nested expression", "Nest level:", "Search in the project", "", new IntegerInputValidator());
if (Window.OK == dialog.open()) {
final int nestedVal = Integer.parseInt(dialog.getValue());
final boolean inProject = dialog.isCheckBoxChecked();
RpcResult res = null;
if (inProject) {
res = WranglerBackendManager.getRefactoringBackend().callInspection("nested_exprs_in_dirs_eclipse", "iaxi", nestedVal, type, wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
} else {
res = WranglerBackendManager.getRefactoringBackend().callInspection("nested_exprs_in_file_eclipse", "siaxi", wranglerSelection.getFilePath(), nestedVal, type, wranglerSelection.getSearchPath(), GlobalParameters.getTabWidth());
}
// handle rpc
final ArrayList<IErlElement> elements = processFunctionResult(shell, res);
if (elements == null) {
return;
}
// show result
if (!elements.isEmpty()) {
CodeInspectionViewsManager.showErlElements("Nested " + type + " expressions", elements, SimpleCodeInspectionHandler.NESTED_EXPRESSIONS + type);
} else {
MessageDialog.openInformation(shell, "No result", "Could not found any " + nestedVal + " levels nested " + type + " expression!");
}
}
} catch (final Exception e) {
ErlLogger.error(e);
}
}
use of org.erlide.runtime.rpc.RpcResult 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());
}
Aggregations