下面列出了com.intellij.psi.search.GlobalSearchScope#EMPTY_SCOPE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private SearchScope createSearchScope(Module module, List<MicroProfilePropertiesScope> scopes,
boolean excludeTestCode) {
SearchScope searchScope = GlobalSearchScope.EMPTY_SCOPE;
for (MicroProfilePropertiesScope scope : scopes) {
switch (scope) {
case sources:
searchScope = searchScope.union(module.getModuleScope(!excludeTestCode));
break;
case dependencies:
searchScope = searchScope.union(module.getModuleWithLibrariesScope());
break;
}
}
return searchScope;
}
@Nonnull
protected GlobalSearchScope initScope() {
RunProfile configuration = getConfiguration();
if (!(configuration instanceof ModuleRunProfile)) {
return GlobalSearchScope.allScope(myProject);
}
Module[] modules = ((ModuleRunProfile)configuration).getModules();
if (modules.length == 0) {
return GlobalSearchScope.allScope(myProject);
}
GlobalSearchScope scope = GlobalSearchScope.EMPTY_SCOPE;
for (Module each : modules) {
scope = scope.uniteWith(GlobalSearchScope.moduleRuntimeScope(each, true));
}
return scope;
}
protected AbstractGotoSEContributor(@Nullable Project project, @Nullable PsiElement context) {
myProject = project;
psiContext = context;
myEverywhereScope = myProject == null ? GlobalSearchScope.EMPTY_SCOPE : GlobalSearchScope.everythingScope(myProject);
GlobalSearchScope projectScope = myProject == null ? GlobalSearchScope.EMPTY_SCOPE : GlobalSearchScope.projectScope(myProject);
if (myProject == null) {
myProjectScope = GlobalSearchScope.EMPTY_SCOPE;
}
else if (!myEverywhereScope.equals(projectScope)) {
myProjectScope = projectScope;
}
else {
// just get the second scope, i.e. Attached Directories in DataGrip
Ref<GlobalSearchScope> result = Ref.create();
processScopes(SimpleDataContext.getProjectContext(myProject), o -> {
if (o.scopeEquals(myEverywhereScope) || o.scopeEquals(null)) return true;
result.set((GlobalSearchScope)o.getScope());
return false;
});
myProjectScope = ObjectUtils.notNull(result.get(), myEverywhereScope);
}
myScopeDescriptor = getInitialSelectedScope();
}
@Override
public GlobalSearchScope uniteWith(@NotNull GlobalSearchScope scope) {
if (scope instanceof BlazePackageSearchScope) {
BlazePackageSearchScope other = (BlazePackageSearchScope) scope;
if (!blazePackage.equals(other.blazePackage)) {
return GlobalSearchScope.EMPTY_SCOPE;
}
return onlyBlazeFiles ? this : other;
}
return super.uniteWith(scope);
}
public static GlobalSearchScope moduleScope(PsiFile file) {
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile == null) {
return GlobalSearchScope.EMPTY_SCOPE;
}
Module module = ProjectRootManager.getInstance(file.getProject()).getFileIndex().getModuleForFile(virtualFile);
if (module == null) {
return GlobalSearchScope.fileScope(file);
}
//the module scope returned by getModuleScope() just contains the files in the configured source and test source directories,
//module content scope includes all files in the module directory
return module.getModuleContentScope();
}
@Nonnull
public SearchScope toSearchScope() {
switch (myType) {
case CUSTOM:
return myScope;
case DIRECTORY:
return GlobalSearchScopesCore.directoryScope((PsiDirectory)myElement, true);
case FILE:
return new LocalSearchScope(myElement);
case INVALID:
return LocalSearchScope.EMPTY;
case MODULE:
GlobalSearchScope moduleScope = GlobalSearchScope.moduleScope(myModule);
return myIncludeTestSource ? moduleScope : GlobalSearchScope.notScope(GlobalSearchScopesCore.projectTestScope(myModule.getProject())).intersectWith(moduleScope);
case MODULES:
SearchScope scope = GlobalSearchScope.EMPTY_SCOPE;
for (Module module : myModules) {
scope = scope.union(GlobalSearchScope.moduleScope(module));
}
return scope;
case PROJECT:
return myIncludeTestSource ? GlobalSearchScope.projectScope(myProject) : GlobalSearchScopesCore.projectProductionScope(myProject);
case VIRTUAL_FILES:
return new GlobalSearchScope() {
@Override
public boolean contains(@Nonnull VirtualFile file) {
return myFilesSet.contains(file);
}
@Override
public int compare(@Nonnull VirtualFile file1, @Nonnull VirtualFile file2) {
return 0;
}
@Override
public boolean isSearchInModuleContent(@Nonnull Module aModule) {
return false;
}
@Override
public boolean isSearchInLibraries() {
return false;
}
};
default:
LOG.error("invalid type " + myType);
return GlobalSearchScope.EMPTY_SCOPE;
}
}
@Override
@Nonnull
public GlobalSearchScope getResolveScope() {
return GlobalSearchScope.EMPTY_SCOPE;
}
@Override
@Nonnull
public SearchScope getUseScope() {
return GlobalSearchScope.EMPTY_SCOPE;
}
<K> void ensureUpToDate(@Nonnull final ID<K, ?> indexId, @Nullable Project project, @Nullable GlobalSearchScope filter, @Nullable VirtualFile restrictedFile) {
ProgressManager.checkCanceled();
getChangedFilesCollector().ensureUpToDate();
ApplicationManager.getApplication().assertReadAccessAllowed();
NoAccessDuringPsiEvents.checkCallContext();
if (!needsFileContentLoading(indexId)) {
return; //indexed eagerly in foreground while building unindexed file list
}
if (filter == GlobalSearchScope.EMPTY_SCOPE) {
return;
}
if (ActionUtil.isDumbMode(project)) {
handleDumbMode(project);
}
if (myReentrancyGuard.get().booleanValue()) {
//assert false : "ensureUpToDate() is not reentrant!";
return;
}
myReentrancyGuard.set(Boolean.TRUE);
try {
if (isUpToDateCheckEnabled()) {
try {
if (!RebuildStatus.isOk(indexId)) {
throw new ProcessCanceledException();
}
forceUpdate(project, filter, restrictedFile);
indexUnsavedDocuments(indexId, project, filter, restrictedFile);
}
catch (RuntimeException e) {
final Throwable cause = e.getCause();
if (cause instanceof StorageException || cause instanceof IOException) {
scheduleRebuild(indexId, e);
}
else {
throw e;
}
}
}
}
finally {
myReentrancyGuard.set(Boolean.FALSE);
}
}