This commit is contained in:
Alexey Kudravtsev
2017-08-16 19:03:18 +03:00
parent b937a37ee7
commit 7b2c8bb8b8
6 changed files with 16 additions and 6 deletions

View File

@@ -488,7 +488,7 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw
}
private UnionScope(@NotNull GlobalSearchScope[] scopes) {
super(ContainerUtil.getFirstItem(ContainerUtil.mapNotNull(scopes, scope -> scope.getProject()), null));
super(ContainerUtil.getFirstItem(ContainerUtil.mapNotNull(scopes, GlobalSearchScope::getProject), null));
if (scopes.length <= 1) throw new IllegalArgumentException("Too few scopes: "+ Arrays.asList(scopes));
myScopes = scopes;
final int[] nested = {0};
@@ -518,7 +518,7 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw
@Override
public boolean isSearchOutsideRootModel() {
return ContainerUtil.find(myScopes, scope -> scope.isSearchOutsideRootModel()) != null;
return ContainerUtil.find(myScopes, GlobalSearchScope::isSearchOutsideRootModel) != null;
}
@Override
@@ -560,7 +560,7 @@ public abstract class GlobalSearchScope extends SearchScope implements ProjectAw
@Override
public boolean isSearchInLibraries() {
return ContainerUtil.find(myScopes, scope -> scope.isSearchInLibraries()) != null;
return ContainerUtil.find(myScopes, GlobalSearchScope::isSearchInLibraries) != null;
}
@Override

View File

@@ -20,7 +20,6 @@ import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;

View File

@@ -20,9 +20,9 @@ import com.intellij.psi.PsiBundle;
import org.jetbrains.annotations.NotNull;
public abstract class SearchScope {
private static int hashCodeCounter = 0;
private static int hashCodeCounter;
@SuppressWarnings({"AssignmentToStaticFieldFromInstanceMethod"})
@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod")
private final int myHashCode = hashCodeCounter++;
/**

View File

@@ -47,12 +47,14 @@ public class ProjectAndLibrariesScope extends GlobalSearchScope {
mySearchOutsideRootModel = searchOutsideRootModel;
}
@Override
public boolean contains(@NotNull VirtualFile file) {
return myProjectFileIndex.isInContent(file) ||
myProjectFileIndex.isInLibraryClasses(file) ||
myProjectFileIndex.isInLibrarySource(file);
}
@Override
public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) {
List<OrderEntry> entries1 = myProjectFileIndex.getOrderEntriesForFile(file1);
List<OrderEntry> entries2 = myProjectFileIndex.getOrderEntriesForFile(file2);
@@ -86,10 +88,12 @@ public class ProjectAndLibrariesScope extends GlobalSearchScope {
return mySearchOutsideRootModel;
}
@Override
public boolean isSearchInModuleContent(@NotNull Module aModule) {
return true;
}
@Override
public boolean isSearchInLibraries() {
return true;
}
@@ -100,6 +104,7 @@ public class ProjectAndLibrariesScope extends GlobalSearchScope {
return project != null ? ModuleManager.getInstance(project).getUnloadedModuleDescriptions() : Collections.emptySet();
}
@Override
@NotNull
public String getDisplayName() {
return myDisplayName;
@@ -109,6 +114,7 @@ public class ProjectAndLibrariesScope extends GlobalSearchScope {
myDisplayName = displayName;
}
@Override
@NotNull
public GlobalSearchScope intersectWith(@NotNull final GlobalSearchScope scope) {
if (scope.isSearchOutsideRootModel()) {
@@ -118,6 +124,7 @@ public class ProjectAndLibrariesScope extends GlobalSearchScope {
return scope;
}
@Override
@NotNull
public GlobalSearchScope uniteWith(@NotNull final GlobalSearchScope scope) {
if (scope.isSearchOutsideRootModel()) {

View File

@@ -186,10 +186,12 @@ public abstract class SourceScope {
return 0;
}
@Override
public boolean isSearchInModuleContent(@NotNull final Module aModule) {
return myMainScope.isSearchInModuleContent(aModule);
}
@Override
public boolean isSearchInLibraries() {
return true;
}

View File

@@ -40,10 +40,12 @@ public class TestNGSearchScope extends GlobalSearchScope {
return 0;
}
@Override
public boolean isSearchInModuleContent(@NotNull Module aModule) {
return true;
}
@Override
public boolean isSearchInLibraries() {
return false;
}