mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'new-mro'
Conflicts: python/src/META-INF/python-plugin-common.xml
This commit is contained in:
@@ -9,6 +9,8 @@ import com.intellij.util.ArrayFactory;
|
||||
import com.intellij.util.Processor;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
||||
import com.jetbrains.python.psi.stubs.PyClassStub;
|
||||
import com.jetbrains.python.psi.types.PyClassLikeType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -42,6 +44,9 @@ public interface PyClass extends PsiNameIdentifierOwner, PyStatement, NameDefine
|
||||
@NotNull
|
||||
PsiElement[] getSuperClassElements();
|
||||
|
||||
@NotNull
|
||||
List<PyClassLikeType> getSuperClassTypes(@NotNull TypeEvalContext context);
|
||||
|
||||
@NotNull
|
||||
PyClass[] getSuperClasses();
|
||||
|
||||
@@ -105,24 +110,17 @@ public interface PyClass extends PsiNameIdentifierOwner, PyStatement, NameDefine
|
||||
*/
|
||||
boolean isNewStyleClass();
|
||||
|
||||
/**
|
||||
* A lazy way to list ancestor classes width first, *not* in method-resolution order.
|
||||
* @return an iterable of ancestor classes.
|
||||
*/
|
||||
Iterable<PyClassRef> iterateAncestors();
|
||||
@NotNull
|
||||
List<PyClass> getAncestorClasses();
|
||||
|
||||
Iterable<PyClass> iterateAncestorClasses();
|
||||
@NotNull
|
||||
List<PyClass> getAncestorClasses(@NotNull TypeEvalContext context);
|
||||
|
||||
/**
|
||||
* Return the method resolution order list for this class.
|
||||
* <br/>
|
||||
* see http://www.python.org/download/releases/2.3/mro/
|
||||
* <br/>
|
||||
* <i>Note: the list begins with this class.</i> It ends with the builtin 'object'.
|
||||
* If class hierarchy is incorrect, e.g. badly looped, assertions may fail in implementation.
|
||||
* @return list of classes in method resolution order for this class, at least one element long.
|
||||
* Get a list of all ancestor types.
|
||||
*/
|
||||
@NotNull List<PyClass> getMRO();
|
||||
@NotNull
|
||||
List<PyClassLikeType> getAncestorTypes(@NotNull TypeEvalContext context);
|
||||
|
||||
/**
|
||||
* Scan properties in order of definition, until processor returns true for one of them.
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.jetbrains.python.psi;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.python.psi.impl.PyQualifiedName;
|
||||
import com.jetbrains.python.psi.types.PyClassType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PyClassRef {
|
||||
@Nullable private final PsiElement myElement;
|
||||
@Nullable private final String myQName;
|
||||
@Nullable private final PyClassType myType;
|
||||
|
||||
public PyClassRef(@Nullable PsiElement element) {
|
||||
myElement = element;
|
||||
myQName = null;
|
||||
myType = null;
|
||||
}
|
||||
|
||||
public PyClassRef(@Nullable String qName) {
|
||||
myElement = null;
|
||||
myQName = qName;
|
||||
myType = null;
|
||||
}
|
||||
|
||||
public PyClassRef(@Nullable PyClassType type) {
|
||||
myElement = null;
|
||||
myQName = null;
|
||||
myType = type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PyClass getPyClass() {
|
||||
if (myElement instanceof PyClass) {
|
||||
return (PyClass) myElement;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getElement() {
|
||||
return myElement;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PyClassType getType() {
|
||||
return myType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getClassName() {
|
||||
if (myElement instanceof PyClass) {
|
||||
return ((PyClass)myElement).getName();
|
||||
}
|
||||
else if (myQName != null) {
|
||||
final PyQualifiedName qname = PyQualifiedName.fromDottedString(myQName);
|
||||
if (qname != null) {
|
||||
return qname.getLastComponent();
|
||||
}
|
||||
}
|
||||
else if (myType != null) {
|
||||
return myType.getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getQualifiedName() {
|
||||
if (myElement instanceof PyClass) {
|
||||
return ((PyClass)myElement).getQualifiedName();
|
||||
}
|
||||
else if (myQName != null) {
|
||||
return myQName;
|
||||
}
|
||||
else if (myType != null) {
|
||||
return myType.getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
PyClassRef that = (PyClassRef)o;
|
||||
|
||||
if (myElement != null ? !myElement.equals(that.myElement) : that.myElement != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return myElement != null ? myElement.hashCode() : 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.jetbrains.python.psi.types;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author vlan
|
||||
*/
|
||||
public interface PyClassLikeType extends PyCallableType {
|
||||
boolean isDefinition();
|
||||
|
||||
PyClassLikeType toInstance();
|
||||
|
||||
@Nullable
|
||||
String getClassQName();
|
||||
|
||||
@NotNull
|
||||
List<PyClassLikeType> getSuperClassTypes(@NotNull TypeEvalContext context);
|
||||
|
||||
boolean isValid();
|
||||
}
|
||||
@@ -3,21 +3,11 @@ package com.jetbrains.python.psi.types;
|
||||
import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public interface PyClassType extends PyCallableType, UserDataHolder {
|
||||
public interface PyClassType extends PyClassLikeType, UserDataHolder {
|
||||
@NotNull
|
||||
PyClass getPyClass();
|
||||
|
||||
boolean isDefinition();
|
||||
|
||||
PyClassType toInstance();
|
||||
|
||||
@Nullable
|
||||
String getClassQName();
|
||||
|
||||
boolean isValid();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user