<commit_before>// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.structuralsearch;

import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.HighlightInfoFilter;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.Document;
import com.intellij.psi.*;
import com.intellij.structuralsearch.plugin.ui.StructuralSearchDialog;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * @author <NAME>
 */
public class StructuralSearchHighlightInfoFilter implements HighlightInfoFilter {

  @Override
  public boolean accept(@NotNull HighlightInfo highlightInfo, @Nullable PsiFile file) {
    if (file == null) {
      return true;
    }
    if (highlightInfo.getSeverity() != HighlightSeverity.ERROR) {
      return false;
    }
    final Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
    if (document == null) {
      return true;
    }
    final String contextId = document.getUserData(StructuralSearchDialog.STRUCTURAL_SEARCH_PATTERN_CONTEXT_ID);
    if (contextId == null) {
      return true;
    }
    final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(file);
    if (profile == null) {
      return true;
    }
    final PatternContext context = StructuralSearchUtil.findPatternContextByID(contextId, profile);
    return profile.shouldShowProblem(highlightInfo, file, context);
  }
}<commit_msg>SSR: only suppress own errors to avoid breaking everything<commit_after>// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.structuralsearch;

import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.HighlightInfoFilter;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.editor.Document;
import com.intellij.psi.*;
import com.intellij.structuralsearch.plugin.ui.StructuralSearchDialog;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * @author <NAME>
 */
public class StructuralSearchHighlightInfoFilter implements HighlightInfoFilter {

  @Override
  public boolean accept(@NotNull HighlightInfo highlightInfo, @Nullable PsiFile file) {
    if (file == null) {
      return true;
    }
    final Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
    if (document == null) {
      return true;
    }
    final String contextId = document.getUserData(StructuralSearchDialog.STRUCTURAL_SEARCH_PATTERN_CONTEXT_ID);
    if (contextId == null) {
      return true;
    }
    if (highlightInfo.getSeverity() != HighlightSeverity.ERROR) {
      return false;
    }
    final StructuralSearchProfile profile = StructuralSearchUtil.getProfileByPsiElement(file);
    if (profile == null) {
      return true;
    }
    final PatternContext context = StructuralSearchUtil.findPatternContextByID(contextId, profile);
    return profile.shouldShowProblem(highlightInfo, file, context);
  }
}
{'fraction_non_alphanumeric': 0.0906855210574854, 'fraction_numerical': 0.006148170919151552, 'mean_word_length': 4.620034542314335, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7493290', 'n_tokens_mistral': 965, 'n_tokens_neox': 911, 'n_words': 218}