Package de.tobject.findbugs.properties

Examples of de.tobject.findbugs.properties.DetectorValidator


    public static synchronized void applyCustomDetectors(boolean force) {
        if(customDetectorsInitialized && !force) {
            return;
        }
        customDetectorsInitialized = true;
        DetectorValidator validator = new DetectorValidator();
        final SortedSet<String> detectorPaths = new TreeSet<String>();
        SortedMap<String, String> contributedDetectors = DetectorsExtensionHelper.getContributedDetectors();
        UserPreferences corePreferences = getCorePreferences(null, false);
        detectorPaths.addAll(corePreferences.getCustomPlugins(true));
        if(DEBUG) {
            dumpClassLoader(FindbugsPlugin.class);
            dumpClassLoader(Plugin.class);
            System.out.println("applyCustomDetectors - going to add " + detectorPaths.size() + " plugin urls...");
            for (String url : detectorPaths) {
                System.out.println("\t" + url);
            }
        }

        // 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);
            }
View Full Code Here

TOP

Related Classes of de.tobject.findbugs.properties.DetectorValidator

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.