mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 23:39:39 +07:00
[java-analysis] PsiSubstitutor.hasRawSubstitution
Optimize partially IDEA-353780 Syntax Analysis hangs forever with complex use of Java generic parameters GitOrigin-RevId: 3b6d77db8353c21e0d09c9c28d551c1edd6c5e1d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
efea905a99
commit
3f46270d18
@@ -41,6 +41,11 @@ public final class EmptySubstitutor implements PsiSubstitutor {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRawSubstitution() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiType substituteWithBoundsPromotion(@NotNull PsiTypeParameter typeParameter) {
|
||||
return JavaPsiFacade.getElementFactory(typeParameter.getProject()).createType(typeParameter);
|
||||
|
||||
@@ -51,6 +51,13 @@ public interface PsiSubstitutor {
|
||||
@Contract(pure = true, value = "null -> null")
|
||||
PsiType substitute(@Nullable PsiType type);
|
||||
|
||||
/**
|
||||
* @return true if this substitutor has at least one raw substitution
|
||||
*/
|
||||
default boolean hasRawSubstitution() {
|
||||
return getSubstitutionMap().containsValue(null);
|
||||
}
|
||||
|
||||
//Should be used with great care, be sure to prevent infinite recursion that could arise
|
||||
// from the use of recursively bounded type parameters
|
||||
@Contract(pure = true)
|
||||
|
||||
@@ -1057,7 +1057,7 @@ public final class PsiUtil extends PsiUtilCore {
|
||||
}
|
||||
|
||||
public static boolean isRawSubstitutor(@NotNull PsiTypeParameterListOwner owner, @NotNull PsiSubstitutor substitutor) {
|
||||
if (substitutor == PsiSubstitutor.EMPTY) return false;
|
||||
if (!substitutor.hasRawSubstitution()) return false;
|
||||
|
||||
for (PsiTypeParameter parameter : typeParametersIterable(owner)) {
|
||||
if (substitutor.substitute(parameter) == null) return true;
|
||||
|
||||
Reference in New Issue
Block a user