mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 19:02:13 +07:00
IJPL-339 resolve for Java
GitOrigin-RevId: 7194b296f17b5318d0aae88b85c99631018ce90f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b095b62e1d
commit
6f5402325c
@@ -98,7 +98,9 @@ public final class PsiElementFinderImpl extends PsiElementFinder implements Dumb
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiClass @NotNull [] getClasses(@Nullable String shortName, @NotNull PsiPackage psiPackage, final @NotNull GlobalSearchScope scope) {
|
||||
public PsiClass @NotNull [] getClasses(@Nullable String shortName,
|
||||
@NotNull PsiPackage psiPackage,
|
||||
@NotNull GlobalSearchScope scope) {
|
||||
List<PsiClass> list = null;
|
||||
String packageName = psiPackage.getQualifiedName();
|
||||
for (PsiDirectory dir : psiPackage.getDirectories(scope)) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.psi.impl.compiled;
|
||||
|
||||
import com.intellij.codeInsight.multiverse.CodeInsightContext;
|
||||
import com.intellij.codeInsight.multiverse.CodeInsightContextManager;
|
||||
import com.intellij.codeInsight.multiverse.CodeInsightContextManagerImpl;
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
@@ -343,6 +346,11 @@ public class ClsFileImpl extends PsiBinaryFileImpl
|
||||
PsiFileFactory factory = PsiFileFactory.getInstance(getManager().getProject());
|
||||
PsiFile mirror = factory.createFileFromText(fileName, JavaLanguage.INSTANCE, mirrorText, false, false, true);
|
||||
mirror.putUserData(PsiUtil.FILE_LANGUAGE_LEVEL_KEY, getLanguageLevel());
|
||||
CodeInsightContextManagerImpl contextManager = CodeInsightContextManagerImpl.Companion.getInstanceImpl(getProject());
|
||||
if (contextManager.isSharedSourceSupportEnabled()) {
|
||||
CodeInsightContext context = contextManager.getCodeInsightContext(getViewProvider());
|
||||
contextManager.setCodeInsightContext(mirror.getViewProvider(), context);
|
||||
}
|
||||
|
||||
mirrorTreeElement = SourceTreeToPsiMap.psiToTreeNotNull(mirror);
|
||||
try {
|
||||
|
||||
@@ -45,7 +45,6 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya
|
||||
private volatile CachedValue<PsiModifierList> myAnnotationList;
|
||||
private volatile CachedValue<Collection<PsiDirectory>> myDirectories;
|
||||
private volatile CachedValue<Collection<PsiDirectory>> myDirectoriesWithLibSources;
|
||||
private volatile SoftReference<Map<String, PsiClass[]>> myClassCache;
|
||||
private volatile SoftReference<Map<GlobalSearchScope, Map<String, PsiClass[]>>> myDumbModeFullCache;
|
||||
private volatile SoftReference<Map<Pair<GlobalSearchScope, String>, PsiClass[]>> myDumbModePartialCache;
|
||||
|
||||
@@ -172,21 +171,7 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya
|
||||
return getCachedClassesInDumbMode(name, scope);
|
||||
}
|
||||
|
||||
Map<String, PsiClass[]> map = dereference(myClassCache);
|
||||
if (map == null) {
|
||||
myClassCache = new SoftReference<>(map = ContainerUtil.createConcurrentSoftValueMap());
|
||||
}
|
||||
PsiClass[] classes = map.get(name);
|
||||
if (classes != null) {
|
||||
return classes;
|
||||
}
|
||||
|
||||
RecursionGuard.StackStamp stamp = RecursionManager.markStack();
|
||||
classes = findAllClasses(name, GlobalSearchScope.everythingScope(getProject()));
|
||||
if (stamp.mayCacheNow()) {
|
||||
map.put(name, classes);
|
||||
}
|
||||
return classes;
|
||||
return findAllClasses(name, scope);
|
||||
}
|
||||
|
||||
private PsiClass @NotNull [] findAllClasses(@NotNull String shortName, @NotNull GlobalSearchScope scope) {
|
||||
@@ -223,6 +208,7 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya
|
||||
return classes == null ? PsiClass.EMPTY_ARRAY : classes;
|
||||
}
|
||||
|
||||
// todo
|
||||
private PsiClass @Nullable [] findClassesHeuristically(final String name, GlobalSearchScope scope) {
|
||||
if (findSubPackageByName(name) != null) {
|
||||
return PsiClass.EMPTY_ARRAY;
|
||||
@@ -237,7 +223,7 @@ public class PsiPackageImpl extends PsiPackageBase implements PsiPackage, Querya
|
||||
RecursionGuard.StackStamp stamp = RecursionManager.markStack();
|
||||
List<PsiClass> fastClasses = new ArrayList<>();
|
||||
for (PsiDirectory directory : getDirectories(scope)) {
|
||||
List<PsiFile> sameNamed = ContainerUtil.filter(directory.getFiles(), file -> file.getName().contains(name));
|
||||
List<PsiFile> sameNamed = ContainerUtil.filter(directory.getFiles(scope), file -> file.getName().contains(name));
|
||||
PsiClass[] classes = CoreJavaDirectoryService.getPsiClasses(directory, sameNamed.toArray(PsiFile.EMPTY_ARRAY));
|
||||
for (PsiClass aClass : classes) {
|
||||
if (name.equals(aClass.getName())) {
|
||||
|
||||
Reference in New Issue
Block a user