PY-34617 Move getTopLevelAttributes(), findTopLevelAttribute() from PyAstFile

GitOrigin-RevId: 226a7e968851ab0c8730bb79ca90d0ed5dcec364
This commit is contained in:
Petr
2024-07-26 19:09:29 +02:00
committed by intellij-monorepo-bot
parent cfa28c0d2a
commit 16a7fb4b3e
4 changed files with 47 additions and 24 deletions

View File

@@ -17,7 +17,6 @@ package com.jetbrains.python.ast;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiNamedElement;
import com.jetbrains.python.ast.controlFlow.AstScopeOwner;
import com.jetbrains.python.ast.docstring.DocStringUtilCore;
import com.jetbrains.python.psi.FutureFeature;
@@ -41,13 +40,6 @@ public interface PyAstFile extends PyAstElement, PsiFile, PyAstDocStringOwner, A
return stmts;
}
List<? extends PyAstTargetExpression> getTopLevelAttributes();
@Nullable
default PyAstTargetExpression findTopLevelAttribute(@NotNull String name) {
return findByName(name, getTopLevelAttributes());
}
LanguageLevel getLanguageLevel();
/**
@@ -55,15 +47,6 @@ public interface PyAstFile extends PyAstElement, PsiFile, PyAstDocStringOwner, A
*/
boolean hasImportFromFuture(FutureFeature feature);
private static <T extends PsiNamedElement> T findByName(@NotNull String name, @NotNull List<T> namedElements) {
for (T namedElement : namedElements) {
if (name.equals(namedElement.getName())) {
return namedElement;
}
}
return null;
}
@ApiStatus.Internal
default boolean isAcceptedFor(@NotNull Class<?> visitorClass) {
return true;