PsiElement (@NotNull PsiClass aClass, @NotNull String memberRefText, PsiElement context) { int parenthIndex = memberRefText.indexOf('('); if (parenthIndex < 0) { String name = memberRefText; PsiField field = aClass.findFieldByName(name, true); if (field != null) return field; PsiClass inner = aClass.findInnerClassByName(name, true); if (inner != null) return inner; PsiMethod[] methods = aClass.getAllMethods(); for (PsiMethod method : methods) { if (method.getName().equals(name)) return method; } return null; } else { String name = memberRefText.substring(0, parenthIndex).trim(); int rparenIndex = memberRefText.lastIndexOf(')'); if (rparenIndex == -1) return null; String parmsText = memberRefText.substring(parenthIndex + 1, rparenIndex).trim(); StringTokenizer tokenizer = new StringTokenizer(parmsText.replaceAll("[*]", ""), ","); PsiType[] types = PsiType.createArray(tokenizer.countTokens()); int i = 0; PsiElementFactory factory = JavaPsiFacade.getElementFactory(aClass.getProject()); while (tokenizer.hasMoreTokens()) { String parmText = tokenizer.nextToken().trim(); try { Matcher typeMatcher = ourTypePattern.matcher(parmText); String typeText = parmText; if (typeMatcher.find()) { typeText = parmText.substring(0, typeMatcher.start()); } PsiType type = factory.createTypeFromText(typeText, context); types[i++] = type; } catch (IncorrectOperationException e) { LOG.info(e); } } MethodSignature methodSignature = MethodSignatureUtil.createMethodSignature(name, types, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY, name.equals(aClass.getName())); final PsiMethod[] allMethods; if (context != null) { allMethods = PsiDocMethodOrFieldRef.getAllMethods(aClass, context); } else { allMethods = aClass.findMethodsByName(name, true); } PsiMethod[] methods = PsiDocMethodOrFieldRef.findMethods(methodSignature, aClass, name, allMethods); if (methods.length == 0) return null; PsiMethod found = methods[0]; int hashIndex = memberRefText.indexOf('#', rparenIndex); if (hashIndex != -1) { PsiParameter[] params = found.getParameterList().getParameters(); int parameterNumber = Integer.parseInt(memberRefText.substring(hashIndex + 1)); if (parameterNumber < params.length) return params[parameterNumber]; } return found; } }