MethodElement (PsiMethod method) { MethodElement me = new MethodElement(); PsiType type = method.getReturnType(); PsiModifierList modifiers = method.getModifierList(); // if something is wrong: // http://www.intellij.net/forums/thread.jsp?nav=false&forum=18&thread=88676&start=0&msRange=15 if (type == null) { LOG.warn("This method does not have a valid return type: " + method.getName() + ", returnType=null"); return me; } PsiElementFactory factory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory(); setElementInfo(me, factory, type, modifiers); // names String fieldName = PsiAdapter.getGetterFieldName(method); me.setName(fieldName == null ? method.getName() : fieldName); me.setFieldName(fieldName); me.setMethodName(method.getName()); // getter me.setGetter(PsiAdapter.isGetterMethod(method)); // misc me.setDeprecated(method.isDeprecated()); me.setReturnTypeVoid(PsiAdapter.isTypeOfVoid(method.getReturnType())); // modifiers if (modifiers.hasModifierProperty(PsiModifier.ABSTRACT)) me.setModifierAbstract(true); if (modifiers.hasModifierProperty(PsiModifier.SYNCHRONIZED)) me.setModifierSynchronized(true); return me; }