List<LookupElement> (@NotNull PsiElement location, @NotNull ProcessingContext context, boolean wantAllSubmodules, boolean suppressParentheses, @NotNull TypeEvalContext typeEvalContext) { final List<LookupElement> result = new ArrayList<>(); final Set<String> namesAlready = context.get(CTX_NAMES); final PointInImport point = ResolveImportUtil.getPointInImport(location); final PyResolveContext resolveContext = PyResolveContext.defaultContext(typeEvalContext); for (PyModuleMembersProvider provider : PyModuleMembersProvider.EP_NAME.getExtensionList()) { for (PyCustomMember member : provider.getMembers(myModule, point, typeEvalContext)) { final String name = member.getName(); if (namesAlready != null && !namesAlready.add(name)) { continue; } if (PyUtil.isClassPrivateName(name)) { continue; } final CompletionVariantsProcessor processor = createCompletionVariantsProcessor(location, suppressParentheses, point); final PsiElement resolved = member.resolve(location, resolveContext); if (resolved != null) { processor.execute(resolved, ResolveState.initial()); final List<LookupElement> lookupList = processor.getResultList(); if (!lookupList.isEmpty()) { final LookupElement element = lookupList.get(0); if (name.equals(element.getLookupString())) { result.add(element); continue; } } } result.add(LookupElementBuilder.create(name).withIcon(member.getIcon()).withTypeText(member.getShortType())); } } if (point == PointInImport.NONE || point == PointInImport.AS_NAME) { // when not imported from, add regular attributes final CompletionVariantsProcessor processor = createCompletionVariantsProcessor(location, suppressParentheses, point); myModule.processDeclarations(processor, ResolveState.initial(), null, location); if (namesAlready != null) { for (LookupElement le : processor.getResultList()) { final String name = le.getLookupString(); if (!namesAlready.contains(name)) { result.add(le); namesAlready.add(name); } } } else { result.addAll(processor.getResultList()); } } if (PyUtil.isPackage(myModule)) { // our module is a dir, not a single file if (point == PointInImport.AS_MODULE || point == PointInImport.AS_NAME || wantAllSubmodules) { // when imported from somehow, add submodules result.addAll(getSubModuleVariants(myModule.getContainingDirectory(), location, namesAlready)); } else { result.addAll(collectImportedSubmodulesAsLookupElements(myModule, location, namesAlready)); } } return result; }