edu.umd.cs.findbugs.classfile.Global.setAnalysisCacheForCurrentThread()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(90)

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

Global.setAnalysisCacheForCurrentThread介绍

[英]Set the analysis cache for the current thread. This should be called before any detectors or analyses that need the cache are used.
[中]为当前线程设置分析缓存。在使用任何需要缓存的检测器或分析之前,应调用此函数。

代码示例

代码示例来源:origin: spotbugs/spotbugs

@After
public void tearDown() {
  Global.setAnalysisCacheForCurrentThread(null);
}

代码示例来源:origin: spotbugs/spotbugs

@Before
public void setUp () {
  Global.setAnalysisCacheForCurrentThread(new NoopAnalysisCache());
}

代码示例来源:origin: spotbugs/spotbugs

/**
 * Create the analysis cache object and register it for current execution thread.
 * <p>
 * This method is protected to allow clients override it and possibly reuse
 * some previous analysis data (for Eclipse interactive re-build)
 *
 * @throws IOException
 *             if error occurs registering analysis engines in a plugin
 */
protected IAnalysisCache createAnalysisCache() throws IOException {
  IAnalysisCache analysisCache = ClassFactory.instance().createAnalysisCache(classPath, bugReporter);
  // Register the "built-in" analysis engines
  registerBuiltInAnalysisEngines(analysisCache);
  // Register analysis engines in plugins
  registerPluginAnalysisEngines(detectorFactoryCollection, analysisCache);
  // Install the DetectorFactoryCollection as a database
  analysisCache.eagerlyPutDatabase(DetectorFactoryCollection.class, detectorFactoryCollection);
  Global.setAnalysisCacheForCurrentThread(analysisCache);
  return analysisCache;
}
/**

代码示例来源:origin: com.google.code.findbugs/findbugs

/**
 * Create the analysis cache object and register it for current execution thread.
 * <p>
 * This method is protected to allow clients override it and possibly reuse
 * some previous analysis data (for Eclipse interactive re-build)
 *
 * @throws IOException
 *             if error occurs registering analysis engines in a plugin
 */
protected IAnalysisCache createAnalysisCache() throws IOException {
  IAnalysisCache analysisCache = ClassFactory.instance().createAnalysisCache(classPath, bugReporter);
  // Register the "built-in" analysis engines
  registerBuiltInAnalysisEngines(analysisCache);
  // Register analysis engines in plugins
  registerPluginAnalysisEngines(detectorFactoryCollection, analysisCache);
  // Install the DetectorFactoryCollection as a database
  analysisCache.eagerlyPutDatabase(DetectorFactoryCollection.class, detectorFactoryCollection);
  Global.setAnalysisCacheForCurrentThread(analysisCache);
  return analysisCache;
}
/**

代码示例来源:origin: com.youdevise/test-driven-detectors4findbugs

private static void setUpStaticDependenciesWithinFindBugs(BugReporter bugReporter) throws Exception {
  bugReporter.setPriorityThreshold(Priorities.LOW_PRIORITY);
  ClassPathImpl classPath = new ClassPathImpl();
  IAnalysisCache analysisCache = ClassFactory.instance().createAnalysisCache(classPath, bugReporter);
  new ClassContextClassAnalysisEngine().registerWith(analysisCache);
  new edu.umd.cs.findbugs.classfile.engine.asm.EngineRegistrar().registerAnalysisEngines(analysisCache);
  new edu.umd.cs.findbugs.classfile.engine.bcel.EngineRegistrar().registerAnalysisEngines(analysisCache);
  new edu.umd.cs.findbugs.classfile.engine.EngineRegistrar().registerAnalysisEngines(analysisCache);
  registerUserDefined(analysisCache);
  Global.setAnalysisCacheForCurrentThread(analysisCache);
  ICodeBaseLocator codeBaseLocator = new FilesystemCodeBaseLocator(".");
  ICodeBase codeBase = new DirectoryCodeBase(codeBaseLocator, new File(CODEBASE_DIRECTORY));
  codeBase.setApplicationCodeBase(true);
  classPath.addCodeBase(codeBase);
  addAuxCodeBasesFromClassPath(classPath);
  IClassFactory classFactory = ClassFactory.instance();
  IClassPathBuilder builder = classFactory.createClassPathBuilder(bugReporter);
  builder.addCodeBase(codeBaseLocator, true);
  builder.scanNestedArchives(true);
  IClassPathBuilderProgress progress = new NoOpFindBugsProgress();
  builder.build(classPath, progress);
  List<ClassDescriptor> appClassList = builder.getAppClassList();
  AnalysisCacheToAnalysisContextAdapter analysisContext = new AnalysisCacheToAnalysisContextAdapter();
  AnalysisContext.setCurrentAnalysisContext(analysisContext);
  analysisContext.setAppClassList(appClassList);
  analysisContext.setFieldSummary(new FieldSummary());
}

相关文章