Search in sources :

Example 1 with Project

use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.

the class MainFrame method shouldDisplayIssue.

// @SuppressWarnings({ "SimplifiableIfStatement" })
boolean shouldDisplayIssue(BugInstance b) {
    Project project = getProject();
    Filter suppressionFilter = project.getSuppressionFilter();
    if (null == getBugCollection() || suppressionFilter.match(b)) {
        return false;
    }
    return viewFilter.show(b);
}
Also used : Project(edu.umd.cs.findbugs.Project) Filter(edu.umd.cs.findbugs.filter.Filter)

Example 2 with Project

use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.

the class MainFrame method redoAnalysis.

void redoAnalysis() {
    // / QQQ-TODO: new RuntimeException("Redo analysis called").printStackTrace();
    acquireDisplayWait();
    edu.umd.cs.findbugs.util.Util.runInDameonThread(() -> {
        try {
            Project project = getProject();
            BugCollection bc = BugLoader.redoAnalysisKeepComments(project);
            updateProjectAndBugCollection(bc);
            setProjectAndBugCollectionInSwingThread(project, bc);
        } finally {
            releaseDisplayWait();
        }
    });
}
Also used : Project(edu.umd.cs.findbugs.Project) SortedBugCollection(edu.umd.cs.findbugs.SortedBugCollection) BugCollection(edu.umd.cs.findbugs.BugCollection)

Example 3 with Project

use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.

the class MainFrame method updateTitle.

/**
 * Changes the title based on curProject and saveFile.
 */
public void updateTitle() {
    Project project = getProject();
    String name = project.getProjectName();
    if ((name == null || "".equals(name.trim())) && saveFile != null) {
        name = saveFile.getAbsolutePath();
    }
    if (name == null) {
        // Project.UNNAMED_PROJECT;
        name = "";
    }
    String oldTitle = this.getTitle();
    String newTitle = TITLE_START_TXT + ("".equals(name.trim()) ? "" : " - " + name);
    if (oldTitle.equals(newTitle)) {
        return;
    }
    this.setTitle(newTitle);
}
Also used : Project(edu.umd.cs.findbugs.Project)

Example 4 with Project

use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.

the class MainFrame method openBugCollection.

public void openBugCollection(SortedBugCollection bugs) {
    acquireDisplayWait();
    try {
        mainFrameLoadSaveHelper.prepareForFileLoad(null, null);
        Project project = bugs.getProject();
        project.setGuiCallback(guiCallback);
        BugLoader.addDeadBugMatcher(bugs);
        setProjectAndBugCollectionInSwingThread(project, bugs);
    } finally {
        releaseDisplayWait();
    }
}
Also used : Project(edu.umd.cs.findbugs.Project)

Example 5 with Project

use of edu.umd.cs.findbugs.Project in project spotbugs by spotbugs.

the class MainFrame method setProjectAndBugCollection.

@SwingThread
private void setProjectAndBugCollection(@CheckForNull Project project, @CheckForNull BugCollection bugCollection) {
    if (GUI2_DEBUG) {
        if (bugCollection == null) {
            System.out.println("Setting bug collection to null");
        } else {
            System.out.println("Setting bug collection; contains " + bugCollection.getCollection().size() + " bugs");
        }
    }
    if (bugCollection != null && bugCollection.getProject() != project) {
        Project p2 = bugCollection.getProject();
        throw new IllegalArgumentException(String.format("project %x and bug collection %x don't match", System.identityHashCode(project), System.identityHashCode(p2)));
    }
    acquireDisplayWait();
    try {
        // setRebuilding(false);
        setProject(project);
        this.bugCollection = bugCollection;
        BugLoader.addDeadBugMatcher(bugCollection);
        displayer.clearCache();
        mainFrameTree.updateBugTree();
        setProjectChanged(false);
        Runnable runnable = () -> {
            PreferencesFrame.getInstance().updateFilterPanel();
            mainFrameMenu.getReconfigMenuItem().setEnabled(true);
            mainFrameMenu.setViewMenu();
            newProject();
            clearSourcePane();
            clearSummaryTab();
            /*
                 * This is here due to a threading issue. It can only be
                 * called after curProject has been changed. Since this
                 * method is called by both open methods it is put here.
                 */
            updateTitle();
        };
        if (SwingUtilities.isEventDispatchThread()) {
            runnable.run();
        } else {
            SwingUtilities.invokeLater(runnable);
        }
    } finally {
        releaseDisplayWait();
    }
}
Also used : Project(edu.umd.cs.findbugs.Project)

Aggregations

Project (edu.umd.cs.findbugs.Project)35 SortedBugCollection (edu.umd.cs.findbugs.SortedBugCollection)8 File (java.io.File)8 BugInstance (edu.umd.cs.findbugs.BugInstance)6 AnalysisContext (edu.umd.cs.findbugs.ba.AnalysisContext)4 Test (org.junit.jupiter.api.Test)4 DetectorFactoryCollection (edu.umd.cs.findbugs.DetectorFactoryCollection)3 FindBugs2 (edu.umd.cs.findbugs.FindBugs2)3 Plugin (edu.umd.cs.findbugs.Plugin)3 ProjectStats (edu.umd.cs.findbugs.ProjectStats)3 UserPreferences (edu.umd.cs.findbugs.config.UserPreferences)3 Filter (edu.umd.cs.findbugs.filter.Filter)3 GridBagConstraints (java.awt.GridBagConstraints)3 Insets (java.awt.Insets)3 IOException (java.io.IOException)3 Reporter (de.tobject.findbugs.reporter.Reporter)2 StopTimer (de.tobject.findbugs.util.Util.StopTimer)2 ClassAnnotation (edu.umd.cs.findbugs.ClassAnnotation)2 PackageStats (edu.umd.cs.findbugs.PackageStats)2 PluginException (edu.umd.cs.findbugs.PluginException)2