use of org.erlide.cover.views.model.ModuleStats in project erlide_eclipse by erlang.
the class EditorTracker method addAnnotationsFragment.
/**
* Makrs coverage of fragment of a file, e.g. of a single function.
*
* @param fileName
* @param start
* @param end
*/
public void addAnnotationsFragment(final String fileName, final int start, final int end) {
final IEditorPart currentEditor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (currentEditor.getTitle().equals(fileName) && currentEditor instanceof ITextEditor && !currentEditor.isDirty()) {
final ModuleStats module = ModuleSet.get(fileName.replace(".erl", ""));
if (module == null || !module.couldBeMarked) {
return;
}
final List<LineResult> list = module.getLineResults();
final ITextEditor editor = (ITextEditor) currentEditor;
log.info(fileName);
for (final LineResult lr : list) {
if (lr.getLineNum() < start || end != -1 && lr.getLineNum() > end) {
continue;
}
if (!coverage.containsAnnotation(fileName, lr)) {
coverage.addAnnotation(fileName, lr, null);
}
markLine(editor, lr);
}
}
}
use of org.erlide.cover.views.model.ModuleStats in project erlide_eclipse by erlang.
the class CoverEventHandler method gotResults.
/**
* When coverage results came
*
* @param msg
* @return
*/
private boolean gotResults(final OtpErlangObject msg) {
if (msg instanceof OtpErlangTuple) {
final OtpErlangTuple resTuple = (OtpErlangTuple) msg;
if (resTuple.elementAt(0) instanceof OtpErlangAtom && ((OtpErlangAtom) resTuple.elementAt(0)).atomValue().equals(CoverEventHandler.COVER_RES)) {
final String moduleName = resTuple.elementAt(1).toString();
String htmlPath = resTuple.elementAt(2).toString();
htmlPath = htmlPath.substring(1, htmlPath.length() - 1);
final int allLines = Integer.parseInt(resTuple.elementAt(3).toString());
final int coveredLines = Integer.parseInt(resTuple.elementAt(4).toString());
final double percent = Double.parseDouble(resTuple.elementAt(5).toString());
log.info(String.format("Module %s %s %d %d %f", moduleName, htmlPath, allLines, coveredLines, percent));
final ModuleStats moduleStats = new ModuleStats();
moduleStats.setLabel(moduleName);
moduleStats.setHtmlPath(htmlPath);
moduleStats.setLiniesCount(allLines);
moduleStats.setCoverCount(coveredLines);
try {
final File file = new File(ErlangEngine.getInstance().getModel().findModule(moduleName).getFilePath());
moduleStats.setMd5(MD5Checksum.getMD5(file));
} catch (final Exception e) {
ErlLogger.error(e);
}
//
prepLineResults((OtpErlangList) resTuple.elementAt(6), moduleStats);
prepFuncResults((OtpErlangList) resTuple.elementAt(7), moduleStats);
addModuleToTree(moduleStats);
ModuleSet.add(moduleStats);
return true;
}
return false;
}
return false;
}
Aggregations