mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Revert incomplete implementation of PyTypeVisitor polluting public API
except PyCollectionType extending PyClassType that makes a lot of sense since both PyCollectionTypeImpl and PyTupleType already extend PyClassTypeImpl, but one still needs explicit casts to PyCollectionTypeImpl to access the corresponding class definition.
This commit is contained in:
@@ -65,9 +65,4 @@ public interface PyClassLikeType extends PyCallableType, PyWithAncestors, PyInst
|
||||
|
||||
@Nullable
|
||||
PyClassLikeType getMetaClassType(@NotNull TypeEvalContext context, boolean inherited);
|
||||
|
||||
@Override
|
||||
default void accept(@NotNull PyTypeVisitor visitor) {
|
||||
visitor.visitClassLikeType(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,4 @@ public interface PyType {
|
||||
boolean isBuiltin();
|
||||
|
||||
void assertValid(String message);
|
||||
|
||||
default void accept(@NotNull PyTypeVisitor visitor) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.psi.types;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Mikhail Golubev
|
||||
*/
|
||||
public abstract class PyTypeVisitor {
|
||||
public void visitType(@NotNull PyType type) {}
|
||||
|
||||
public void visitCallableType(@NotNull PyCallableType type) {
|
||||
visitType(type);
|
||||
}
|
||||
|
||||
public void visitFunctionType(@NotNull PyFunctionType type) {
|
||||
visitCallableType(type);
|
||||
}
|
||||
|
||||
public void visitClassLikeType(@NotNull PyClassLikeType type) {
|
||||
visitCallableType(type);
|
||||
}
|
||||
|
||||
public void visitClassType(@NotNull PyClassType type) {
|
||||
visitClassLikeType(type);
|
||||
}
|
||||
}
|
||||
@@ -110,11 +110,4 @@ public class PyCallableTypeImpl implements PyCallableType {
|
||||
@Override
|
||||
public void assertValid(String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PyTypeVisitor visitor) {
|
||||
if (visitor instanceof PyTypeVisitorExt) {
|
||||
visitor.visitCallableType(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -901,9 +901,4 @@ public class PyClassTypeImpl extends UserDataHolderBase implements PyClassType {
|
||||
return (instance != target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PyTypeVisitor visitor) {
|
||||
visitor.visitClassType(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,11 +111,4 @@ public class PyCollectionTypeImpl extends PyClassTypeImpl implements PyCollectio
|
||||
// TODO: Select the parameter type that matches T in Iterable[T]
|
||||
return ContainerUtil.getFirstItem(myElementTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PyTypeVisitor visitor) {
|
||||
if (visitor instanceof PyTypeVisitorExt) {
|
||||
((PyTypeVisitorExt)visitor).visitCollectionType(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,9 +182,4 @@ public class PyFunctionTypeImpl implements PyFunctionType {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PyTypeVisitor visitor) {
|
||||
visitor.visitFunctionType(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,11 +131,4 @@ public class PyGenericType implements PyType, PyInstantiableType<PyGenericType>
|
||||
public PyGenericType toClass() {
|
||||
return myIsDefinition ? this : new PyGenericType(myName, myBound, true, myTargetExpression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PyTypeVisitor visitor) {
|
||||
if (visitor instanceof PyTypeVisitorExt) {
|
||||
((PyTypeVisitorExt)visitor).visitGenericType(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,13 +123,6 @@ public class PyImportedModuleType implements PyType {
|
||||
return myImportedModule;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PyTypeVisitor visitor) {
|
||||
if (visitor instanceof PyTypeVisitorExt) {
|
||||
((PyTypeVisitorExt)visitor).visitImportedModuleType(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
||||
@@ -507,10 +507,4 @@ public class PyModuleType implements PyType { // Modules don't descend from obje
|
||||
return MODULE_MEMBERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PyTypeVisitor visitor) {
|
||||
if (visitor instanceof PyTypeVisitorExt) {
|
||||
((PyTypeVisitorExt)visitor).visitModuleType(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,11 +60,4 @@ public class PyNoneType implements PyType { // TODO must extend ClassType. It's
|
||||
@Override
|
||||
public void assertValid(String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PyTypeVisitor visitor) {
|
||||
if (visitor instanceof PyTypeVisitorExt) {
|
||||
((PyTypeVisitorExt)visitor).visitNoneType(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,11 +88,4 @@ public class PyStructuralType implements PyType {
|
||||
public Set<String> getAttributeNames() {
|
||||
return myAttributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PyTypeVisitor visitor) {
|
||||
if (visitor instanceof PyTypeVisitorExt) {
|
||||
((PyTypeVisitorExt)visitor).visitStructuralType(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,11 +124,4 @@ public class PyTupleType extends PyClassTypeImpl implements PyCollectionType {
|
||||
public PyType getIteratedItemType() {
|
||||
return PyUnionType.union(myElementTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PyTypeVisitor visitor) {
|
||||
if (visitor instanceof PyTypeVisitorExt) {
|
||||
((PyTypeVisitorExt)visitor).visitTupleType(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.psi.types;
|
||||
|
||||
import com.jetbrains.python.codeInsight.stdlib.PyNamedTupleType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Mikhail Golubev
|
||||
*/
|
||||
public abstract class PyTypeVisitorExt extends PyTypeVisitor {
|
||||
|
||||
public void visitNoneType(@NotNull PyNoneType type) {
|
||||
visitType(type);
|
||||
}
|
||||
|
||||
public void visitUnionType(@NotNull PyUnionType type) {
|
||||
visitType(type);
|
||||
}
|
||||
|
||||
public void visitGenericType(@NotNull PyGenericType type) {
|
||||
visitType(type);
|
||||
}
|
||||
|
||||
public void visitCollectionType(@NotNull PyCollectionType type) {
|
||||
visitClassType(type);
|
||||
}
|
||||
|
||||
public void visitTupleType(@NotNull PyTupleType type) {
|
||||
visitCollectionType(type);
|
||||
}
|
||||
|
||||
public void visitNamedTupleType(@NotNull PyNamedTupleType type) {
|
||||
visitTupleType(type);
|
||||
}
|
||||
|
||||
public void visitStructuralType(@NotNull PyStructuralType type) {
|
||||
visitType(type);
|
||||
}
|
||||
|
||||
public void visitImportedModuleType(@NotNull PyImportedModuleType type) {
|
||||
visitType(type);
|
||||
}
|
||||
|
||||
public void visitModuleType(@NotNull PyModuleType type) {
|
||||
visitType(type);
|
||||
}
|
||||
}
|
||||
@@ -219,11 +219,4 @@ public class PyUnionType implements PyType {
|
||||
public String toString() {
|
||||
return "PyUnionType: " + getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(@NotNull PyTypeVisitor visitor) {
|
||||
if (visitor instanceof PyTypeVisitorExt) {
|
||||
((PyTypeVisitorExt)visitor).visitUnionType(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user