Package org.jacoco.core.analysis

Examples of org.jacoco.core.analysis.ICoverageNode


    assertEquals("E",
        support.findStr(doc, "/html/body/table/tbody/tr[5]/td[1]"));
  }

  private ITableItem createItem(final String name, final int count) {
    final ICoverageNode node = new CoverageNodeImpl(ElementType.GROUP, name) {
      {
        this.classCounter = CounterImpl.getInstance(count, 0);
      }
    };
    return new ITableItem() {
      public String getLinkLabel() {
        return name;
      }

      public String getLink(ReportOutputFolder base) {
        return name + ".html";
      }

      public String getLinkStyle() {
        return Resources.getElementStyle(node.getElementType());
      }

      public ICoverageNode getNode() {
        return node;
      }
View Full Code Here


    assertTrue(column.getComparator().compare(i2, i1) > 0);
    doc.close();
  }

  private ITableItem createItem(final String name, final String link) {
    final ICoverageNode node = new CoverageNodeImpl(ElementType.GROUP, name);
    return new ITableItem() {
      public String getLinkLabel() {
        return name;
      }

      public String getLink(ReportOutputFolder base) {
        return link;
      }

      public String getLinkStyle() {
        return Resources.getElementStyle(node.getElementType());
      }

      public ICoverageNode getNode() {
        return node;
      }
View Full Code Here

    assertEquals(0, c.compare(i1, i1));
    doc.close();
  }

  private ITableItem createItem(final int missed, final int covered) {
    final ICoverageNode node = createNode(missed, covered);
    return new ITableItem() {
      public String getLinkLabel() {
        return "Foo";
      }

      public String getLink(ReportOutputFolder base) {
        return null;
      }

      public String getLinkStyle() {
        return Resources.getElementStyle(node.getElementType());
      }

      public ICoverageNode getNode() {
        return node;
      }
View Full Code Here

    };
    CoverageTools.addJavaCoverageListener(coverageListener);
  }

  public void decorate(Object element, IDecoration decoration) {
    final ICoverageNode coverage = CoverageTools.getCoverageInfo(element);
    if (coverage == null) {
      // no coverage data
      return;
    }
    // TODO obtain counter from preferences
    ICounter counter = coverage.getInstructionCounter();
    ImageDescriptor overlay = EclEmmaUIPlugin.getCoverageOverlay(counter
        .getCoveredRatio());
    decoration.addOverlay(overlay, IDecoration.TOP_LEFT);
    decoration.addSuffix(SUFFIX_FORMAT.format(Double.valueOf(counter
        .getCoveredRatio())));
View Full Code Here

      protected void measure(Event event, Object element) {
      }

      @Override
      protected void paint(Event event, Object element) {
        final ICoverageNode coverage = CoverageTools.getCoverageInfo(element);
        if (coverage != null) {
          final ICounter counter = coverage.getCounter(settings.getCounters());
          RedGreenBar.draw(event, column1.getColumn().getWidth(), counter,
              maxTotalCache.getMaxTotal(element));
        }
      }
    });
    sorter.addColumn(column1, COLUMN_RATIO);

    final TreeViewerColumn column2 = new TreeViewerColumn(viewer, SWT.RIGHT);
    column2.setLabelProvider(new CellLabelProvider() {

      @Override
      public void update(ViewerCell cell) {
        if (cell.getElement() == LOADING_ELEMENT) {
          cell.setText(""); //$NON-NLS-1$
        } else {
          cell.setText(cellTextConverter.getCovered(cell.getElement()));
        }
      }
    });
    sorter.addColumn(column2, COLUMN_COVERED);

    final TreeViewerColumn column3 = new TreeViewerColumn(viewer, SWT.RIGHT);
    column3.setLabelProvider(new CellLabelProvider() {

      @Override
      public void update(ViewerCell cell) {
        if (cell.getElement() == LOADING_ELEMENT) {
          cell.setText(""); //$NON-NLS-1$
        } else {
          cell.setText(cellTextConverter.getMissed(cell.getElement()));
        }
      }
    });
    sorter.addColumn(column3, COLUMN_MISSED);

    final TreeViewerColumn column4 = new TreeViewerColumn(viewer, SWT.RIGHT);
    column4.setLabelProvider(new CellLabelProvider() {

      @Override
      public void update(ViewerCell cell) {
        if (cell.getElement() == LOADING_ELEMENT) {
          cell.setText(""); //$NON-NLS-1$
        } else {
          cell.setText(cellTextConverter.getTotal(cell.getElement()));
        }
      }
    });
    sorter.addColumn(column4, COLUMN_TOTAL);

    viewer.addFilter(new ViewerFilter() {
      public boolean select(Viewer viewer, Object parentElement, Object element) {
        if (element == LOADING_ELEMENT) {
          return true;
        } else {
          final ICoverageNode c = CoverageTools.getCoverageInfo(element);
          if (c == null) {
            return false;
          }
          final ICounter instructions = c.getInstructionCounter();
          if (instructions.getTotalCount() == 0) {
            return false;
          }
          if (settings.getHideUnusedElements()
              && instructions.getCoveredCount() == 0) {
View Full Code Here

    return false;
  }

  private ISourceNode findSourceCoverageForElement(Object element) {
    // Do we have a coverage info for the editor input?
    ICoverageNode coverage = CoverageTools.getCoverageInfo(element);
    if (coverage instanceof ISourceNode) {
      return (ISourceNode) coverage;
    }
    return null;
  }
View Full Code Here

    column.getColumn().setWidth(convertWidthInCharsToPixels(width));
    column.setLabelProvider(labelProvider);
  }

  private Line[] getLines() {
    ICoverageNode c = CoverageTools.getCoverageInfo(getElement());
    if (c == null) {
      return new Line[0];
    } else {
      return new Line[] {
          new Line(UIMessages.CoveragePropertyPageInstructions_label,
              c.getInstructionCounter()),
          new Line(UIMessages.CoveragePropertyPageBranches_label,
              c.getBranchCounter()),
          new Line(UIMessages.CoveragePropertyPageLines_label,
              c.getLineCounter()),
          new Line(UIMessages.CoveragePropertyPageMethods_label,
              c.getMethodCounter()),
          new Line(UIMessages.CoveragePropertyPageTypes_label,
              c.getClassCounter()),
          new Line(UIMessages.CoveragePropertyPageComplexity_label,
              c.getComplexityCounter()) };
    }
  }
View Full Code Here

    IType[] arr = new IType[types.size()];
    return types.toArray(arr);
  }

  public ICoverageNode getCoverageFor(IJavaElement element) {
    final ICoverageNode coverage = coveragemap.get(element);
    if (coverage != null) {
      return coverage;
    }
    if (IJavaElement.METHOD == element.getElementType()) {
      resolveMethods((IType) element.getParent());
View Full Code Here

    // then find the coverage information from the current session
    IJavaModelCoverage mc = CoverageTools.getJavaModelCoverage();
    if (mc == null) {
      return null;
    } else {
      ICoverageNode coverage = mc.getCoverageFor((IJavaElement) object);
      if (adapterType.isInstance(coverage)) {
        return coverage;
      } else {
        return null;
      }
View Full Code Here

  }

  private int calculateMaxTotal(IJavaElement parent) {
    int max = 0;
    for (Object sibling : contentProvider.getChildren(parent)) {
      final ICoverageNode coverage = CoverageTools.getCoverageInfo(sibling);
      if (coverage != null) {
        max = Math.max(max, coverage.getCounter(settings.getCounters())
            .getTotalCount());
      }
    }
    return max;
  }
View Full Code Here

TOP

Related Classes of org.jacoco.core.analysis.ICoverageNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.