use of org.erlide.engine.model.erlang.ErlangFunction in project erlide_eclipse by erlang.
the class OpenItemAction method run.
@Override
public void run() {
log.info("Open item!");
final ISelection selection = viewer.getSelection();
if (!(selection instanceof ITreeSelection)) {
final IStatus executionStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Internall error occured: bad sellection type", null);
StatusManager.getManager().handle(executionStatus, StatusManager.SHOW);
return;
}
final ITreeSelection treeSelection = (ITreeSelection) selection;
final StatsTreeObject obj = (StatsTreeObject) treeSelection.getFirstElement();
if (obj.getClass().equals(ModuleStats.class)) {
openInEditor(obj.getLabel() + ".erl");
} else if (obj.getClass().equals(FunctionStats.class)) {
final FunctionStats fs = (FunctionStats) obj;
final String moduleName = ((StatsTreeObject) fs.getParent()).getLabel();
final IEditorPart p = openInEditor(moduleName + ".erl");
if (p == null || !(p instanceof ErlangEditor)) {
return;
}
final ErlangEditor editor = (ErlangEditor) p;
IErlModule module;
try {
module = ErlangEngine.getInstance().getModel().findModule(moduleName);
final IErlFunction f = module.findFunction(new ErlangFunction(fs.getLabel(), fs.getArity()));
editor.setSelection(f);
} catch (final ErlModelException e) {
ErlLogger.error(e);
}
} else {
// disabled
}
}
use of org.erlide.engine.model.erlang.ErlangFunction in project erlide_eclipse by erlang.
the class FunctionStats method getLineStart.
/**
* First line of the function
*
* @return
*/
public int getLineStart() {
if (lineStart != 0) {
return lineStart;
}
final String mName = ((StatsTreeObject) getParent()).getLabel();
IErlModule m;
try {
m = ErlangEngine.getInstance().getModel().findModule(mName);
final IErlFunction f = m.findFunction(new ErlangFunction(getLabel(), getArity()));
lineStart = f.getLineStart();
} catch (final ErlModelException e) {
ErlLogger.error(e);
}
return lineStart;
}
use of org.erlide.engine.model.erlang.ErlangFunction in project erlide_eclipse by erlang.
the class ModelInternalUtils method getImportsAsList.
@Override
public List<OtpErlangObject> getImportsAsList(final IErlModule mod) {
if (mod == null) {
return ModelInternalUtils.NO_IMPORTS;
}
final Collection<IErlImport> imports = mod.getImports();
if (imports.isEmpty()) {
return ModelInternalUtils.NO_IMPORTS;
}
final List<OtpErlangObject> result = new ArrayList<>(imports.size());
for (final IErlImport i : imports) {
final Collection<ErlangFunction> functions = i.getFunctions();
final OtpErlangObject[] funsT = new OtpErlangObject[functions.size()];
int j = 0;
for (final ErlangFunction f : functions) {
funsT[j] = f.getNameArityTuple();
j++;
}
final OtpErlangTuple modFunsT = new OtpErlangTuple(new OtpErlangObject[] { new OtpErlangAtom(i.getImportModule()), new OtpErlangList(funsT) });
result.add(modFunsT);
}
return result;
}
use of org.erlide.engine.model.erlang.ErlangFunction in project erlide_eclipse by erlang.
the class OpenUtils method findExternalCallOrType.
private IErlElement findExternalCallOrType(final IErlModule module, final OpenResult res, final IErlProject project, final IErlElement element, final IErlElementLocator.Scope scope) throws CoreException {
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
if (isTypeDefOrRecordDef(element, res)) {
return modelFindService.findTypeDef(model, project, module, res.getName(), res.getFun(), res.getPath(), scope);
}
final IErlFunction result = modelFindService.findFunction(model, project, module, res.getName(), res.getPath(), res.getFunction(), scope);
if (result != null) {
return result;
}
return modelFindService.findFunction(model, project, module, res.getName(), res.getPath(), new ErlangFunction(res.getFun(), ErlangFunction.ANY_ARITY), scope);
}
Aggregations