private static RegExpMatchResult isMatchingText(@NotNull final PsiFile regExpFile, String regExpText, @NotNull String sampleText) {
    final Language regExpFileLanguage = regExpFile.getLanguage();
    final RegExpMatcherProvider matcherProvider = RegExpMatcherProvider.EP.forLanguage(regExpFileLanguage);
    if (matcherProvider != null) {
      final RegExpMatchResult result = ReadAction.compute(() -> {
        final PsiLanguageInjectionHost host = InjectedLanguageManager.getInstance(regExpFile.getProject()).getInjectionHost(regExpFile);
        return host != null ? matcherProvider.matches(regExpText, regExpFile, host, sampleText, 1000L) : null;
      });
      if (result != null) {
        return result;
      }
    }

    final Integer patternFlags = ReadAction.compute(() -> {
      final PsiLanguageInjectionHost host = InjectedLanguageManager.getInstance(regExpFile.getProject()).getInjectionHost(regExpFile);
      int flags = 0;
      if (host != null) {
        for (RegExpModifierProvider provider : RegExpModifierProvider.EP.allForLanguage(host.getLanguage())) {
          flags = provider.getFlags(host, regExpFile);
          if (flags > 0) break;
        }
      }
      return flags;
    });

    try {
      //noinspection MagicConstant
      final Matcher matcher = Pattern.compile(regExpText, patternFlags).matcher(StringUtil.newBombedCharSequence(sampleText, 1000));
      if (matcher.matches()) {
        setMatches(regExpFile, collectMatches(matcher));
        return RegExpMatchResult.MATCHES;
      }
      final boolean hitEnd = matcher.hitEnd();
      if (matcher.find()) {
        setMatches(regExpFile, collectMatches(matcher));
        return RegExpMatchResult.FOUND;
      }
      else if (hitEnd) {
        return RegExpMatchResult.INCOMPLETE;
      }
      else {
        return RegExpMatchResult.NO_MATCH;
      }
    }
    catch (ProcessCanceledException ignore) {
      return RegExpMatchResult.TIMEOUT;
    }
    catch (Exception e) {
      LOG.warn(e);
    }

    return RegExpMatchResult.BAD_REGEXP;
  }
private static RegExpMatchResult isMatchingText(@NotNull final PsiFile regExpFile, String regExpText, @NotNull String sampleText)