mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Introduce Scratches named scope (GO-4763)
- it's required to deserialize "Scratches and Consoles" scope
This commit is contained in:
@@ -315,7 +315,7 @@ public class ScratchFileServiceImpl extends ScratchFileService implements Persis
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Scratches and Consoles";
|
||||
return ScratchesAndConsolesNamedScope.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2000-2017 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.ide.scratch;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.search.scope.packageSet.AbstractPackageSet;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScope;
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ScratchesAndConsolesNamedScope extends NamedScope {
|
||||
public static final String NAME = "Scratches and Consoles";
|
||||
|
||||
public ScratchesAndConsolesNamedScope() {
|
||||
super(NAME, new AbstractPackageSet(NAME) {
|
||||
@Override
|
||||
public boolean contains(VirtualFile file, NamedScopesHolder holder) {
|
||||
return contains(file, holder.getProject(), holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(VirtualFile file, @NotNull Project project, @Nullable NamedScopesHolder holder) {
|
||||
RootType rootType = ScratchUtil.isScratch(file) ? ScratchFileService.getInstance().getRootType(file) : null;
|
||||
return rootType != null && !rootType.isHidden();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.ide.util.scopeChooser;
|
||||
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.ide.scratch.ScratchesAndConsolesNamedScope;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -62,7 +63,9 @@ public class ScopeChooserUtils {
|
||||
namedScope = new ProjectFilesScope();
|
||||
}
|
||||
GlobalSearchScope scope = GlobalSearchScopesCore.filterScope(project, namedScope);
|
||||
if (namedScope instanceof ProjectFilesScope || namedScope instanceof ProjectProductionScope) {
|
||||
if (namedScope instanceof ProjectFilesScope ||
|
||||
namedScope instanceof ProjectProductionScope ||
|
||||
namedScope instanceof ScratchesAndConsolesNamedScope) {
|
||||
return scope;
|
||||
}
|
||||
return intersectWithContentScope(project, scope);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.packageDependencies;
|
||||
|
||||
import com.intellij.ide.scratch.ScratchesAndConsolesNamedScope;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.search.scope.NonProjectFilesScope;
|
||||
@@ -47,7 +48,7 @@ public class DefaultScopesProvider extends CustomScopesProviderEx {
|
||||
NamedScope projectScope = new ProjectFilesScope();
|
||||
NamedScope nonProjectScope = new NonProjectFilesScope();
|
||||
myProblemsScope = new ProblemScope(project);
|
||||
myScopes = Arrays.asList(projectScope, getProblemsScope(), getAllScope(), nonProjectScope);
|
||||
myScopes = Arrays.asList(projectScope, getProblemsScope(), getAllScope(), nonProjectScope, new ScratchesAndConsolesNamedScope());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user