org.jacoco.core.analysis.Analyzer.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中org.jacoco.core.analysis.Analyzer.<init>()方法的一些代码示例,展示了Analyzer.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Analyzer.<init>()方法的具体详情如下:
包路径:org.jacoco.core.analysis.Analyzer
类名称:Analyzer
方法名:<init>

Analyzer.<init>介绍

[英]Creates a new analyzer reporting to the given output.
[中]创建报告给定输出的新分析器。

代码示例

代码示例来源:origin: org.codehaus.sonar-plugins.java/java-jacoco

private CoverageBuilder analyze(ExecutionDataStore executionDataStore) {
 CoverageBuilder coverageBuilder = new CoverageBuilder();
 Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder);
 for (File classFile : classFilesCache.values()) {
  analyzeClassFile(analyzer, classFile);
 }
 return coverageBuilder;
}

代码示例来源:origin: Stratio/sonar-scala-plugin

private CoverageBuilder analyze(ExecutionDataStore executionDataStore) {
  CoverageBuilder coverageBuilder = new CoverageBuilder();
  Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder);
  java.io.File binariesDir = new File(fileSystem.baseDir() + "/target/classes");
  if (binariesDir.exists()) {
    analyzeAll(analyzer, binariesDir);
  }
  return coverageBuilder;
}

代码示例来源:origin: eu.stamp-project/test-runner

private void collectForParametrizedTest(String testMethodName) {
  final CoverageBuilder coverageBuilder = new CoverageBuilder();
  final Analyzer analyzer = new Analyzer(this.internalCoverage.getExecutionData(), coverageBuilder);
  try {
    analyzer.analyzeAll(new File(this.internalCoverage.getClassesDirectory()));
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  if (!this.coveragesPerMethodName.containsKey(testMethodName)) {
    this.coveragesPerMethodName.put(testMethodName, new ArrayList<>());
  }
  coverageBuilder.getClasses()
      .forEach(classCoverage ->
          this.coveragesPerMethodName.get(testMethodName)
              .add(classCoverage)
      );
}

代码示例来源:origin: eu.stamp-project/test-runner

@Override
public void collectData(ExecutionDataStore executionData, String classesDirectory) {
  final CoverageBuilder coverageBuilder = new CoverageBuilder();
  final Analyzer analyzer = new Analyzer(executionData, coverageBuilder);
  try {
    analyzer.analyzeAll(new File(classesDirectory));

代码示例来源:origin: org.codehaus.sonar-plugins.java/sonar-jacoco-plugin

private CoverageBuilder analyze2(ExecutionDataStore executionDataStore) {
 CoverageBuilder coverageBuilder = new CoverageBuilder();
 Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder);
 for (File binaryDir : fileSystem.binaryDirs()) {
  for (ExecutionData data : executionDataStore.getContents()) {
   String vmClassName = data.getName();
   String classFileName = vmClassName.replace('.', '/') + ".class";
   File classFile = new File(binaryDir, classFileName);
   if (classFile.isFile()) {
    try {
     analyzer.analyzeAll(classFile);
    } catch (Exception e) {
     JaCoCoUtils.LOG.warn("Exception during analysis of file " + classFile.getAbsolutePath(), e);
    }
   }
  }
 }
 return coverageBuilder;
}

代码示例来源:origin: org.codehaus.sonar-plugins.java/sonar-jacoco-plugin

private CoverageBuilder analyze(ExecutionDataStore executionDataStore) {
 CoverageBuilder coverageBuilder = new CoverageBuilder();
 Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder);
 for (File binaryDir : fileSystem.binaryDirs()) {
  analyzeAll(analyzer, binaryDir);
 }
 return coverageBuilder;
}

代码示例来源:origin: jenkinsci/jacoco-plugin

private IBundleCoverage analyzeStructure() throws IOException {
  File classDirectory = new File(classDir.getRemote());
  final CoverageBuilder coverageBuilder = new CoverageBuilder();
  final Analyzer analyzer = new Analyzer(executionDataStore,
      coverageBuilder);
  analyzer.analyzeAll(classDirectory);
  return coverageBuilder.getBundle(name);
}
public IBundleCoverage loadBundleCoverage() throws IOException {

代码示例来源:origin: org.codehaus.sonar-plugins.java/java-jacoco

private CoverageBuilder analyze2(ExecutionDataStore executionDataStore) {
 CoverageBuilder coverageBuilder = new CoverageBuilder();
 Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder);
 for (ExecutionData data : executionDataStore.getContents()) {
  String vmClassName = data.getName();
  File classFile = classFilesCache.get(vmClassName);
  if (classFile != null) {
   analyzeClassFile(analyzer, classFile);
  }
 }
 return coverageBuilder;
}

代码示例来源:origin: org.jacoco/org.jacoco.cli

@Override
public int execute(final PrintWriter out, final PrintWriter err)
    throws IOException {
  if (classfiles.isEmpty()) {
    out.println("[WARN] No class files provided.");
  } else {
    final Analyzer analyzer = new Analyzer(new ExecutionDataStore(),
        new Printer(out));
    for (final File file : classfiles) {
      analyzer.analyzeAll(file);
    }
  }
  return 0;
}

代码示例来源:origin: SonarSource/sonar-java

/**
 * Caller must guarantee that {@code classFiles} are actually class file.
 */
public CoverageBuilder analyzeFiles(ExecutionDataStore executionDataStore, Collection<File> classFiles) {
 CoverageBuilder coverageBuilder = new CoverageBuilder();
 Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder);
 for (File classFile : classFiles) {
  analyzeClassFile(analyzer, classFile);
 }
 logNoMatchClasses(coverageBuilder.getNoMatchClasses());
 return coverageBuilder;
}

代码示例来源:origin: rohanpadhye/jqf

public void jacocoCheckpoint(File classFile, File csvDir) {
  int idx = nextFileIdx;
  csvDir.mkdirs();
  try {
    // Get exec data by dynamically calling RT.getAgent().getExecutionData()
    Class RT = Class.forName("org.jacoco.agent.rt.RT");
    Method getAgent = RT.getMethod("getAgent");
    Object agent = getAgent.invoke(null);
    Method dump = agent.getClass().getMethod("getExecutionData", boolean.class);
    byte[] execData = (byte[]) dump.invoke(agent, false);
    // Analyze exec data
    ExecFileLoader loader = new ExecFileLoader();
    loader.load(new ByteArrayInputStream(execData));
    final CoverageBuilder builder = new CoverageBuilder();
    Analyzer analyzer = new Analyzer(loader.getExecutionDataStore(), builder);
    analyzer.analyzeAll(classFile);
    // Generate CSV
    File csv = new File(csvDir, String.format("cov-%05d.csv", idx));
    try (FileOutputStream out = new FileOutputStream(csv)) {
      IReportVisitor coverageVisitor = new CSVFormatter().createVisitor(out);
      coverageVisitor.visitBundle(builder.getBundle("JQF"), null);
      coverageVisitor.visitEnd();
      out.flush();
    }
  } catch (Exception e) {
    System.err.println(e);
  }
}

代码示例来源:origin: jenkinsci/jacoco-plugin

final Analyzer analyzer = new Analyzer(executionDataStore,
    coverageBuilder);

代码示例来源:origin: org.jacoco/org.jacoco.cli

private IBundleCoverage analyze(final ExecutionDataStore data,
    final PrintWriter out) throws IOException {
  final CoverageBuilder builder = new CoverageBuilder();
  final Analyzer analyzer = new Analyzer(data, builder);
  for (final File f : classfiles) {
    analyzer.analyzeAll(f);
  }
  printNoMatchWarning(builder.getNoMatchClasses(), out);
  return builder.getBundle(name);
}

代码示例来源:origin: pmayweg/sonar-groovy

/**
 * Caller must guarantee that {@code classFiles} are actually class file.
 */
public CoverageBuilder analyzeFiles(ExecutionDataStore executionDataStore, Collection<File> classFiles) {
 CoverageBuilder coverageBuilder = new CoverageBuilder();
 if (useCurrentBinaryFormat) {
  Analyzer analyzer = new Analyzer(executionDataStore, coverageBuilder);
  for (File classFile : classFiles) {
   analyzeClassFile(analyzer, classFile);
  }
 } else {
  org.jacoco.previous.core.analysis.Analyzer analyzer = new org.jacoco.previous.core.analysis.Analyzer(executionDataStore, coverageBuilder);
  for (File classFile : classFiles) {
   analyzeClassFile(analyzer, classFile);
  }
 }
 return coverageBuilder;
}

代码示例来源:origin: eclipse/eclemma

private AnalyzedNodes analyzeExternal(final IPackageFragmentRoot root)
  throws CoreException {
 IPath location = null;
 try {
  location = root.getPath();
  AnalyzedNodes nodes = cache.get(location);
  if (nodes != null) {
   return nodes;
  }
  final CoverageBuilder builder = new CoverageBuilder();
  final Analyzer analyzer = new Analyzer(executiondata, builder);
  new ResourceTreeWalker(analyzer).walk(location);
  nodes = new AnalyzedNodes(builder.getClasses(), builder.getSourceFiles());
  cache.put(location, nodes);
  return nodes;
 } catch (Exception e) {
  throw new CoreException(EclEmmaStatus.BUNDLE_ANALYSIS_ERROR.getStatus(
    root.getElementName(), location, e));
 }
}

代码示例来源:origin: eclipse/eclemma

private AnalyzedNodes analyzeInternal(final IPackageFragmentRoot root)
  throws CoreException {
 IResource location = null;
 try {
  location = getClassfilesLocation(root);
  if (location == null) {
   TRACER.trace("No class files found for package fragment root {0}", //$NON-NLS-1$
     root.getPath());
   return AnalyzedNodes.EMPTY;
  }
  AnalyzedNodes nodes = cache.get(location);
  if (nodes != null) {
   return nodes;
  }
  final CoverageBuilder builder = new CoverageBuilder();
  final Analyzer analyzer = new Analyzer(executiondata, builder);
  new ResourceTreeWalker(analyzer).walk(location);
  nodes = new AnalyzedNodes(builder.getClasses(), builder.getSourceFiles());
  cache.put(location, nodes);
  return nodes;
 } catch (Exception e) {
  throw new CoreException(EclEmmaStatus.BUNDLE_ANALYSIS_ERROR.getStatus(
    root.getElementName(), location, e));
 }
}

代码示例来源:origin: com.android.tools.build/gradle-core

final Analyzer analyzer = new Analyzer(executionDataStore, builder);

相关文章