use of org.erlide.engine.model.IErlElement 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.engine.model.IErlElement 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.engine.model.IErlElement 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.engine.model.IErlElement in project erlide_eclipse by erlang.
the class BreakpointUtils method getElement.
public static IErlElement getElement(final ILineBreakpoint breakpoint) {
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlElement element = model.findElement(breakpoint.getMarker().getResource());
if (element instanceof IErlModule) {
final IErlModule m = (IErlModule) element;
try {
m.open(null);
final int lineNumber = breakpoint.getLineNumber();
return m.getElementAtLine(lineNumber - 1);
} catch (final Exception e) {
ErlLogger.warn(e);
}
}
return null;
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class SearchPatternFactory method getSearchPatternFromErlElementAndLimitTo.
public ErlangSearchPattern getSearchPatternFromErlElementAndLimitTo(final IErlElement element, final LimitTo limitTo) {
if (element instanceof IErlFunction) {
final IErlFunction function = (IErlFunction) element;
final String withoutExtension = SystemConfiguration.withoutExtension(function.getModuleName());
return new FunctionPattern(withoutExtension, function.getFunctionName(), function.getArity(), limitTo, true, modelUtilService.getModule(function), !function.isExported());
} else if (element instanceof IErlMacroDef) {
final IErlMacroDef m = (IErlMacroDef) element;
final String unquoted = StringUtils.unquote(m.getDefinedName());
return new MacroPattern(unquoted, limitTo);
} else if (element instanceof IErlRecordDef) {
final IErlRecordDef r = (IErlRecordDef) element;
final String unquoted = StringUtils.unquote(r.getDefinedName());
return new RecordPattern(unquoted, limitTo);
} else if (element instanceof IErlFunctionClause) {
final IErlFunctionClause clause = (IErlFunctionClause) element;
return getSearchPatternFromErlElementAndLimitTo((IErlElement) clause.getParent(), limitTo);
} else if (element instanceof IErlAttribute) {
final IErlAttribute a = (IErlAttribute) element;
if (a.getName().startsWith("include")) {
final String s = Util.stringValue(a.getValue());
return new IncludePattern(s, limitTo);
}
}
return null;
}
Aggregations