mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-18 20:41:22 +07:00
PY-70247 Cache the stub-based computation of ScopeUtilCore.getScopeOwner()
GitOrigin-RevId: 5eca49ca75c7bb6b1bccd2dc3a7d4cd5f3009725
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cf177b24d9
commit
9198c0fb92
@@ -33,6 +33,11 @@ public final class ScopeUtilCore {
|
||||
final PsiElement context = element.getContext();
|
||||
return context instanceof AstScopeOwner ? (AstScopeOwner)context : getScopeOwner(context);
|
||||
}
|
||||
return CachedValuesManager.getCachedValue(element, () -> CachedValueProvider.Result
|
||||
.create(calculateScopeOwner(element), PsiModificationTracker.MODIFICATION_COUNT));
|
||||
}
|
||||
|
||||
private static @Nullable AstScopeOwner calculateScopeOwner(@Nullable PsiElement element) {
|
||||
if (element instanceof StubBasedPsiElement<?> stubBasedElement) {
|
||||
final StubElement<?> stub = stubBasedElement.getStub();
|
||||
if (stub != null) {
|
||||
@@ -52,11 +57,6 @@ public final class ScopeUtilCore {
|
||||
return firstOwner;
|
||||
}
|
||||
}
|
||||
return CachedValuesManager.getCachedValue(element, () -> CachedValueProvider.Result
|
||||
.create(calculateScopeOwnerByAST(element), PsiModificationTracker.MODIFICATION_COUNT));
|
||||
}
|
||||
|
||||
private static @Nullable AstScopeOwner calculateScopeOwnerByAST(@Nullable PsiElement element) {
|
||||
final AstScopeOwner firstOwner = getParentOfType(element, AstScopeOwner.class);
|
||||
if (firstOwner == null) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user