private void printMethod(final IMethodCoverage method, final boolean more) { final String desc = String.format("+- method %s%s", method.getName(), method.getDesc()); printDetails(desc, method); for (int nr = method.getFirstLine(); nr <= method .getLastLine(); nr++) { printLine(method.getLine(nr), nr, more ? "| " : " "); } }
private void check(final IMethodCoverage method, final String className) { final String name = names.getQualifiedMethodName(className, method.getName(), method.getDesc(), method.getSignature()); checkRules(method, methodRules, "method", name); }
public static List<Integer> getListOfCountForCounterFunction(IClassCoverage coverage, Function<ICounter, Integer> counterGetter) { return coverage.getMethods() .stream() .filter(iMethodCoverage -> !"<clinit>".equals(iMethodCoverage.getName())) .flatMap(iMethodCoverage -> IntStream.range(iMethodCoverage.getFirstLine(), iMethodCoverage.getLastLine() + 1) .mapToObj(iMethodCoverage::getLine) .map(ILine::getInstructionCounter) .map(counterGetter) ).collect(Collectors.toList()); }
/** * Creates a 'method' element. * * @param coverage * method coverage node to write out * @return 'method' element * @throws IOException * in case of problems with the underlying output */ public ReportElement method(final IMethodCoverage coverage) throws IOException { final ReportElement element = namedElement("method", coverage.getName()); element.attr("desc", coverage.getDesc()); final int line = coverage.getFirstLine(); if (line != -1) { element.attr("line", line); } return element; }
if ("<clinit>".equals(methodCov.getName())) return "static {...}"; if ("<init>".equals(methodCov.getName())) { if (isAnonymous(classCov.getName())) { return "{...}"; sb.append(name.replace('$', '.')); } else { sb.append(methodCov.getName()); final Type[] arguments = Type.getArgumentTypes(methodCov.getDesc()); boolean comma = false; for(final Type arg : arguments) {
public String getLink(final ReportOutputFolder base) { if (sourcePage == null) { return null; } final String link = sourcePage.getLink(base); final int first = node.getFirstLine(); return first != ISourceNode.UNKNOWN_LINE ? link + "#L" + first : link; }
private void resolveMethods(final IType type) { IClassCoverage classCoverage = (IClassCoverage) getCoverageFor(type); if (classCoverage == null) { return; } try { MethodLocator locator = new MethodLocator(type); for (IMethodCoverage methodCoverage : classCoverage.getMethods()) { final IMethod method = locator.findMethod(methodCoverage.getName(), methodCoverage.getDesc()); if (method != null) { coveragemap.put(method, methodCoverage); } else { TRACER .trace( "Method not found in Java model: {0}.{1}{2}", type.getFullyQualifiedName(), methodCoverage.getName(), methodCoverage.getDesc()); //$NON-NLS-1$ } } } catch (JavaModelException e) { TRACER.trace("Error while creating method locator for {0}: {1}", type //$NON-NLS-1$ .getFullyQualifiedName(), e); } } }
@Override public void render() throws IOException { for (final IMethodCoverage m : getNode().getMethods()) { final String label = context.getLanguageNames().getMethodName( getNode().getName(), m.getName(), m.getDesc(), m.getSignature()); addItem(new MethodItem(m, label, sourcePage)); } super.render(); }