use of com.jetbrains.python.psi.PyClass in project intellij-community by JetBrains.
the class PyContainingFileRenamerFactory method isApplicable.
@Override
public boolean isApplicable(PsiElement element) {
if (!(element instanceof PyClass)) {
return false;
}
ScopeOwner scopeOwner = PsiTreeUtil.getParentOfType(element, ScopeOwner.class);
if (scopeOwner instanceof PyFile) {
String className = ((PyClass) element).getName();
String fileName = FileUtil.getNameWithoutExtension(scopeOwner.getName());
return fileName.equalsIgnoreCase(className);
}
return false;
}
use of com.jetbrains.python.psi.PyClass in project intellij-community by JetBrains.
the class MembersBasedPresenterImpl method getConflicts.
/**
* Checks if one of destination classes already has members that should be moved, so conflict would take place.
*
* @return map of conflicts (if any)
* @see #getDestClassesToCheckConflicts()
*/
@NotNull
protected final MultiMap<PyClass, PyMemberInfo<?>> getConflicts() {
final MultiMap<PyClass, PyMemberInfo<?>> result = new MultiMap<>();
final Collection<PyMemberInfo<PyElement>> memberInfos = myView.getSelectedMemberInfos();
for (final PyClass destinationClass : getDestClassesToCheckConflicts()) {
for (final PyMemberInfo<PyElement> pyMemberInfo : memberInfos) {
if (pyMemberInfo.hasConflict(destinationClass)) {
result.putValue(destinationClass, pyMemberInfo);
}
}
}
return result;
}
use of com.jetbrains.python.psi.PyClass in project intellij-community by JetBrains.
the class PyClassCellRenderer method customizeRenderer.
public JLabel customizeRenderer(final Object value, final boolean showReadOnly) {
PyClass aClass = (PyClass) value;
setText(getClassText(aClass));
int flags = Iconable.ICON_FLAG_VISIBILITY;
if (showReadOnly) {
flags |= Iconable.ICON_FLAG_READ_STATUS;
}
Icon icon = aClass.getIcon(flags);
if (icon != null) {
setIcon(icon);
}
return this;
}
use of com.jetbrains.python.psi.PyClass in project intellij-community by JetBrains.
the class PyExtractMethodHandler method rangeBelongsToSameClassBody.
private static boolean rangeBelongsToSameClassBody(@NotNull PsiElement element1, @NotNull PsiElement element2) {
final PyClass firstScopeOwner = PsiTreeUtil.getParentOfType(element1, PyClass.class, false, ScopeOwner.class);
final PyClass secondScopeOwner = PsiTreeUtil.getParentOfType(element2, PyClass.class, false, ScopeOwner.class);
return firstScopeOwner != null && firstScopeOwner == secondScopeOwner;
}
use of com.jetbrains.python.psi.PyClass in project intellij-community by JetBrains.
the class PyInheritorsSearchTest method testInheritorsWhenSuperClassImportedWithAs.
// PY-19461
public void testInheritorsWhenSuperClassImportedWithAs() throws Exception {
setupProject();
final PyClass pyClass = findClass("C");
final Collection<PyClass> inheritors = PyClassInheritorsSearch.search(pyClass, false).findAll();
assertSameElements(inheritors, findClass("D"));
}
Aggregations