@Override public String toString() { String s = "All reporting detectors"; if (plugin != null) { s += " in plugin " + plugin.getPluginId(); } return s; } }
@Override public String toString() { if (plugin == null) { return String.format("PluginLoader(%s)", loadedFrom); } return String.format("PluginLoader(%s, %s)", plugin.getPluginId(), loadedFrom); }
@CheckForNull public Boolean getPluginStatus(Plugin plugin) { return enabledPlugins.get(plugin.getPluginId()); }
public static synchronized @CheckForNull Plugin getByPluginId(String name) { if(name == null) { return null; } for(Plugin plugin : allPlugins.values()) { // the second part is questionable, as this may lead to id collisions if (name.equals(plugin.getPluginId()) /*|| name.equals(plugin.getShortPluginId())*/) { return plugin; } } return null; }
public static synchronized Collection<String> getAllPluginIds() { ArrayList<String> result = new ArrayList<>(); for(Plugin p : allPlugins.values()) { result.add(p.getPluginId()); } return result; }
public static synchronized void removeCustomPlugin(Plugin plugin) { Set<Entry<URI, Plugin>> entrySet = Plugin.allPlugins.entrySet(); for (Entry<URI, Plugin> entry : entrySet) { if(entry.getValue() == plugin) { Plugin.allPlugins.remove(entry.getKey()); PluginLoader.loadedPluginIds.remove(plugin.getPluginId()); break; } } DetectorFactoryCollection.instance().unLoadPlugin(plugin); }
/** * Loads the given plugin and enables it for the given project. */ public static Plugin loadCustomPlugin(URL urlString, @CheckForNull Project project) throws PluginException { Plugin plugin = addCustomPlugin(urlString); if (project != null) { project.setPluginStatusTrinary(plugin.getPluginId(), true); } return plugin; }
private void setGlobalOptions() { globalOptions.clear(); globalOptionsSetter.clear(); for(Plugin p : plugins()) { if (p.isGloballyEnabled()) { for(Map.Entry<String, String> e : p.getMyGlobalOptions().entrySet()) { String key = e.getKey(); String value = e.getValue(); String oldValue = globalOptions.get(key); if (oldValue != null) { if (oldValue.equals(value)) { continue; } Plugin oldP = globalOptionsSetter.get(key); throw new RuntimeException( "Incompatible global options for " + key + "; conflict between " + oldP.getPluginId() + " and " + p.getPluginId()); } globalOptions.put(key, value); globalOptionsSetter.put(key, p); } } } }
private void appendDetectorsToPass(Collection<DetectorFactory> detectorSet, AnalysisPass pass) { DetectorFactory[] unassignedList = detectorSet.toArray(new DetectorFactory[detectorSet.size()]); Arrays.sort(unassignedList, (a, b) -> { // Sort first by plugin id... int cmp = a.getPlugin().getPluginId().compareTo(b.getPlugin().getPluginId()); if (cmp != 0) { return cmp; } // Then by order specified in plugin descriptor return a.getPositionSpecifiedInPluginDescriptor() - b.getPositionSpecifiedInPluginDescriptor(); }); for (DetectorFactory factory : unassignedList) { appendToPass(factory, pass); } }
} catch (InstantiationException e) { IOException ioe = new IOException("Could not create analysis engine registrar for plugin " + plugin.getPluginId()); ioe.initCause(e); throw ioe; } catch (IllegalAccessException e) { IOException ioe = new IOException("Could not create analysis engine registrar for plugin " + plugin.getPluginId()); ioe.initCause(e); throw ioe;
private Plugin init() throws PluginException { if (DEBUG) { System.out.println("Loading plugin from " + loadedFrom); } // Plugin descriptor (a.k.a, "findbugs.xml"). Defines // the bug detectors and bug patterns that the plugin provides. Document pluginDescriptor = getPluginDescriptor(); List<Document> messageCollectionList = getMessageDocuments(); Plugin constructedPlugin = constructMinimalPlugin(pluginDescriptor, messageCollectionList); // Success! if (DEBUG) { System.out.println("Loaded " + constructedPlugin.getPluginId() + " from " + loadedFrom); } return constructedPlugin; }
@CheckReturnValue private Project createProject(Path[] files) { final Project project = new Project(); project.setProjectName(getClass().getSimpleName()); if (PLUGIN_JAR != null) { try { String pluginId = Plugin.addCustomPlugin(PLUGIN_JAR.toURI()).getPluginId(); project.setPluginStatusTrinary(pluginId, Boolean.TRUE); } catch (PluginException e) { throw new AssertionError("Failed to load plugin", e); } } for (Path file : files) { project.addFile(file.toAbsolutePath().toString()); } for (Path auxClasspathEntry : auxClasspathEntries) { project.addAuxClasspathEntry(auxClasspathEntry.toAbsolutePath().toString()); } return project; }
DetectorFactoryCollection.instance(); for(Plugin p : Plugin.getAllPlugins()) { LOG.info("Plugin: {}", p.getPluginId()); LOG.info(" description: {}", p.getShortDescription()); LOG.info(" provider: {}", p.getProvider());
String pluginId = pluginLoader.getPlugin().getPluginId(); assert pluginLoader.hasParent(); String parentid = pluginLoader.parentId;
void loadPlugin(Plugin plugin) { if (FindBugs.DEBUG) { System.out.println("Loading " + plugin.getPluginId()); } pluginByIdMap.put(plugin.getPluginId(), plugin); setGlobalOptions(); // Register all of the detectors that this plugin contains for (DetectorFactory factory : plugin.getDetectorFactories()) { registerDetector(factory); } for (BugCategory bugCategory : plugin.getBugCategories()) { registerBugCategory(bugCategory); } // Register the BugPatterns for (BugPattern bugPattern : plugin.getBugPatterns()) { registerBugPattern(bugPattern); } // Register the BugCodes for (BugCode bugCode : plugin.getBugCodes()) { registerBugCode(bugCode); } }
plugin.getPluginId(), plugin.getVersion(), plugin.getPluginLoader().getURL()); if (plugin.isCorePlugin()) { LOG.info(" is core plugin"); LOG.info(" has parent plugin {}", parent.getPluginId());
/** * Add a Plugin whose Detectors should be added to the execution plan. */ public void addPlugin(Plugin plugin) throws OrderingConstraintException { if (DEBUG) { System.out.println("Adding plugin " + plugin.getPluginId() + " to execution plan"); } pluginList.add(plugin); // Add ordering constraints copyTo(plugin.interPassConstraintIterator(), interPassConstraintList); copyTo(plugin.intraPassConstraintIterator(), intraPassConstraintList); // Add detector factories for (DetectorFactory factory : plugin.getDetectorFactories()) { if (DEBUG) { System.out.println(" Detector factory " + factory.getShortName()); } if (factoryMap.put(factory.getFullName(), factory) != null) { throw new OrderingConstraintException("Detector " + factory.getFullName() + " is defined by more than one plugin"); } } }
Plugin plugin = i.next(); if (DEBUG) { System.out.println("Adding plugin " + plugin.getPluginId() + " to execution plan");
void unLoadPlugin(Plugin plugin) { pluginByIdMap.remove(plugin.getPluginId()); setGlobalOptions(); for (DetectorFactory factory : plugin.getDetectorFactories()) { unRegisterDetector(factory); } for (BugCategory bugCategory : plugin.getBugCategories()) { unRegisterBugCategory(bugCategory); } for (BugPattern bugPattern : plugin.getBugPatterns()) { unRegisterBugPattern(bugPattern); } for (BugCode bugCode : plugin.getBugCodes()) { unRegisterBugCode(bugCode); } }
+ "</BugCollection>")); assertEquals(1, bc.getCollection().size()); assertEquals("edu.umd.cs.findbugs.plugins.core", DetectorFactoryCollection.instance().getCorePlugin().getPluginId()); BugInstance bug = bc.getCollection().iterator().next(); assertEquals("MS_MUTABLE_ARRAY", bug.getBugPattern().getType());