use of org.sonarlint.intellij.config.project.ExclusionItem in project sonarlint-intellij by SonarSource.
the class LocalFileExclusions method loadProjectExclusions.
private void loadProjectExclusions(SonarLintProjectSettings settings) {
List<ExclusionItem> projectExclusionsItems = settings.getFileExclusions().stream().map(ExclusionItem::parse).filter(Objects::nonNull).collect(Collectors.toList());
Set<String> projectFileExclusions = getExclusionsOfType(projectExclusionsItems, ExclusionItem.Type.FILE);
Set<String> projectDirExclusions = getExclusionsOfType(projectExclusionsItems, ExclusionItem.Type.DIRECTORY);
Set<String> projectGlobExclusions = getExclusionsOfType(projectExclusionsItems, ExclusionItem.Type.GLOB);
this.projectExclusions = new FileExclusions(projectFileExclusions, projectDirExclusions, projectGlobExclusions);
}
use of org.sonarlint.intellij.config.project.ExclusionItem 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.ExclusionItem 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);
}
}
Aggregations