PyNamedParameter (@NotNull Editor editor, @NotNull PsiFile file) { final PsiElement elementAt = getElementUnderCaret(editor, file); final StreamEx<PyNamedParameter> parameters; final PyNamedParameter immediateParam = PsiTreeUtil.getParentOfType(elementAt, PyNamedParameter.class); if (immediateParam != null) { parameters = StreamEx.of(immediateParam); } else { final PyReferenceExpression referenceExpr = PsiTreeUtil.getParentOfType(elementAt, PyReferenceExpression.class); if (referenceExpr != null) { parameters = StreamEx.of(PyUtil.multiResolveTopPriority(referenceExpr, getResolveContext(elementAt))) .select(PyNamedParameter.class); } else { parameters = StreamEx.empty(); } } final ProjectFileIndex index = ProjectFileIndex.getInstance(file.getProject()); return parameters .filter(param -> !param.isSelf()) .filter(param -> PsiTreeUtil.getParentOfType(param, PyLambdaExpression.class) == null) .filter(param -> { VirtualFile dir = param.getContainingFile().getOriginalFile().getVirtualFile(); return dir != null && !index.isInLibraryClasses(dir); }) .filter(param -> !isParamTypeDefined(param)) .findFirst().orElse(null); }