use of org.erlide.cover.views.model.FunctionStats in project erlide_eclipse by erlang.
the class HideCoverageAction method perform.
@Override
protected void perform(final StatsTreeObject selection) {
if (selection instanceof ModuleStats) {
final ModuleStats module = (ModuleStats) selection;
final String name = module.getLabel() + ".erl";
marker.removeAnnotationsFromFile(name);
} else if (selection instanceof FunctionStats) {
final FunctionStats fs = (FunctionStats) selection;
final ModuleStats module = (ModuleStats) fs.getParent();
final String name = module.getLabel() + ".erl";
log.info(fs.getLineStart());
log.info(fs.getLineEnd());
marker.removeAnnotationsFragment(name, fs.getLineStart(), fs.getLineEnd());
} else {
marker.clearAllAnnotations();
}
}
use of org.erlide.cover.views.model.FunctionStats in project erlide_eclipse by erlang.
the class HtmlReportAction method run.
@Override
public void run() {
log.info("html report!");
if (StatsTreeModel.getInstance().getRoot().getHtmlPath() == null) {
final IPath location = Activator.getDefault().getStateLocation().append(CoverConstants.REPORT_DIR);
final File dir = location.toFile();
if (!dir.exists() && !dir.mkdir()) {
CoverageHelper.reportError("Can not save results!");
return;
}
generateReportTree(StatsTreeModel.getInstance().getRoot(), dir.getAbsolutePath());
}
final ISelection selection = viewer.getSelection();
log.info(selection.getClass().getName());
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;
log.info(treeSelection.getFirstElement());
log.info(treeSelection.getFirstElement().getClass().getName());
log.info(treeSelection.getPaths());
final StatsTreeObject selObj = (StatsTreeObject) treeSelection.getFirstElement();
final BrowserDialog browser = new BrowserDialog(shell);
if (selObj instanceof FunctionStats) {
final ModuleStats module = (ModuleStats) selObj.getParent();
browser.setObject(module);
} else {
browser.setObject(selObj);
}
browser.open();
}
use of org.erlide.cover.views.model.FunctionStats in project erlide_eclipse by erlang.
the class ShowCoverageAction method perform.
@Override
protected void perform(final StatsTreeObject selection) {
if (selection instanceof ModuleStats) {
final ModuleStats module = (ModuleStats) selection;
final String name = module.getLabel() + ".erl";
if (ifMarkAnnotations(module)) {
module.couldBeMarked = true;
marker.addAnnotationsToFile(name);
}
} else if (selection instanceof FunctionStats) {
final FunctionStats fs = (FunctionStats) selection;
final ModuleStats module = (ModuleStats) fs.getParent();
final String name = module.getLabel() + ".erl";
if (ifMarkAnnotations(module)) {
log.info(fs.getLineStart());
log.info(fs.getLineEnd());
module.couldBeMarked = true;
marker.addAnnotationsFragment(name, fs.getLineStart(), fs.getLineEnd());
}
} else if (selection.equals(StatsTreeModel.getInstance().getRoot())) {
// TODO: check annotation tree, only if root mark all annotations
final Collection<ICoverageObject> col = selection.getModules();
for (final ICoverageObject module : col) {
if (ifMarkAnnotations((ModuleStats) module)) {
((ModuleStats) module).couldBeMarked = true;
} else {
((ModuleStats) module).couldBeMarked = false;
}
}
marker.addAnnotations();
} else {
final Collection<ICoverageObject> col = selection.getModules();
for (final ICoverageObject module : col) {
if (ifMarkAnnotations((ModuleStats) module)) {
final String name = module.getLabel() + ".erl";
((ModuleStats) module).couldBeMarked = true;
marker.addAnnotationsToFile(name);
}
}
}
}
use of org.erlide.cover.views.model.FunctionStats 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.cover.views.model.FunctionStats in project erlide_eclipse by erlang.
the class CoverEventHandler method prepFuncResults.
private void prepFuncResults(final OtpErlangList funcList, final ModuleStats stats) {
for (OtpErlangObject aFuncList : funcList) {
final OtpErlangTuple res = (OtpErlangTuple) aFuncList;
final FunctionStats func = new FunctionStats();
final String name = res.elementAt(1).toString();
final int arity = Integer.parseInt(res.elementAt(2).toString());
final int allLines = Integer.parseInt(res.elementAt(3).toString());
final int coveredLines = Integer.parseInt(res.elementAt(4).toString());
func.setLabel(name);
func.setLiniesCount(allLines);
func.setCoverCount(coveredLines);
func.setArity(arity);
stats.addChild(func.getLabel(), func);
}
}
Aggregations