mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ChangeListScope is not bound to the specific ChangeList
This commit is contained in:
+4
-8
@@ -1,23 +1,19 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.psi.search.scope.packageSet;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import java.util.Collection;
|
||||
|
||||
public class FilteredNamedScope extends NamedScope {
|
||||
public FilteredNamedScope(@NotNull String name, @NotNull Icon icon, int priority, @NotNull Collection<VirtualFile> files) {
|
||||
this(name, icon, priority, files::contains);
|
||||
}
|
||||
|
||||
public FilteredNamedScope(@NotNull String name, @NotNull Icon icon, int priority, @NotNull VirtualFileFilter filter) {
|
||||
super(name, icon, new AbstractPackageSet(name, priority) {
|
||||
super(name, icon, new FilteredPackageSet(name, priority) {
|
||||
@Override
|
||||
public boolean contains(VirtualFile file, NamedScopesHolder holder) {
|
||||
return file != null && filter.accept(file);
|
||||
public boolean contains(@NotNull VirtualFile file, @NotNull Project project) {
|
||||
return filter.accept(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+4
@@ -11,6 +11,10 @@ public abstract class FilteredPackageSet extends AbstractPackageSet {
|
||||
super(text);
|
||||
}
|
||||
|
||||
public FilteredPackageSet(@NotNull String text, int priority) {
|
||||
super(text, priority);
|
||||
}
|
||||
|
||||
public abstract boolean contains(@NotNull VirtualFile file, @NotNull Project project);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,23 +3,20 @@ package com.intellij.packageDependencies;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.vcs.changes.ChangeList;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.psi.search.scope.packageSet.FilteredNamedScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.intellij.openapi.vcs.changes.ChangesUtil.getAfterRevisionsFiles;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
public final class ChangeListScope extends FilteredNamedScope {
|
||||
public static final String NAME = IdeBundle.message("scope.modified.files");
|
||||
|
||||
public ChangeListScope(@NotNull ChangeListManager manager) {
|
||||
super(NAME, AllIcons.Toolwindows.ToolWindowChanges, 0, manager.getAffectedFiles());
|
||||
super(NAME, AllIcons.Toolwindows.ToolWindowChanges, 0, manager::isFileAffected);
|
||||
}
|
||||
|
||||
public ChangeListScope(@NotNull ChangeList list) {
|
||||
super(list.getName(), AllIcons.Toolwindows.ToolWindowChanges, 0, getAfterRevisionsFiles(list.getChanges().stream()).collect(toList()));
|
||||
public ChangeListScope(@NotNull ChangeListManager manager, @NotNull String name) {
|
||||
super(name, AllIcons.Toolwindows.ToolWindowChanges, 0,
|
||||
file -> manager.getChangeLists(file).stream().anyMatch(list -> list.getName().equals(name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ public class ChangeListsScopesProvider extends CustomScopesProviderEx {
|
||||
final List<NamedScope> result = new ArrayList<>();
|
||||
result.add(new ChangeListScope(changeListManager));
|
||||
for (ChangeList list : changeListManager.getChangeListsCopy()) {
|
||||
result.add(new ChangeListScope(list));
|
||||
result.add(new ChangeListScope(changeListManager, list.getName()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class ChangeListsScopesProvider extends CustomScopesProviderEx {
|
||||
}
|
||||
final LocalChangeList changeList = changeListManager.findChangeList(name);
|
||||
if (changeList != null) {
|
||||
return new ChangeListScope(changeList);
|
||||
return new ChangeListScope(changeListManager, changeList.getName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user