Search in sources :

Example 6 with SonarLintProjectSettings

use of org.sonarlint.intellij.config.project.SonarLintProjectSettings in project sonarlint-intellij by SonarSource.

the class SonarQubeServerMgmtPanel method updateServerBinding.

public static void updateServerBinding(SonarQubeServer server, ConnectedSonarLintEngine engine, boolean onlyProjects) {
    Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
    Map<String, List<Project>> projectsPerModule = new HashMap<>();
    for (Project p : openProjects) {
        SonarLintProjectSettings projectSettings = SonarLintUtils.get(p, SonarLintProjectSettings.class);
        String moduleKey = projectSettings.getProjectKey();
        if (projectSettings.isBindingEnabled() && server.getName().equals(projectSettings.getServerId()) && moduleKey != null) {
            List<Project> projects = projectsPerModule.computeIfAbsent(moduleKey, k -> new ArrayList<>());
            projects.add(p);
        }
    }
    ServerUpdateTask task = new ServerUpdateTask(engine, server, projectsPerModule, onlyProjects);
    ProgressManager.getInstance().run(task.asBackground());
}
Also used : Project(com.intellij.openapi.project.Project) ServerUpdateTask(org.sonarlint.intellij.tasks.ServerUpdateTask) SonarLintProjectSettings(org.sonarlint.intellij.config.project.SonarLintProjectSettings) HashMap(java.util.HashMap) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) JBList(com.intellij.ui.components.JBList) JList(javax.swing.JList)

Example 7 with SonarLintProjectSettings

use of org.sonarlint.intellij.config.project.SonarLintProjectSettings in project sonarlint-intellij by SonarSource.

the class ExcludeFileAction method update.

@Override
public void update(AnActionEvent e) {
    super.update(e);
    Project project = e.getProject();
    if (project == null || !project.isInitialized() || project.isDisposed()) {
        e.getPresentation().setEnabled(false);
        e.getPresentation().setVisible(true);
        return;
    }
    VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
    if (!ActionPlaces.isPopupPlace(e.getPlace()) || files == null || files.length == 0) {
        e.getPresentation().setEnabled(false);
        e.getPresentation().setVisible(false);
        return;
    }
    e.getPresentation().setVisible(true);
    SonarLintProjectSettings settings = SonarLintUtils.get(project, SonarLintProjectSettings.class);
    List<String> exclusions = new ArrayList<>(settings.getFileExclusions());
    boolean anyFileToAdd = Arrays.stream(files).map(vf -> toExclusion(project, vf)).filter(exclusion -> !exclusion.item().isEmpty()).map(ExclusionItem::toStringWithType).anyMatch(path -> !exclusions.contains(path));
    if (!anyFileToAdd) {
        e.getPresentation().setEnabled(false);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SonarLintUtils(org.sonarlint.intellij.util.SonarLintUtils) ProjectConfigurationListener(org.sonarlint.intellij.messages.ProjectConfigurationListener) Arrays(java.util.Arrays) SonarLintProjectSettings(org.sonarlint.intellij.config.project.SonarLintProjectSettings) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExclusionItem(org.sonarlint.intellij.config.project.ExclusionItem) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) ActionPlaces(com.intellij.openapi.actionSystem.ActionPlaces) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Project(com.intellij.openapi.project.Project) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) Project(com.intellij.openapi.project.Project) SonarLintProjectSettings(org.sonarlint.intellij.config.project.SonarLintProjectSettings) ArrayList(java.util.ArrayList)

Example 8 with SonarLintProjectSettings

use of org.sonarlint.intellij.config.project.SonarLintProjectSettings in project sonarlint-intellij by SonarSource.

the class ExcludeFileAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
    if (project == null || project.isDisposed() || files == null || files.length == 0) {
        return;
    }
    SonarLintProjectSettings settings = SonarLintUtils.get(project, SonarLintProjectSettings.class);
    List<String> exclusions = new ArrayList<>(settings.getFileExclusions());
    List<String> newExclusions = Arrays.stream(files).map(vf -> toExclusion(project, vf)).filter(exclusion -> !exclusion.item().isEmpty()).map(ExclusionItem::toStringWithType).filter(path -> !exclusions.contains(path)).collect(Collectors.toList());
    if (!newExclusions.isEmpty()) {
        exclusions.addAll(newExclusions);
        settings.setFileExclusions(exclusions);
        ProjectConfigurationListener projectListener = project.getMessageBus().syncPublisher(ProjectConfigurationListener.TOPIC);
        projectListener.changed(settings);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SonarLintUtils(org.sonarlint.intellij.util.SonarLintUtils) ProjectConfigurationListener(org.sonarlint.intellij.messages.ProjectConfigurationListener) Arrays(java.util.Arrays) SonarLintProjectSettings(org.sonarlint.intellij.config.project.SonarLintProjectSettings) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExclusionItem(org.sonarlint.intellij.config.project.ExclusionItem) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction) List(java.util.List) ActionPlaces(com.intellij.openapi.actionSystem.ActionPlaces) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Project(com.intellij.openapi.project.Project) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) Project(com.intellij.openapi.project.Project) SonarLintProjectSettings(org.sonarlint.intellij.config.project.SonarLintProjectSettings) ProjectConfigurationListener(org.sonarlint.intellij.messages.ProjectConfigurationListener) ArrayList(java.util.ArrayList) ExclusionItem(org.sonarlint.intellij.config.project.ExclusionItem)

Example 9 with SonarLintProjectSettings

use of org.sonarlint.intellij.config.project.SonarLintProjectSettings in project sonarlint-intellij by SonarSource.

the class ConnectedSonarLintFacadeTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    settings = new SonarLintProjectSettings();
    when(project.getBasePath()).thenReturn("");
    facade = new ConnectedSonarLintFacade(engine, settings, console, project, moduleKey);
}
Also used : SonarLintProjectSettings(org.sonarlint.intellij.config.project.SonarLintProjectSettings) Before(org.junit.Before)

Example 10 with SonarLintProjectSettings

use of org.sonarlint.intellij.config.project.SonarLintProjectSettings in project sonarlint-intellij by SonarSource.

the class ToolWindowLogAnalysisActionTest method prepare.

@Before
public void prepare() {
    settings = new SonarLintProjectSettings();
    super.register(SonarLintProjectSettings.class, settings);
    action = new ToolWindowLogAnalysisAction();
    event = SonarLintTestUtils.createAnActionEvent(project);
}
Also used : SonarLintProjectSettings(org.sonarlint.intellij.config.project.SonarLintProjectSettings) Before(org.junit.Before)

Aggregations

SonarLintProjectSettings (org.sonarlint.intellij.config.project.SonarLintProjectSettings)13 Before (org.junit.Before)9 Project (com.intellij.openapi.project.Project)5 ArrayList (java.util.ArrayList)3 List (java.util.List)3 ActionPlaces (com.intellij.openapi.actionSystem.ActionPlaces)2 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)2 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)2 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Arrays (java.util.Arrays)2 Collectors (java.util.stream.Collectors)2 SonarApplication (org.sonarlint.intellij.SonarApplication)2 ExclusionItem (org.sonarlint.intellij.config.project.ExclusionItem)2 ProjectConfigurationListener (org.sonarlint.intellij.messages.ProjectConfigurationListener)2 SonarLintConsole (org.sonarlint.intellij.ui.SonarLintConsole)2 SonarLintUtils (org.sonarlint.intellij.util.SonarLintUtils)2 JBList (com.intellij.ui.components.JBList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1