use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class ModelInternalUtils method getExternalModulePath.
@Override
public String getExternalModulePath(final IErlElementLocator model, final IErlModule module) {
final List<String> result = Lists.newArrayList();
IErlElement element = module;
while (element != model) {
if (element instanceof IErlExternal) {
final IErlExternal external = (IErlExternal) element;
result.add(external.getName());
} else {
result.add(element.getName());
}
element = (IErlElement) element.getParent();
}
return Joiner.on(ModelInternalUtils.DELIMITER).join(Lists.reverse(result));
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class ErlElement method closing.
/**
* This element is being closed. Do any necessary cleanup.
*
* @throws ErlModelException
*/
protected void closing(final Object info) throws ErlModelException {
for (final IErlElement e : getChildren()) {
if (e instanceof ErlElement) {
final ErlElement ee = (ErlElement) e;
ee.closing(info);
}
}
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class SimpleCodeInspectionHandler method processFunctionResult.
private ArrayList<IErlElement> processFunctionResult(final Shell shell, final RpcResult result) throws OtpErlangRangeException {
final ArrayList<IErlElement> elements = new ArrayList<>();
final OtpErlangObject obj = result.getValue();
final OtpErlangTuple restuple = (OtpErlangTuple) obj;
final OtpErlangAtom resindicator = (OtpErlangAtom) restuple.elementAt(0);
if ("ok".equals(resindicator.atomValue())) {
final OtpErlangList erlangFunctionList = (OtpErlangList) restuple.elementAt(1);
for (int i = 0; i < erlangFunctionList.arity(); ++i) {
final OtpErlangTuple fTuple = (OtpErlangTuple) erlangFunctionList.elementAt(i);
IErlFunctionClause f;
try {
f = extractFunction(fTuple);
elements.add(f);
} catch (final ErlModelException e) {
}
}
} else {
final OtpErlangString s = (OtpErlangString) restuple.elementAt(1);
MessageDialog.openError(shell, "Error", s.stringValue());
return null;
}
return elements;
}
use of org.erlide.engine.model.IErlElement in project erlide_eclipse by erlang.
the class SimpleCodeInspectionHandler method createErlModuleList.
private ArrayList<IErlElement> createErlModuleList(final OtpErlangList modList) {
final ArrayList<IErlElement> modules = new ArrayList<>();
for (int i = 0; i < modList.arity(); ++i) {
IErlModule m;
try {
m = extractModule(modList.elementAt(i));
modules.add(m);
} catch (final ErlModelException e) {
}
}
return modules;
}
use of org.erlide.engine.model.IErlElement 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);
}
}
Aggregations