mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
GitOrigin-RevId: f9766961fcad0760d25069ed952c032767f1354c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
aa565167d4
commit
6f7e72f06a
@@ -301,7 +301,7 @@ public class JavaFindUsagesHelper {
|
||||
});
|
||||
if (methodClass == null) continue;
|
||||
boolean equivalent = ReadAction.compute(() -> manager.areElementsEquivalent(methodClass, aClass));
|
||||
if (equivalent){
|
||||
if (equivalent) {
|
||||
if (!addElementUsages(method, options, processor)) return false;
|
||||
}
|
||||
else {
|
||||
@@ -483,18 +483,18 @@ public class JavaFindUsagesHelper {
|
||||
private static boolean addResult(@NotNull PsiElement element,
|
||||
@NotNull FindUsagesOptions options,
|
||||
@NotNull Processor<? super UsageInfo> processor) {
|
||||
return !filterUsage(element, options) || processor.process(new UsageInfo(element));
|
||||
return !acceptUsage(element, options) || processor.process(new UsageInfo(element));
|
||||
}
|
||||
|
||||
private static boolean addResult(@NotNull PsiReference ref, @NotNull FindUsagesOptions options, @NotNull Processor<? super UsageInfo> processor) {
|
||||
if (filterUsage(ref.getElement(), options)){
|
||||
if (acceptUsage(ref.getElement(), options)) {
|
||||
TextRange rangeInElement = ref.getRangeInElement();
|
||||
return processor.process(new UsageInfo(ref.getElement(), rangeInElement.getStartOffset(), rangeInElement.getEndOffset(), false));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean filterUsage(@NotNull PsiElement usage, @NotNull FindUsagesOptions options) {
|
||||
private static boolean acceptUsage(@NotNull PsiElement usage, @NotNull FindUsagesOptions options) {
|
||||
if (!(usage instanceof PsiJavaCodeReferenceElement)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,9 @@ public class PsiSuperMethodUtil {
|
||||
for (HierarchicalMethodSignature hms : superClass.getVisibleSignatures()) {
|
||||
PsiMethod method = hms.getMethod();
|
||||
if (MethodSignatureUtil.findMethodBySignature(aClass, method.getSignature(superClassSubstitutor), false) != null) continue;
|
||||
final PsiClass containingClass = correctClassByScope(method.getContainingClass(), resolveScope);
|
||||
PsiClass methodClass = method.getContainingClass();
|
||||
if (methodClass == null) continue;
|
||||
final PsiClass containingClass = correctClassByScope(methodClass, resolveScope);
|
||||
if (containingClass == null) continue;
|
||||
method = containingClass.findMethodBySignature(method, false);
|
||||
if (method == null) continue;
|
||||
@@ -90,11 +92,7 @@ public class PsiSuperMethodUtil {
|
||||
final PsiSubstitutor finalSubstitutor =
|
||||
obtainFinalSubstitutor(containingClass, containingClassSubstitutor, hms.getSubstitutor(), false);
|
||||
final MethodSignatureBackedByPsiMethod signature = MethodSignatureBackedByPsiMethod.create(method, finalSubstitutor, false);
|
||||
Set<PsiMethod> methods = overrideEquivalent.get(signature);
|
||||
if (methods == null) {
|
||||
methods = new LinkedHashSet<>();
|
||||
overrideEquivalent.put(signature, methods);
|
||||
}
|
||||
Set<PsiMethod> methods = overrideEquivalent.computeIfAbsent(signature, __ -> new LinkedHashSet<>());
|
||||
methods.add(method);
|
||||
}
|
||||
}
|
||||
@@ -102,8 +100,7 @@ public class PsiSuperMethodUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiClass correctClassByScope(PsiClass psiClass, final GlobalSearchScope resolveScope) {
|
||||
if (psiClass == null) return null;
|
||||
public static PsiClass correctClassByScope(@NotNull PsiClass psiClass, @NotNull GlobalSearchScope resolveScope) {
|
||||
String qualifiedName = psiClass.getQualifiedName();
|
||||
if (qualifiedName == null) {
|
||||
return psiClass;
|
||||
|
||||
@@ -34,10 +34,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.JBTreeTraverser;
|
||||
import gnu.trove.THashMap;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
@@ -77,14 +74,14 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PsiMethod findMethodBySignature(@NotNull PsiClass aClass, @NotNull PsiMethod patternMethod, final boolean checkBases) {
|
||||
final List<PsiMethod> result = findMethodsBySignature(aClass, patternMethod, checkBases, true);
|
||||
public static PsiMethod findMethodBySignature(@NotNull PsiClass aClass, @NotNull PsiMethod patternMethod, boolean checkBases) {
|
||||
List<PsiMethod> result = findMethodsBySignature(aClass, patternMethod, checkBases, true);
|
||||
return result.isEmpty() ? null : result.get(0);
|
||||
}
|
||||
|
||||
// ----------------------------- findMethodsBySignature -----------------------------------
|
||||
|
||||
public static PsiMethod @NotNull [] findMethodsBySignature(@NotNull PsiClass aClass, @NotNull PsiMethod patternMethod, final boolean checkBases) {
|
||||
public static PsiMethod @NotNull [] findMethodsBySignature(@NotNull PsiClass aClass, @NotNull PsiMethod patternMethod, boolean checkBases) {
|
||||
List<PsiMethod> methods = findMethodsBySignature(aClass, patternMethod, checkBases, false);
|
||||
return methods.toArray(PsiMethod.EMPTY_ARRAY);
|
||||
}
|
||||
@@ -94,16 +91,16 @@ public class PsiClassImplUtil {
|
||||
@NotNull PsiMethod patternMethod,
|
||||
boolean checkBases,
|
||||
boolean stopOnFirst) {
|
||||
final PsiMethod[] methodsByName = aClass.findMethodsByName(patternMethod.getName(), checkBases);
|
||||
PsiMethod[] methodsByName = aClass.findMethodsByName(patternMethod.getName(), checkBases);
|
||||
if (methodsByName.length == 0) return Collections.emptyList();
|
||||
final List<PsiMethod> methods = new SmartList<>();
|
||||
final MethodSignature patternSignature = patternMethod.getSignature(PsiSubstitutor.EMPTY);
|
||||
for (final PsiMethod method : methodsByName) {
|
||||
final PsiClass superClass = method.getContainingClass();
|
||||
final PsiSubstitutor substitutor = checkBases && !aClass.equals(superClass) && superClass != null ?
|
||||
List<PsiMethod> methods = new SmartList<>();
|
||||
MethodSignature patternSignature = patternMethod.getSignature(PsiSubstitutor.EMPTY);
|
||||
for (PsiMethod method : methodsByName) {
|
||||
PsiClass superClass = method.getContainingClass();
|
||||
PsiSubstitutor substitutor = checkBases && !aClass.equals(superClass) && superClass != null ?
|
||||
TypeConversionUtil.getSuperClassSubstitutor(superClass, aClass, PsiSubstitutor.EMPTY) :
|
||||
PsiSubstitutor.EMPTY;
|
||||
final MethodSignature signature = method.getSignature(substitutor);
|
||||
MethodSignature signature = method.getSignature(substitutor);
|
||||
if (signature.equals(patternSignature)) {
|
||||
methods.add(method);
|
||||
if (stopOnFirst) {
|
||||
@@ -220,7 +217,7 @@ public class PsiClassImplUtil {
|
||||
private static final Function<ClassIconRequest, Icon> FULL_ICON_EVALUATOR = (NullableFunction<ClassIconRequest, Icon>)r -> {
|
||||
if (!r.psiClass.isValid() || r.psiClass.getProject().isDisposed()) return null;
|
||||
|
||||
final boolean isLocked = BitUtil.isSet(r.flags, Iconable.ICON_FLAG_READ_STATUS) && !r.psiClass.isWritable();
|
||||
boolean isLocked = BitUtil.isSet(r.flags, Iconable.ICON_FLAG_READ_STATUS) && !r.psiClass.isWritable();
|
||||
Icon symbolIcon = r.symbolIcon != null
|
||||
? r.symbolIcon
|
||||
: ElementPresentationUtil.getClassIconOfKind(r.psiClass, ElementPresentationUtil.getClassKind(r.psiClass));
|
||||
@@ -231,7 +228,7 @@ public class PsiClassImplUtil {
|
||||
return result;
|
||||
};
|
||||
|
||||
public static Icon getClassIcon(final int flags, @NotNull PsiClass aClass) {
|
||||
public static Icon getClassIcon(int flags, @NotNull PsiClass aClass) {
|
||||
return getClassIcon(flags, aClass, null);
|
||||
}
|
||||
|
||||
@@ -253,10 +250,10 @@ public class PsiClassImplUtil {
|
||||
if (aClass instanceof PsiAnonymousClass) {
|
||||
return new LocalSearchScope(aClass);
|
||||
}
|
||||
final GlobalSearchScope maximalUseScope = ResolveScopeManager.getElementUseScope(aClass);
|
||||
GlobalSearchScope maximalUseScope = ResolveScopeManager.getElementUseScope(aClass);
|
||||
PsiFile file = aClass.getContainingFile();
|
||||
if (PsiImplUtil.isInServerPage(file)) return maximalUseScope;
|
||||
final PsiClass containingClass = aClass.getContainingClass();
|
||||
PsiClass containingClass = aClass.getContainingClass();
|
||||
if (aClass.hasModifierProperty(PsiModifier.PUBLIC) ||
|
||||
aClass.hasModifierProperty(PsiModifier.PROTECTED)) {
|
||||
return containingClass == null ? maximalUseScope : containingClass.getUseScope();
|
||||
@@ -318,7 +315,7 @@ public class PsiClassImplUtil {
|
||||
private static class MembersMap {
|
||||
final ConcurrentMap<MemberType, Map<String, PsiMember[]>> myMap;
|
||||
|
||||
MembersMap(PsiClass psiClass, GlobalSearchScope scope) {
|
||||
MembersMap(@NotNull PsiClass psiClass, @NotNull GlobalSearchScope scope) {
|
||||
myMap = createMembersMap(psiClass, scope);
|
||||
}
|
||||
|
||||
@@ -327,11 +324,11 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static ConcurrentMap<MemberType, Map<String, PsiMember[]>> createMembersMap(PsiClass psiClass, GlobalSearchScope scope) {
|
||||
private static @NotNull ConcurrentMap<MemberType, Map<String, PsiMember[]>> createMembersMap(@NotNull PsiClass psiClass, @NotNull GlobalSearchScope scope) {
|
||||
return ConcurrentFactoryMap.createMap(key -> {
|
||||
final Map<String, List<PsiMember>> map = new THashMap<>();
|
||||
Map<String, List<PsiMember>> map = new THashMap<>();
|
||||
|
||||
final List<PsiMember> allMembers = new ArrayList<>();
|
||||
List<PsiMember> allMembers = new ArrayList<>();
|
||||
map.put(ALL, allMembers);
|
||||
|
||||
JBTreeTraverser<PsiClass> allSupers = JBTreeTraverser
|
||||
@@ -360,7 +357,7 @@ public class PsiClassImplUtil {
|
||||
private static final ByNameCachedValueProvider INSTANCE = new ByNameCachedValueProvider();
|
||||
|
||||
@Override
|
||||
public CachedValueProvider.Result<Map<GlobalSearchScope, MembersMap>> compute(@NotNull final PsiClass myClass) {
|
||||
public CachedValueProvider.Result<Map<GlobalSearchScope, MembersMap>> compute(@NotNull PsiClass myClass) {
|
||||
Map<GlobalSearchScope, MembersMap> map = ConcurrentFactoryMap.createMap(scope -> new MembersMap(myClass, scope));
|
||||
return CachedValueProvider.Result.create(map, PsiModificationTracker.MODIFICATION_COUNT);
|
||||
}
|
||||
@@ -379,7 +376,7 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
|
||||
public static boolean processDeclarationsInClass(@NotNull PsiClass aClass,
|
||||
@NotNull final PsiScopeProcessor processor,
|
||||
@NotNull PsiScopeProcessor processor,
|
||||
@NotNull ResolveState state,
|
||||
@Nullable Set<PsiClass> visited,
|
||||
PsiElement last,
|
||||
@@ -390,7 +387,7 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
|
||||
private static boolean processDeclarationsInClass(@NotNull PsiClass aClass,
|
||||
@NotNull final PsiScopeProcessor processor,
|
||||
@NotNull PsiScopeProcessor processor,
|
||||
@NotNull ResolveState state,
|
||||
@Nullable Set<PsiClass> visited,
|
||||
PsiElement last,
|
||||
@@ -406,7 +403,7 @@ public class PsiClassImplUtil {
|
||||
PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY);
|
||||
isRaw = isRaw || PsiUtil.isRawSubstitutor(aClass, substitutor);
|
||||
|
||||
final NameHint nameHint = processor.getHint(NameHint.KEY);
|
||||
NameHint nameHint = processor.getHint(NameHint.KEY);
|
||||
if (nameHint != null) {
|
||||
String name = nameHint.getName(state);
|
||||
return processCachedMembersByName(aClass, processor, state, visited, last, place, isRaw, substitutor,
|
||||
@@ -415,18 +412,18 @@ public class PsiClassImplUtil {
|
||||
return processClassMembersWithAllNames(aClass, processor, state, visited, last, place, isRaw, languageLevel, resolveScope);
|
||||
}
|
||||
|
||||
private static boolean processCachedMembersByName(@NotNull final PsiClass aClass,
|
||||
private static boolean processCachedMembersByName(@NotNull PsiClass aClass,
|
||||
@NotNull PsiScopeProcessor processor,
|
||||
@NotNull ResolveState state,
|
||||
@Nullable Set<? super PsiClass> visited,
|
||||
PsiElement last,
|
||||
@NotNull final PsiElement place,
|
||||
final boolean isRaw,
|
||||
@NotNull final PsiSubstitutor substitutor,
|
||||
@NotNull PsiElement place,
|
||||
boolean isRaw,
|
||||
@NotNull PsiSubstitutor substitutor,
|
||||
@NotNull MembersMap value,
|
||||
String name,
|
||||
@NotNull final LanguageLevel languageLevel,
|
||||
final GlobalSearchScope resolveScope) {
|
||||
@NotNull LanguageLevel languageLevel,
|
||||
@NotNull GlobalSearchScope resolveScope) {
|
||||
Function<PsiMember, PsiSubstitutor> finalSubstitutor = new Function<PsiMember, PsiSubstitutor>() {
|
||||
final ScopedClassHierarchy hierarchy = ScopedClassHierarchy.getHierarchy(aClass, resolveScope);
|
||||
final PsiElementFactory factory = JavaPsiFacade.getElementFactory(aClass.getProject());
|
||||
@@ -444,22 +441,22 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
};
|
||||
|
||||
final ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);
|
||||
ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);
|
||||
|
||||
if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.FIELD)) {
|
||||
final PsiField fieldByName = aClass.findFieldByName(name, false);
|
||||
PsiField fieldByName = aClass.findFieldByName(name, false);
|
||||
if (fieldByName != null) {
|
||||
PsiUtilCore.ensureValid(fieldByName);
|
||||
processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, aClass);
|
||||
if (!processor.execute(fieldByName, state)) return false;
|
||||
}
|
||||
else {
|
||||
final Map<String, PsiMember[]> allFieldsMap = value.get(MemberType.FIELD);
|
||||
Map<String, PsiMember[]> allFieldsMap = value.get(MemberType.FIELD);
|
||||
|
||||
final PsiMember[] list = allFieldsMap.get(name);
|
||||
PsiMember[] list = allFieldsMap.get(name);
|
||||
if (list != null) {
|
||||
boolean resolved = false;
|
||||
for (final PsiMember candidateField : list) {
|
||||
for (PsiMember candidateField : list) {
|
||||
PsiClass containingClass = candidateField.getContainingClass();
|
||||
PsiUtilCore.ensureValid(candidateField);
|
||||
if (containingClass == null) {
|
||||
@@ -484,11 +481,11 @@ public class PsiClassImplUtil {
|
||||
if (!processor.execute(last, state)) return false;
|
||||
}
|
||||
// Parameters
|
||||
final PsiTypeParameterList list = aClass.getTypeParameterList();
|
||||
PsiTypeParameterList list = aClass.getTypeParameterList();
|
||||
if (list != null && !list.processDeclarations(processor, state, last, place)) return false;
|
||||
}
|
||||
if (!(last instanceof PsiReferenceList)) {
|
||||
final PsiClass classByName = aClass.findInnerClassByName(name, false);
|
||||
PsiClass classByName = aClass.findInnerClassByName(name, false);
|
||||
if (classByName != null) {
|
||||
PsiUtilCore.ensureValid(classByName);
|
||||
processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, aClass);
|
||||
@@ -500,7 +497,7 @@ public class PsiClassImplUtil {
|
||||
PsiMember[] list = allClassesMap.get(name);
|
||||
if (list != null) {
|
||||
boolean resolved = false;
|
||||
for (final PsiMember inner : list) {
|
||||
for (PsiMember inner : list) {
|
||||
PsiUtilCore.ensureValid(inner);
|
||||
PsiClass containingClass = inner.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
@@ -517,9 +514,9 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.METHOD)) {
|
||||
if (processor instanceof MethodResolverProcessor) {
|
||||
final MethodResolverProcessor methodResolverProcessor = (MethodResolverProcessor)processor;
|
||||
MethodResolverProcessor methodResolverProcessor = (MethodResolverProcessor)processor;
|
||||
if (methodResolverProcessor.isConstructor()) {
|
||||
final PsiMethod[] constructors = aClass.getConstructors();
|
||||
PsiMethod[] constructors = aClass.getConstructors();
|
||||
methodResolverProcessor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, aClass);
|
||||
for (PsiMethod constructor : constructors) {
|
||||
PsiUtilCore.ensureValid(constructor);
|
||||
@@ -532,14 +529,14 @@ public class PsiClassImplUtil {
|
||||
PsiMember[] list = allMethodsMap.get(name);
|
||||
if (list != null) {
|
||||
boolean resolved = false;
|
||||
for (final PsiMember candidate : list) {
|
||||
for (PsiMember candidate : list) {
|
||||
ProgressIndicatorProvider.checkCanceled();
|
||||
PsiMethod candidateMethod = (PsiMethod)candidate;
|
||||
PsiUtilCore.ensureValid(candidateMethod);
|
||||
if (processor instanceof MethodResolverProcessor) {
|
||||
if (candidateMethod.isConstructor() != ((MethodResolverProcessor)processor).isConstructor()) continue;
|
||||
}
|
||||
final PsiClass containingClass = candidateMethod.getContainingClass();
|
||||
PsiClass containingClass = candidateMethod.getContainingClass();
|
||||
if (containingClass == null || visited != null && visited.contains(containingClass)) {
|
||||
continue;
|
||||
}
|
||||
@@ -569,7 +566,7 @@ public class PsiClassImplUtil {
|
||||
//certain members of a raw type are not erased,
|
||||
//namely static members whose types are parameterized, and members inherited from a non-generic supertype.
|
||||
if (isRaw && !candidateMethod.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
final PsiClass containingClass = candidateMethod.getContainingClass();
|
||||
PsiClass containingClass = candidateMethod.getContainingClass();
|
||||
if (containingClass != null && containingClass.hasTypeParameters()) {
|
||||
PsiTypeParameter[] methodTypeParameters = candidateMethod.getTypeParameters();
|
||||
substitutor = factory.createRawSubstitutor(substitutor, methodTypeParameters);
|
||||
@@ -587,26 +584,26 @@ public class PsiClassImplUtil {
|
||||
if (PsiUtil.isRawSubstitutor(aClass, substitutor)) {
|
||||
return elementFactory.createRawSubstitutor(candidateClass).putAll(substitutor);
|
||||
}
|
||||
final PsiType containingType = elementFactory.createType(candidateClass, candidateSubstitutor, languageLevel);
|
||||
PsiType containingType = elementFactory.createType(candidateClass, candidateSubstitutor, languageLevel);
|
||||
PsiType type = substitutor.substitute(containingType);
|
||||
if (!(type instanceof PsiClassType)) return candidateSubstitutor;
|
||||
return ((PsiClassType)type).resolveGenerics().getSubstitutor();
|
||||
}
|
||||
|
||||
private static boolean processClassMembersWithAllNames(@NotNull PsiClass aClass,
|
||||
@NotNull final PsiScopeProcessor processor,
|
||||
@NotNull final ResolveState state,
|
||||
@NotNull PsiScopeProcessor processor,
|
||||
@NotNull ResolveState state,
|
||||
@Nullable Set<PsiClass> visited,
|
||||
final PsiElement last,
|
||||
@NotNull final PsiElement place,
|
||||
final boolean isRaw,
|
||||
@NotNull final LanguageLevel languageLevel,
|
||||
@NotNull final GlobalSearchScope resolveScope) {
|
||||
PsiElement last,
|
||||
@NotNull PsiElement place,
|
||||
boolean isRaw,
|
||||
@NotNull LanguageLevel languageLevel,
|
||||
@NotNull GlobalSearchScope resolveScope) {
|
||||
ProgressManager.checkCanceled();
|
||||
if (visited == null) visited = new THashSet<>();
|
||||
if (!visited.add(aClass)) return true;
|
||||
processor.handleEvent(PsiScopeProcessor.Event.SET_DECLARATION_HOLDER, aClass);
|
||||
final ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);
|
||||
ElementClassHint classHint = processor.getHint(ElementClassHint.KEY);
|
||||
|
||||
if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.FIELD)) {
|
||||
for (PsiField field : aClass.getFields()) {
|
||||
@@ -628,7 +625,7 @@ public class PsiClassImplUtil {
|
||||
if (classHint == null || classHint.shouldProcess(ElementClassHint.DeclarationKind.CLASS)) {
|
||||
if (last != null && last.getContext() == aClass) {
|
||||
// Parameters
|
||||
final PsiTypeParameterList list = aClass.getTypeParameterList();
|
||||
PsiTypeParameterList list = aClass.getTypeParameterList();
|
||||
if (list != null && !list.processDeclarations(processor, ResolveState.initial(), last, place)) return false;
|
||||
}
|
||||
|
||||
@@ -641,14 +638,14 @@ public class PsiClassImplUtil {
|
||||
|
||||
if (last instanceof PsiReferenceList) return true;
|
||||
|
||||
final Set<PsiClass> visited1 = visited;
|
||||
Set<PsiClass> visited1 = visited;
|
||||
return processSuperTypes(aClass, state.get(PsiSubstitutor.KEY), factory, languageLevel, resolveScope,
|
||||
(superClass, finalSubstitutor) -> processDeclarationsInClass(superClass, processor, state.put(PsiSubstitutor.KEY, finalSubstitutor), visited1, last, place,
|
||||
languageLevel, isRaw, resolveScope));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <T extends PsiType> T correctType(@Nullable final T originalType, @NotNull final GlobalSearchScope resolveScope) {
|
||||
public static <T extends PsiType> T correctType(@Nullable T originalType, @NotNull GlobalSearchScope resolveScope) {
|
||||
if (originalType == null || !Registry.is("java.correct.class.type.by.place.resolve.scope")) {
|
||||
return originalType;
|
||||
}
|
||||
@@ -656,7 +653,7 @@ public class PsiClassImplUtil {
|
||||
return new TypeCorrector(resolveScope).correctType(originalType);
|
||||
}
|
||||
|
||||
public static List<PsiClassType.ClassResolveResult> getScopeCorrectedSuperTypes(final PsiClass aClass, GlobalSearchScope resolveScope) {
|
||||
public static List<PsiClassType.ClassResolveResult> getScopeCorrectedSuperTypes(PsiClass aClass, GlobalSearchScope resolveScope) {
|
||||
PsiUtilCore.ensureValid(aClass);
|
||||
return ScopedClassHierarchy.getHierarchy(aClass, resolveScope).getImmediateSupersWithCapturing();
|
||||
}
|
||||
@@ -701,7 +698,7 @@ public class PsiClassImplUtil {
|
||||
|
||||
if (CommonClassNames.JAVA_LANG_OBJECT.equals(psiClass.getQualifiedName())) return null;
|
||||
|
||||
final PsiClassType[] referenceElements = psiClass.getExtendsListTypes();
|
||||
PsiClassType[] referenceElements = psiClass.getExtendsListTypes();
|
||||
|
||||
if (referenceElements.length == 0) return findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_OBJECT);
|
||||
|
||||
@@ -715,8 +712,8 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
|
||||
public static PsiClass @NotNull [] getSupers(@NotNull PsiClass psiClass) {
|
||||
final PsiClass[] supers = getSupersInner(psiClass);
|
||||
for (final PsiClass aSuper : supers) {
|
||||
PsiClass[] supers = getSupersInner(psiClass);
|
||||
for (PsiClass aSuper : supers) {
|
||||
LOG.assertTrue(aSuper != null);
|
||||
}
|
||||
return supers;
|
||||
@@ -746,7 +743,7 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
if (psiClass instanceof PsiTypeParameter) {
|
||||
if (extendsListTypes.length == 0) {
|
||||
final PsiClass objectClass = findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_OBJECT);
|
||||
PsiClass objectClass = findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_OBJECT);
|
||||
return objectClass != null ? new PsiClass[]{objectClass} : PsiClass.EMPTY_ARRAY;
|
||||
}
|
||||
return resolveClassReferenceList(extendsListTypes, psiClass, false);
|
||||
@@ -803,7 +800,7 @@ public class PsiClassImplUtil {
|
||||
|
||||
private static PsiClassType getEnumSuperType(@NotNull PsiClass psiClass, @NotNull PsiElementFactory factory) {
|
||||
PsiClassType superType;
|
||||
final PsiClass enumClass = findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_ENUM);
|
||||
PsiClass enumClass = findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_ENUM);
|
||||
if (enumClass == null) {
|
||||
try {
|
||||
superType = (PsiClassType)factory.createTypeFromText(CommonClassNames.JAVA_LANG_ENUM, null);
|
||||
@@ -813,7 +810,7 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
}
|
||||
else {
|
||||
final PsiTypeParameter[] typeParameters = enumClass.getTypeParameters();
|
||||
PsiTypeParameter[] typeParameters = enumClass.getTypeParameters();
|
||||
PsiSubstitutor substitutor = PsiSubstitutor.EMPTY;
|
||||
if (typeParameters.length == 1) {
|
||||
substitutor = substitutor.put(typeParameters[0], factory.createType(psiClass));
|
||||
@@ -824,13 +821,13 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
|
||||
public static PsiClass @NotNull [] getInterfaces(@NotNull PsiTypeParameter typeParameter) {
|
||||
final PsiClassType[] referencedTypes = typeParameter.getExtendsListTypes();
|
||||
PsiClassType[] referencedTypes = typeParameter.getExtendsListTypes();
|
||||
if (referencedTypes.length == 0) {
|
||||
return PsiClass.EMPTY_ARRAY;
|
||||
}
|
||||
final List<PsiClass> result = new ArrayList<>(referencedTypes.length);
|
||||
List<PsiClass> result = new ArrayList<>(referencedTypes.length);
|
||||
for (PsiClassType referencedType : referencedTypes) {
|
||||
final PsiClass psiClass = referencedType.resolve();
|
||||
PsiClass psiClass = referencedType.resolve();
|
||||
if (psiClass != null && psiClass.isInterface()) {
|
||||
result.add(psiClass);
|
||||
}
|
||||
@@ -849,7 +846,7 @@ public class PsiClassImplUtil {
|
||||
return baseClass != null && baseClass.isInterface() ? new PsiClass[]{baseClass} : PsiClass.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
final PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes();
|
||||
PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes();
|
||||
return resolveClassReferenceList(implementsListTypes, psiClass, false);
|
||||
}
|
||||
|
||||
@@ -892,9 +889,9 @@ public class PsiClassImplUtil {
|
||||
String name,
|
||||
boolean checkBases) {
|
||||
if (!checkBases) {
|
||||
final PsiMethod[] methodsByName = psiClass.findMethodsByName(name, false);
|
||||
final List<Pair<PsiMethod, PsiSubstitutor>> ret = new ArrayList<>(methodsByName.length);
|
||||
for (final PsiMethod method : methodsByName) {
|
||||
PsiMethod[] methodsByName = psiClass.findMethodsByName(name, false);
|
||||
List<Pair<PsiMethod, PsiSubstitutor>> ret = new ArrayList<>(methodsByName.length);
|
||||
for (PsiMethod method : methodsByName) {
|
||||
ret.add(Pair.create(method, PsiSubstitutor.EMPTY));
|
||||
}
|
||||
return ret;
|
||||
@@ -905,9 +902,9 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static <T extends PsiMember> List<Pair<T, PsiSubstitutor>> withSubstitutors(@NotNull final PsiClass psiClass, PsiMember[] members) {
|
||||
final ScopedClassHierarchy hierarchy = ScopedClassHierarchy.getHierarchy(psiClass, psiClass.getResolveScope());
|
||||
final LanguageLevel level = PsiUtil.getLanguageLevel(psiClass);
|
||||
private static <T extends PsiMember> List<Pair<T, PsiSubstitutor>> withSubstitutors(@NotNull PsiClass psiClass, PsiMember[] members) {
|
||||
ScopedClassHierarchy hierarchy = ScopedClassHierarchy.getHierarchy(psiClass, psiClass.getResolveScope());
|
||||
LanguageLevel level = PsiUtil.getLanguageLevel(psiClass);
|
||||
return ContainerUtil.map(members, member -> {
|
||||
PsiClass containingClass = member.getContainingClass();
|
||||
PsiSubstitutor substitutor = containingClass == null ? null : hierarchy.getSuperMembersSubstitutor(containingClass, level);
|
||||
@@ -922,7 +919,7 @@ public class PsiClassImplUtil {
|
||||
return enumSuperType == null ? PsiClassType.EMPTY_ARRAY : new PsiClassType[]{enumSuperType};
|
||||
}
|
||||
if (psiClass.isRecord()) {
|
||||
final PsiClass recordClass = findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_RECORD);
|
||||
PsiClass recordClass = findSpecialSuperClass(psiClass, CommonClassNames.JAVA_LANG_RECORD);
|
||||
if (recordClass != null) {
|
||||
return new PsiClassType[]{new PsiImmediateClassType(recordClass, PsiSubstitutor.EMPTY)};
|
||||
}
|
||||
@@ -937,8 +934,8 @@ public class PsiClassImplUtil {
|
||||
upperBound = ThreadLocalTypes.getElementType(psiClass);
|
||||
}
|
||||
if (upperBound instanceof PsiIntersectionType) {
|
||||
final PsiType[] conjuncts = ((PsiIntersectionType)upperBound).getConjuncts();
|
||||
final List<PsiClassType> result = new ArrayList<>();
|
||||
PsiType[] conjuncts = ((PsiIntersectionType)upperBound).getConjuncts();
|
||||
List<PsiClassType> result = new ArrayList<>();
|
||||
for (PsiType conjunct : conjuncts) {
|
||||
if (conjunct instanceof PsiClassType) {
|
||||
result.add((PsiClassType)conjunct);
|
||||
@@ -949,7 +946,7 @@ public class PsiClassImplUtil {
|
||||
if (upperBound instanceof PsiClassType) {
|
||||
return new PsiClassType[] {(PsiClassType)upperBound};
|
||||
}
|
||||
final PsiReferenceList extendsList = psiClass.getExtendsList();
|
||||
PsiReferenceList extendsList = psiClass.getExtendsList();
|
||||
if (extendsList != null) {
|
||||
return extendsList.getReferencedTypes();
|
||||
}
|
||||
@@ -957,7 +954,7 @@ public class PsiClassImplUtil {
|
||||
}
|
||||
|
||||
public static PsiClassType @NotNull [] getImplementsListTypes(@NotNull PsiClass psiClass) {
|
||||
final PsiReferenceList extendsList = psiClass.getImplementsList();
|
||||
PsiReferenceList extendsList = psiClass.getImplementsList();
|
||||
if (extendsList != null) {
|
||||
return extendsList.getReferencedTypes();
|
||||
}
|
||||
@@ -979,7 +976,7 @@ public class PsiClassImplUtil {
|
||||
upperBound = ThreadLocalTypes.getElementType(psiClass);
|
||||
}
|
||||
if (upperBound instanceof PsiIntersectionType) {
|
||||
final PsiType[] conjuncts = ((PsiIntersectionType)upperBound).getConjuncts();
|
||||
PsiType[] conjuncts = ((PsiIntersectionType)upperBound).getConjuncts();
|
||||
for (PsiType conjunct : conjuncts) {
|
||||
if (conjunct instanceof PsiClassType && ((PsiClassType)conjunct).getClassName().equals(baseName) && baseClass.equals(((PsiClassType)conjunct).resolve())) {
|
||||
return true;
|
||||
@@ -1089,20 +1086,20 @@ public class PsiClassImplUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
final PsiFile file1 = getOriginalFile(aClass);
|
||||
final PsiFile file2 = getOriginalFile((PsiClass)another);
|
||||
PsiFile file1 = getOriginalFile(aClass);
|
||||
PsiFile file2 = getOriginalFile((PsiClass)another);
|
||||
|
||||
//see com.intellij.openapi.vcs.changes.PsiChangeTracker
|
||||
//see com.intellij.psi.impl.PsiFileFactoryImpl#createFileFromText(CharSequence,PsiFile)
|
||||
final PsiFile original1 = file1.getUserData(PsiFileFactory.ORIGINAL_FILE);
|
||||
final PsiFile original2 = file2.getUserData(PsiFileFactory.ORIGINAL_FILE);
|
||||
PsiFile original1 = file1.getUserData(PsiFileFactory.ORIGINAL_FILE);
|
||||
PsiFile original2 = file2.getUserData(PsiFileFactory.ORIGINAL_FILE);
|
||||
if (original1 == original2 && original1 != null || original1 == file2 || original2 == file1 || file1 == file2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final FileIndexFacade fileIndex = ServiceManager.getService(file1.getProject(), FileIndexFacade.class);
|
||||
final VirtualFile vfile1 = file1.getViewProvider().getVirtualFile();
|
||||
final VirtualFile vfile2 = file2.getViewProvider().getVirtualFile();
|
||||
FileIndexFacade fileIndex = ServiceManager.getService(file1.getProject(), FileIndexFacade.class);
|
||||
VirtualFile vfile1 = file1.getViewProvider().getVirtualFile();
|
||||
VirtualFile vfile2 = file2.getViewProvider().getVirtualFile();
|
||||
boolean lib1 = fileIndex.isInLibraryClasses(vfile1);
|
||||
boolean lib2 = fileIndex.isInLibraryClasses(vfile2);
|
||||
|
||||
@@ -1158,8 +1155,8 @@ public class PsiClassImplUtil {
|
||||
private static boolean compareParamTypes(@NotNull PsiManager manager, @NotNull PsiType type1, @NotNull PsiType type2, Set<? super String> visited) {
|
||||
if (type1 instanceof PsiArrayType) {
|
||||
if (type2 instanceof PsiArrayType) {
|
||||
final PsiType componentType1 = ((PsiArrayType)type1).getComponentType();
|
||||
final PsiType componentType2 = ((PsiArrayType)type2).getComponentType();
|
||||
PsiType componentType1 = ((PsiArrayType)type1).getComponentType();
|
||||
PsiType componentType2 = ((PsiArrayType)type2).getComponentType();
|
||||
if (compareParamTypes(manager, componentType1, componentType2, visited)) return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1176,8 +1173,8 @@ public class PsiClassImplUtil {
|
||||
|
||||
if (class1 instanceof PsiTypeParameter && class2 instanceof PsiTypeParameter) {
|
||||
if (!(Objects.equals(class1.getName(), class2.getName()) && ((PsiTypeParameter)class1).getIndex() == ((PsiTypeParameter)class2).getIndex())) return false;
|
||||
final PsiClassType[] eTypes1 = class1.getExtendsListTypes();
|
||||
final PsiClassType[] eTypes2 = class2.getExtendsListTypes();
|
||||
PsiClassType[] eTypes1 = class1.getExtendsListTypes();
|
||||
PsiClassType[] eTypes2 = class2.getExtendsListTypes();
|
||||
if (eTypes1.length != eTypes2.length) return false;
|
||||
for (int i = 0; i < eTypes1.length; i++) {
|
||||
PsiClassType eType1 = eTypes1[i];
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ public class HighlightingSessionImpl implements HighlightingSession {
|
||||
myEDTQueue.offer(runnable);
|
||||
}
|
||||
|
||||
public static HighlightingSession getHighlightingSession(@NotNull PsiFile psiFile, @NotNull ProgressIndicator progressIndicator) {
|
||||
private static HighlightingSession getHighlightingSession(@NotNull PsiFile psiFile, @NotNull ProgressIndicator progressIndicator) {
|
||||
Map<PsiFile, HighlightingSession> map = ((DaemonProgressIndicator)progressIndicator).getUserData(HIGHLIGHTING_SESSION);
|
||||
return map == null ? null : map.get(psiFile);
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public class HighlightingSessionImpl implements HighlightingSession {
|
||||
if (session == null) {
|
||||
ConcurrentMap<PsiFile, HighlightingSession> map = progressIndicator.getUserData(HIGHLIGHTING_SESSION);
|
||||
if (map == null) {
|
||||
map = progressIndicator.putUserDataIfAbsent(HIGHLIGHTING_SESSION, new ConcurrentHashMap<PsiFile, HighlightingSession>());
|
||||
map = progressIndicator.putUserDataIfAbsent(HIGHLIGHTING_SESSION, new ConcurrentHashMap<>());
|
||||
}
|
||||
session = ConcurrencyUtil.cacheOrGet(map, psiFile,
|
||||
new HighlightingSessionImpl(psiFile, progressIndicator, editorColorsScheme));
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
*
|
||||
* @param <R> type of search result, it is used to bind type of search parameters to the type of {@link Query}
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public interface SearchParameters<R> {
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user