use of org.erlide.engine.model.ErlModelException in project erlide_eclipse by erlang.
the class OpenItemAction method openInEditor.
private IEditorPart openInEditor(final String name) {
// search
IErlModule module;
try {
module = ErlangEngine.getInstance().getModel().findModule(name);
} catch (final ErlModelException e1) {
e1.printStackTrace();
return null;
}
log.info(module.getFilePath());
final File fileToOpen = new File(module.getFilePath());
final IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
final IEditorPart p = IDE.openEditorOnFileStore(page, fileStore);
log.info(p.getClass());
return p;
} catch (final PartInitException e) {
ErlLogger.error(e);
return null;
}
}
use of org.erlide.engine.model.ErlModelException 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.ErlModelException in project erlide_eclipse by erlang.
the class CoverMainTab method createModuleArray.
private Object[] createModuleArray(final IErlProject p) {
Object[] array;
try {
final List<ProjectElement> res = new LinkedList<>();
final Collection<IErlModule> modules = p.getModules();
for (final IErlModule m : modules) {
final ProjectElement elem = new ProjectElement(m.getName(), ErlangElementImageProvider.getErlImageDescriptor(m, ErlangElementImageProvider.SMALL_ICONS).createImage());
res.add(elem);
}
array = res.toArray();
} catch (final ErlModelException e) {
array = new Object[0];
ErlLogger.error(e);
}
return array;
}
use of org.erlide.engine.model.ErlModelException 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.ErlModelException in project erlide_eclipse by erlang.
the class ErlFolder method buildStructure.
@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
final IErlModel model = ErlangEngine.getInstance().getModel();
final IContainer c = (IContainer) getResource();
try {
// FIXME this is general stuff -> model or model manager?
final IResource[] members = c.members();
for (final IResource resource : members) {
model.create(resource);
}
} catch (final CoreException e) {
throw new ErlModelException(new ErlModelStatus(ErlModelStatusConstants.CORE_EXCEPTION, e));
}
return true;
}
Aggregations