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());
}
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);
}
}
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);
}
}
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);
}
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);
}
Aggregations