mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-78236 Rename PyTypeVisitor#visitPyType to just #visit, add javadoc
Similarly to PyRecursiveTypeVisitor#traverse and PyCloningTypeVisitor#clone. GitOrigin-RevId: 285537e4b7f9326ded81dcd648fa510572c0aba3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7fd8018705
commit
d5e40b4ad4
@@ -75,7 +75,7 @@ public interface PyType {
|
||||
void assertValid(String message);
|
||||
|
||||
/**
|
||||
* For nullable {@code PyType} instance use {@link PyTypeVisitor#visitPyType(PyType, PyTypeVisitor)}
|
||||
* For nullable {@code PyType} instance use {@link PyTypeVisitor#visit(PyType, PyTypeVisitor)}
|
||||
* to visit {@code null} values with {@link PyTypeVisitor#visitUnknownType()}.
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
|
||||
@@ -21,12 +21,16 @@ import org.jetbrains.annotations.Nullable;
|
||||
* @see PyRecursiveTypeVisitor
|
||||
* @see PyCloningTypeVisitor
|
||||
* @see PyType#acceptTypeVisitor(PyTypeVisitor)
|
||||
* @see #visitPyType(PyType, PyTypeVisitor)
|
||||
* @see #visit(PyType, PyTypeVisitor)
|
||||
* @see #visitUnknownType()
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
public abstract class PyTypeVisitor<T> {
|
||||
public static <T> T visitPyType(@Nullable PyType type, @NotNull PyTypeVisitor<T> visitor) {
|
||||
/**
|
||||
* Use this method instead of {@link PyType#acceptTypeVisitor(PyTypeVisitor)} to take into account
|
||||
* "unknown" {@code null} types, for which {@link #visitUnknownType()} should be called.
|
||||
*/
|
||||
public static <T> T visit(@Nullable PyType type, @NotNull PyTypeVisitor<T> visitor) {
|
||||
return type == null ? visitor.visitUnknownType() : type.acceptTypeVisitor(visitor);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public abstract class PyCloningTypeVisitor extends PyTypeVisitorExt<PyType> {
|
||||
}
|
||||
try {
|
||||
//noinspection unchecked
|
||||
return (T)visitPyType(type, this);
|
||||
return (T)visit(type, this);
|
||||
}
|
||||
finally {
|
||||
cloning.remove(type);
|
||||
|
||||
+4
-4
@@ -48,13 +48,13 @@ public final class PyRecursiveTypeVisitor extends PyTypeVisitorExt<PyRecursiveTy
|
||||
return Traversal.CONTINUE;
|
||||
}
|
||||
try {
|
||||
Traversal next = visitPyType(type, myTraverser);
|
||||
Traversal next = visit(type, myTraverser);
|
||||
if (next == Traversal.TERMINATE) {
|
||||
return Traversal.TERMINATE;
|
||||
}
|
||||
if (next != Traversal.PRUNE) {
|
||||
for (@Nullable PyType childType : visitPyType(type, myComponentsStrategy)) {
|
||||
if (visitPyType(childType, this) == Traversal.TERMINATE) {
|
||||
for (@Nullable PyType childType : visit(type, myComponentsStrategy)) {
|
||||
if (visit(childType, this) == Traversal.TERMINATE) {
|
||||
return Traversal.TERMINATE;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public final class PyRecursiveTypeVisitor extends PyTypeVisitorExt<PyRecursiveTy
|
||||
}
|
||||
|
||||
public static void traverse(@Nullable PyType type, @NotNull TypeEvalContext context, @NotNull PyTypeTraverser delegate) {
|
||||
visitPyType(type, new PyRecursiveTypeVisitor(delegate, context));
|
||||
visit(type, new PyRecursiveTypeVisitor(delegate, context));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user