use of com.jetbrains.python.psi.PyClass in project intellij-community by JetBrains.
the class PyClassInsertHandler method handleInsert.
public void handleInsert(InsertionContext context, LookupElement item) {
final Editor editor = context.getEditor();
final Document document = editor.getDocument();
if (context.getCompletionChar() == '(') {
context.setAddCompletionChar(false);
final int offset = context.getTailOffset();
document.insertString(offset, "()");
PyClass pyClass = PyUtil.as(item.getPsiElement(), PyClass.class);
PyFunction init = pyClass != null ? pyClass.findInitOrNew(true, null) : null;
if (init != null && PyFunctionInsertHandler.hasParams(context, init)) {
editor.getCaretModel().moveToOffset(offset + 1);
AutoPopupController.getInstance(context.getProject()).autoPopupParameterInfo(context.getEditor(), init);
} else {
editor.getCaretModel().moveToOffset(offset + 2);
}
}
}
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;
}
Aggregations