Package edu.umd.cs.findbugs

Examples of edu.umd.cs.findbugs.Plugin


                throw new IllegalArgumentException("Cannot find registered cloud for " + cloudId);
            }
        }
        // is the desired plugin disabled for this project (and/or globally)? if so, skip it.
        if (plugin != null) {
            Plugin fbplugin = Plugin.getByPluginId(plugin.getFindbugsPluginId());
            //noinspection PointlessBooleanExpression
            if (fbplugin != null && Boolean.FALSE.equals(project.getPluginStatus(fbplugin))) {
                plugin = null; // use default cloud below
            }
        }
View Full Code Here


        DetectorFactoryCollection detectorFactoryCollection = DetectorFactoryCollection.instance();

        ExecutionPlan execPlan = new ExecutionPlan();

        for (String pluginId : argv) {
            Plugin plugin = detectorFactoryCollection.getPluginById(pluginId);
            if (plugin != null) {
                execPlan.addPlugin(plugin);
            }
        }
View Full Code Here

        cloudSelector.addItem(null);
        String cloudId = project.getCloudId();

        for (CloudPlugin c : DetectorFactoryCollection.instance().getRegisteredClouds().values()) {
            String fbid = c.getFindbugsPluginId();
            Plugin plugin = Plugin.getByPluginId(fbid);
            if (plugin == null) {
                continue;
            }
            Boolean fbPluginStatus = project.getPluginStatus(plugin);
            if ((!c.isHidden() || c.getId().equals(cloudId)) && !Boolean.FALSE.equals(fbPluginStatus)) {
View Full Code Here

        try {
            fakeLoader = new PluginLoader(true, new URL("http://" + pluginId + ".findbugs.cs.umd.edu"));
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
        Plugin plugin = new Plugin(pluginId, version, releaseDate, fakeLoader,  true, false);
        plugin.setShortDescription("My Plugin");
        plugin.setUpdateUrl("http://example.com/update");
        return plugin;
    }
View Full Code Here

        boolean changed = pluginsAdded;
        pluginsAdded = false;
        List<String> enabledPlugins = new ArrayList<String>();
        List<String> disabledPlugins = new ArrayList<String>();
        for (Map.Entry<Plugin, EnabledSettings> entry : pluginEnabledStatus.entrySet()) {
            Plugin plugin = entry.getKey();
            EnabledSettings enabled = entry.getValue();
            if (project != null) {
                Boolean newSetting = enabled.project;
                Boolean existingSetting = project.getPluginStatus(plugin);
                boolean sameSettings = Objects.equals(existingSetting, newSetting);
                if (!sameSettings) {
                    project.setPluginStatusTrinary(plugin.getPluginId(), newSetting);
                    changed = true;
                }
            }
            if (enabled.global) {
                enabledPlugins.add(plugin.getPluginId());
            } else {
                disabledPlugins.add(plugin.getPluginId());
            }
            if (plugin.isGloballyEnabled() != enabled.global) {
                plugin.setGloballyEnabled(enabled.global);
                changed = true;
            }
        }

        if (changed && project != null) {
View Full Code Here

                if (retvalue == JFileChooser.APPROVE_OPTION) {
                    File f = chooser.getSelectedFile();
                    try {
                        // load and enable for project (if loaded)
                        Plugin plugin = Plugin.loadCustomPlugin(f, PreferencesFrame.this.getCurrentProject());

                        GUISaveState guiSaveState = GUISaveState.getInstance();
                        URL url = f.toURI().toURL();
                        // add to FBGUI custom plugins list
                        guiSaveState.addCustomPlugin(url);
                        // add to list of enabled plugins
                        guiSaveState.setPluginEnabled(plugin.getPluginId());
                        plugin.setGloballyEnabled(true);
                        guiSaveState.save();
                        pluginsAdded = true;
                        rebuildPluginCheckboxes();

                    } catch (PluginException | MalformedURLException e1) {
View Full Code Here

        }
    }

    private static void enablePlugins(Iterable<String> plugins, boolean enabled) {
        for (String pid : plugins) {
            Plugin plugin = Plugin.getByPluginId(pid);
            if (plugin != null) {
                if (!enabled && plugin.cannotDisable()) {
                    JOptionPane.showMessageDialog(null,
                            "Cannot disable plugin: " + plugin.getPluginId() + "\n" + plugin.getShortDescription(),
                            "Cannot disable plugin", JOptionPane.ERROR_MESSAGE);
                } else {
                    plugin.setGloballyEnabled(enabled);
                }
            }
        }
    }
View Full Code Here

        if (cls == null) {
            // Find the dataflow class from the plugin in which it was loaded

            DetectorFactoryCollection detectorFactoryCollection = analysisCache.getDatabase(DetectorFactoryCollection.class);
            for (Iterator<Plugin> i = detectorFactoryCollection.pluginIterator(); i.hasNext();) {
                Plugin plugin = i.next();

                try {
                    cls = asDataflowClass(plugin.getClassLoader().loadClass(dataflowClassName));
                    break;
                } catch (ClassNotFoundException e) {
                    assert true;
                }
View Full Code Here

        // disable custom plugins configured via properties, if they are already loaded
        Set<String> disabledPlugins = corePreferences.getCustomPlugins(false);
        Map<URI, Plugin> allPlugins = Plugin.getAllPluginsMap();
        for (Entry<URI, Plugin> entry : allPlugins.entrySet()) {
            Plugin fbPlugin = entry.getValue();
            String pluginId = fbPlugin.getPluginId();
            // ignore all custom plugins with the same plugin id as already loaded
            if(contributedDetectors.containsKey(pluginId)) {
                contributedDetectors.remove(pluginId);
                detectorPaths.remove(pluginId);
            }

            if (fbPlugin.isCorePlugin() || fbPlugin.isInitialPlugin()) {
                continue;
            }
            if (disabledPlugins.contains(entry.getKey().getPath())
                    || disabledPlugins.contains(pluginId)) {
                fbPlugin.setGloballyEnabled(false);
                Plugin.removeCustomPlugin(fbPlugin);
                if (DEBUG) {
                    System.out.println("Removed plugin: " + fbPlugin + " loaded from " + entry.getKey());
                }
            }
        }

        HashSet<Plugin> enabled = new HashSet<Plugin>();

        // adding FindBugs *Eclipse* plugins, key plugin id, value is path
        for (Entry<String, String> entry : contributedDetectors.entrySet()) {
            String pluginId = entry.getKey();
            String pluginPath = entry.getValue();
            URI uri = new File(pluginPath).toURI();
            if (disabledPlugins.contains(pluginId)
                    || disabledPlugins.contains(pluginPath)
                    || allPlugins.containsKey(uri)) {
                continue;
            }
            addCustomPlugin(enabled, uri);
        }

        // adding custom plugins configured via properties, but only if they are not loaded yet
        for (String path : detectorPaths) {
            // this is plugin id, so we can't use it as URL
            if(new Path(path).segmentCount() == 1) {
                continue;
            }
            URI uri = new File(path).toURI();
            if(allPlugins.containsKey(uri)) {
                continue;
            }
            ValidationStatus status = validator.validate(path);
            if (status.isOK()) {
                addCustomPlugin(enabled, uri);
            } else {
                getDefault().getLog().log(status);
            }
        }

        if (DEBUG) {
            System.out.println("applyCustomDetectors - there was " + detectorPaths.size()
                    + " extra FB plugin urls with " + enabled.size()
                    + " valid FB plugins and " + allPlugins.size()
                    + " total plugins registered by FB.");
            for (Entry<URI, Plugin> entry : allPlugins.entrySet()) {
                Plugin fbPlugin = entry.getValue();
                if (fbPlugin.isGloballyEnabled()) {
                    System.out.println("IS  enabled:\t" + fbPlugin.getPluginId());
                } else {
                    System.out.println("NOT enabled:\t" + fbPlugin.getPluginId());
                }
            }
        }
    }
View Full Code Here

        try {
            // bug 3117769 - we must provide our own classloader
            // to allow third-party plugins extend the classpath via
            // "Buddy" classloading
            // see also: Eclipse-BuddyPolicy attribute in MANIFEST.MF
            Plugin fbPlugin = Plugin.addCustomPlugin(uri, FindbugsPlugin.class.getClassLoader());
            if(fbPlugin != null) {
                // TODO line below required to enable this *optional* plugin
                // but it should be taken by FB core from the findbugs.xml,
                // which currently only works for *core* plugins only
                fbPlugin.setGloballyEnabled(true);
                enabled.add(fbPlugin);
            }
        } catch (PluginException e) {
            getDefault().logException(e, "Failed to load plugin for custom detector: " + uri);
        } catch (DuplicatePluginIdException e) {
View Full Code Here

TOP

Related Classes of edu.umd.cs.findbugs.Plugin

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.