public static @Nullable ChainCompletionContext createContext(@Nullable PsiType targetType,
                                                               @Nullable PsiElement containingElement,
                                                               boolean suggestIterators) {
    ChainSearchTarget target = containingElement == null ? null : ChainSearchTarget.create(targetType);
    if (target == null) {
      return null;
    }

    CompilerReferenceServiceEx compilerReferenceService = (CompilerReferenceServiceEx)CompilerReferenceService.getInstanceIfEnabled(containingElement.getProject());
    if (compilerReferenceService == null) {
      return null;
    }

    if (suggestIterators) {
      target = target.toIterators();
    }

    Set<? extends PsiVariable> excludedVariables = getEnclosingLocalVariables(containingElement);
    Project project = containingElement.getProject();
    ContextProcessor processor = new ContextProcessor(null, project, containingElement, excludedVariables);
    PsiScopesUtil.treeWalkUp(processor, containingElement, containingElement.getContainingFile());
    List<PsiNamedElement> contextElements = processor.getContextElements();
    return new ChainCompletionContext(target, contextElements, containingElement, compilerReferenceService);
  }
public static @Nullable ChainCompletionContext createContext(@Nullable PsiType targetType,
                                                               @Nullable PsiElement containingElement,
                                                               boolean suggestIterators)