use of com.intellij.psi.search.EverythingGlobalScope in project intellij-community by JetBrains.
the class PsiPackageImpl method getCachedClassesByName.
@NotNull
private PsiClass[] getCachedClassesByName(@NotNull String name, GlobalSearchScope scope) {
if (DumbService.getInstance(getProject()).isDumb()) {
return getCachedClassInDumbMode(name, scope);
}
Map<String, PsiClass[]> map = SoftReference.dereference(myClassCache);
if (map == null) {
myClassCache = new SoftReference<>(map = ContainerUtil.createConcurrentSoftValueMap());
}
PsiClass[] classes = map.get(name);
if (classes != null) {
return classes;
}
final String qName = getQualifiedName();
final String classQName = !qName.isEmpty() ? qName + "." + name : name;
map.put(name, classes = getFacade().findClasses(classQName, new EverythingGlobalScope(getProject())));
return classes;
}
use of com.intellij.psi.search.EverythingGlobalScope in project intellij-community by JetBrains.
the class JavaDocInfoGenerator method generatePackageJavaDoc.
private void generatePackageJavaDoc(final StringBuilder buffer, final PsiPackage psiPackage, boolean generatePrologueAndEpilogue) {
for (PsiDirectory directory : psiPackage.getDirectories(new EverythingGlobalScope(myProject))) {
final PsiFile packageInfoFile = directory.findFile(PsiPackage.PACKAGE_INFO_FILE);
if (packageInfoFile != null) {
final ASTNode node = packageInfoFile.getNode();
if (node != null) {
final ASTNode docCommentNode = findRelevantCommentNode(node);
if (docCommentNode != null) {
if (generatePrologueAndEpilogue)
generatePrologue(buffer);
generateCommonSection(buffer, (PsiDocComment) docCommentNode.getPsi());
if (generatePrologueAndEpilogue)
generateEpilogue(buffer);
break;
}
}
}
PsiFile packageHtmlFile = directory.findFile("package.html");
if (packageHtmlFile != null) {
generatePackageHtmlJavaDoc(buffer, packageHtmlFile, generatePrologueAndEpilogue);
break;
}
}
}
use of com.intellij.psi.search.EverythingGlobalScope in project intellij-community by JetBrains.
the class LineBreakpoint method isInScopeOf.
private boolean isInScopeOf(DebugProcessImpl debugProcess, String className) {
final SourcePosition position = getSourcePosition();
if (position != null) {
final VirtualFile breakpointFile = position.getFile().getVirtualFile();
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
if (breakpointFile != null && fileIndex.isUnderSourceRootOfType(breakpointFile, JavaModuleSourceRootTypes.SOURCES)) {
if (debugProcess.getSearchScope().contains(breakpointFile)) {
return true;
}
// apply filtering to breakpoints from content sources only, not for sources attached to libraries
final Collection<VirtualFile> candidates = findClassCandidatesInSourceContent(className, debugProcess.getSearchScope(), fileIndex);
if (LOG.isDebugEnabled()) {
LOG.debug("Found " + (candidates == null ? "null" : candidates.size()) + " candidate containing files for class " + className);
}
if (candidates == null) {
// If no candidates are found in scope then assume that class is loaded dynamically and allow breakpoint
return true;
}
//}
if (LOG.isDebugEnabled()) {
final GlobalSearchScope scope = debugProcess.getSearchScope();
final boolean contains = scope.contains(breakpointFile);
List<VirtualFile> files = ContainerUtil.map(JavaFullClassNameIndex.getInstance().get(className.hashCode(), myProject, scope), aClass -> aClass.getContainingFile().getVirtualFile());
List<VirtualFile> allFiles = ContainerUtil.map(JavaFullClassNameIndex.getInstance().get(className.hashCode(), myProject, new EverythingGlobalScope(myProject)), aClass -> aClass.getContainingFile().getVirtualFile());
final VirtualFile contentRoot = fileIndex.getContentRootForFile(breakpointFile);
final Module module = fileIndex.getModuleForFile(breakpointFile);
LOG.debug("Did not find '" + className + "' in " + scope + "; contains=" + contains + "; contentRoot=" + contentRoot + "; module = " + module + "; all files in index are: " + files + "; all possible files are: " + allFiles);
}
return false;
}
}
return true;
}
use of com.intellij.psi.search.EverythingGlobalScope in project intellij-community by JetBrains.
the class GradleClassFinder method findClass.
@Override
public PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) {
PsiClass aClass = super.findClass(qualifiedName, scope);
if (aClass == null || scope instanceof ExternalModuleBuildGlobalSearchScope || scope instanceof EverythingGlobalScope) {
return aClass;
}
PsiFile containingFile = aClass.getContainingFile();
VirtualFile file = containingFile != null ? containingFile.getVirtualFile() : null;
return (file != null && !ProjectFileIndex.SERVICE.getInstance(myProject).isInContent(file) && !ProjectFileIndex.SERVICE.getInstance(myProject).isInLibraryClasses(file) && !ProjectFileIndex.SERVICE.getInstance(myProject).isInLibrarySource(file)) ? aClass : null;
}
Aggregations