private ProblemDescriptor @NotNull [] checkElement(@NotNull PsiFile psiFile,
                                                     @NotNull RedundantSuppressionDetector extension,
                                                     @NotNull InspectionManager manager,
                                                     @NotNull InspectionProfile profile) {
    Map<PsiElement, Collection<String>> suppressedScopes = new HashMap<>();
    psiFile.accept(new PsiRecursiveElementWalkingVisitor() {
      @Override
      public void visitElement(@NotNull PsiElement element) {
        super.visitElement(element);
        collectSuppressions(element, suppressedScopes, IGNORE_ALL, extension);
      }
    });

    if (suppressedScopes.values().isEmpty()) return ProblemDescriptor.EMPTY_ARRAY;
    // have to visit all file from scratch since inspections can be written in any pervasive way including checkFile() overriding
    Map<InspectionToolWrapper<?, ?>, String> suppressedTools = new HashMap<>();
    List<InspectionToolWrapper<?, ?>> toolWrappers = getInspectionTools(psiFile, profile);
    Language language = psiFile.getLanguage();
    for (Collection<String> ids : suppressedScopes.values()) {
      for (Iterator<String> iterator = ids.iterator(); iterator.hasNext(); ) {
        String suppressId = iterator.next().trim();
        List<InspectionToolWrapper<?, ?>> reportingWrappers = findReportingTools(toolWrappers, suppressId, language);
        if (reportingWrappers.isEmpty()) {
          iterator.remove();
        }
        else {
          for (InspectionToolWrapper<?, ?> toolWrapper : reportingWrappers) {
            suppressedTools.put(toolWrapper, suppressId);
          }
        }
      }
    }

    AnalysisScope scope = new AnalysisScope(psiFile);

    GlobalInspectionContextBase globalContext = createContext(psiFile);
    globalContext.setCurrentScope(scope);
    List<ProblemDescriptor> result = new ArrayList<>();
    ((RefManagerImpl)globalContext.getRefManager()).runInsideInspectionReadAction(() -> {
      try {
        for (Map.Entry<InspectionToolWrapper<?, ?>, String> entry : suppressedTools.entrySet()) {
          InspectionToolWrapper<?, ?> toolWrapper = entry.getKey();
          String toolId = entry.getValue();
          toolWrapper.initialize(globalContext);
          Collection<CommonProblemDescriptor> descriptors;
          if (toolWrapper instanceof LocalInspectionToolWrapper local) {
            if (local.isUnfair()) {
              continue; // can't work with passes other than LocalInspectionPass
            }
            LocalInspectionTool tool = local.getTool();
            List<ProblemDescriptor> found = Collections.synchronizedList(new ArrayList<>());
            // shouldn't use standard ProblemsHolder because it filters out suppressed elements by default
            InspectionEngine.inspectEx(Collections.singletonList(new LocalInspectionToolWrapper(tool)), psiFile, psiFile.getTextRange(),
                                       psiFile.getTextRange(), false,
                                       true, false, ProgressIndicatorProvider.getGlobalProgressIndicator(),
                                       (wrapper, descriptor) -> found.add(descriptor));
            descriptors = new ArrayList<>(found);
          }
          else if (toolWrapper instanceof GlobalInspectionToolWrapper global) {
            GlobalInspectionTool globalTool = global.getTool();
            //when graph is needed, results probably depend on outer files so absence of results on one file (in current context) doesn't guarantee anything
            if (globalTool.isGraphNeeded()) continue;
            if (globalTool instanceof RedundantSuppressInspectionBase) continue;
            descriptors = new ArrayList<>(InspectionEngine.runInspectionOnFile(psiFile, global, globalContext));
          }
          else {
            continue;
          }
          for (Map.Entry<PsiElement, Collection<String>> e : suppressedScopes.entrySet()) {
            Collection<String> suppressedIds = e.getValue();
            PsiElement suppressedScope = e.getKey();
            if (!suppressedIds.contains(toolId)) continue;
            for (CommonProblemDescriptor descriptor : descriptors) {
              if (!(descriptor instanceof ProblemDescriptor problemDescriptor)) continue;
              PsiElement element = problemDescriptor.getPsiElement();
              if (element == null) continue;
              PsiLanguageInjectionHost host = InjectedLanguageManager.getInstance(element.getProject()).getInjectionHost(element);
              if (extension.isSuppressionFor(suppressedScope, ObjectUtils.notNull(host, element), toolId)) {
                suppressedIds.remove(toolId);
                break;
              }
            }
          }
        }
        for (Map.Entry<PsiElement, Collection<String>> entry : suppressedScopes.entrySet()) {
          PsiElement suppressedScope = entry.getKey();
          Collection<String> suppressedIds = entry.getValue();
          for (String toolId : suppressedIds) {
            PsiElement documentedElement = globalContext.getRefManager().getContainerElement(suppressedScope);
            if (documentedElement != null && documentedElement.isValid()) {
              QuickFix<?> fix;
              synchronized (this) {
                if (myQuickFixes == null) myQuickFixes = new BidirectionalMap<>();
                String key = toolId + ";" + suppressedScope.getLanguage().getID();
                fix = myQuickFixes.get(key);
                if (fix == null) {
                  fix = createQuickFix(key);
                  myQuickFixes.put(key, fix);
                }
              }
              PsiElement identifier;
              if (suppressedScope instanceof PsiNameIdentifierOwner nameIdentifierOwner && suppressedScope == documentedElement) {
                identifier = ObjectUtils.notNull(nameIdentifierOwner.getNameIdentifier(), suppressedScope);
              }
              else {
                identifier = suppressedScope;
              }
              result.add(
                manager.createProblemDescriptor(identifier, InspectionsBundle.message("inspection.redundant.suppression.description"),
                                                (LocalQuickFix)fix, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
                                                false));
            }
          }
        }
      }
      finally {
        globalContext.close(true);
      }
    });
    return result.toArray(ProblemDescriptor.EMPTY_ARRAY);
  }
private ProblemDescriptor @NotNull [] checkElement(@NotNull PsiFile psiFile,
                                                     @NotNull RedundantSuppressionDetector extension,
                                                     @NotNull InspectionManager manager,
                                                     @NotNull InspectionProfile profile)