@NotNull public static DeclarationDescriptor getEnclosingDescriptor( @NotNull BindingContext context, @NotNull JetElement element) { JetNamedDeclaration declaration = PsiTreeUtil.getParentOfType(element, JetNamedDeclaration.class); if (declaration instanceof JetFunctionLiteral) { return getEnclosingDescriptor(context, declaration); } DeclarationDescriptor descriptor = context.get(DECLARATION_TO_DESCRIPTOR, declaration); assert descriptor != null : "No descriptor for named declaration: " + declaration.getText() + "\n(of type " + declaration.getClass() + ")"; return descriptor; }