String (PsiModifierListOwner owner, boolean showParamName, int maxParamsToShow) { if (owner instanceof PsiPackage) { return ((PsiPackage)owner).getQualifiedName(); } StringBuilder builder = new StringBuilder(); if (owner instanceof PsiClass) { ClassUtil.formatClassName((PsiClass)owner, builder); return builder.toString(); } PsiClass psiClass = PsiTreeUtil.getContextOfType(owner, PsiClass.class, false); if (psiClass == null) return null; ClassUtil.formatClassName(psiClass, builder); if (owner instanceof PsiMethod) { builder.append(' '); int options = SHOW_NAME | SHOW_FQ_NAME | SHOW_TYPE | SHOW_PARAMETERS | SHOW_FQ_CLASS_NAMES; int parameterOptions = showParamName ? SHOW_NAME | SHOW_TYPE | SHOW_FQ_CLASS_NAMES : SHOW_TYPE | SHOW_FQ_CLASS_NAMES; formatMethod((PsiMethod)owner, PsiSubstitutor.EMPTY, options, parameterOptions, maxParamsToShow, builder); } else if (owner instanceof PsiField) { builder.append(' ').append(((PsiField)owner).getName()); } else if (owner instanceof PsiParameter) { PsiElement declarationScope = ((PsiParameter)owner).getDeclarationScope(); if (!(declarationScope instanceof PsiMethod)) { return null; } PsiMethod psiMethod = (PsiMethod)declarationScope; builder.append(' '); int options = SHOW_NAME | SHOW_FQ_NAME | SHOW_TYPE | SHOW_PARAMETERS | SHOW_FQ_CLASS_NAMES; int parameterOptions = showParamName ? SHOW_NAME | SHOW_TYPE | SHOW_FQ_CLASS_NAMES : SHOW_TYPE | SHOW_FQ_CLASS_NAMES; formatMethod(psiMethod, PsiSubstitutor.EMPTY, options, parameterOptions, maxParamsToShow, builder); builder.append(' '); if (showParamName) { formatVariable((PsiVariable)owner, SHOW_NAME, PsiSubstitutor.EMPTY, builder); } else { builder.append(psiMethod.getParameterList().getParameterIndex((PsiParameter)owner)); } } else { return null; } return builder.toString(); }