@Override public void visitClass(PsiClass aClass) { ArrangementSettingsToken type = CLASS; if (aClass.isEnum()) { type = ENUM; } else if (aClass.isInterface()) { type = INTERFACE; } JavaElementArrangementEntry entry = createNewEntry(aClass, aClass.getTextRange(), type, aClass.getName(), true); processEntry(entry, aClass, aClass); }
private static int findOffsetToInsertMethodTo(Editor editor, PsiFile file) { int result = editor.getCaretModel().getOffset(); PsiClass classAtCursor = PsiTreeUtil.getParentOfType(file.findElementAt(result), PsiClass.class, false); while (classAtCursor != null && !(classAtCursor.getParent() instanceof PsiFile)) { result = classAtCursor.getTextRange().getEndOffset(); classAtCursor = PsiTreeUtil.getParentOfType(classAtCursor, PsiClass.class); } return result; }