Search in sources :

Example 1 with SourceLineCounter

use of com.intellij.rt.coverage.instrumentation.SourceLineCounter in project intellij-community by JetBrains.

the class SourceLineCounterUtil method collectNonCoveredClassInfo.

public static boolean collectNonCoveredClassInfo(final PackageAnnotator.ClassCoverageInfo classCoverageInfo, final PackageAnnotator.PackageCoverageInfo packageCoverageInfo, byte[] content, final boolean excludeLines, final PsiClass psiClass) {
    if (content == null)
        return false;
    ClassReader reader = new ClassReader(content, 0, content.length);
    SourceLineCounter counter = new SourceLineCounter(null, excludeLines, null);
    reader.accept(counter, 0);
    classCoverageInfo.totalLineCount += counter.getNSourceLines();
    packageCoverageInfo.totalLineCount += counter.getNSourceLines();
    for (Object nameAndSig : counter.getMethodsWithSourceCode()) {
        if (!PackageAnnotator.isGeneratedDefaultConstructor(psiClass, (String) nameAndSig)) {
            classCoverageInfo.totalMethodCount++;
            packageCoverageInfo.totalMethodCount++;
        }
    }
    if (!counter.isInterface()) {
        packageCoverageInfo.totalClassCount++;
    }
    return !counter.isInterface();
}
Also used : ClassReader(org.jetbrains.org.objectweb.asm.ClassReader) SourceLineCounter(com.intellij.rt.coverage.instrumentation.SourceLineCounter)

Example 2 with SourceLineCounter

use of com.intellij.rt.coverage.instrumentation.SourceLineCounter in project intellij-community by JetBrains.

the class SourceLineCounterUtil method collectSrcLinesForUntouchedFiles.

public static void collectSrcLinesForUntouchedFiles(final List<Integer> uncoveredLines, byte[] content, final boolean excludeLines) {
    final ClassReader reader = new ClassReader(content);
    final SourceLineCounter collector = new SourceLineCounter(null, excludeLines, null);
    reader.accept(collector, 0);
    final TIntObjectHashMap lines = collector.getSourceLines();
    lines.forEachKey(new TIntProcedure() {

        public boolean execute(int line) {
            line--;
            uncoveredLines.add(line);
            return true;
        }
    });
}
Also used : TIntProcedure(gnu.trove.TIntProcedure) TIntObjectHashMap(gnu.trove.TIntObjectHashMap) ClassReader(org.jetbrains.org.objectweb.asm.ClassReader) SourceLineCounter(com.intellij.rt.coverage.instrumentation.SourceLineCounter)

Aggregations

SourceLineCounter (com.intellij.rt.coverage.instrumentation.SourceLineCounter)2 ClassReader (org.jetbrains.org.objectweb.asm.ClassReader)2 TIntObjectHashMap (gnu.trove.TIntObjectHashMap)1 TIntProcedure (gnu.trove.TIntProcedure)1