@NotNull
  private PsiElement @NotNull [] doCreatePatternTree(@NotNull String text,
                                                     @NotNull PatternTreeContext context,
                                                     @NotNull LanguageFileType fileType,
                                                     @NotNull Language language,
                                                     @NotNull Project project,
                                                     boolean physical,
                                                     @NotNull String strContext) {
    String placeholderName = getPlaceholderVarName();
    final String patternInContext = (context == PatternTreeContext.File) ? text : strContext.replace(placeholderName, text);

    @NonNls final String name = "__dummy." + fileType.getDefaultExtension();
    final PsiFile file = PsiFileFactory.getInstance(project).createFileFromText(name, language, patternInContext, physical, true);
    if (file == null) {
      return PsiElement.EMPTY_ARRAY;
    }
    if (context == PatternTreeContext.File) {
      return new PsiElement[] {file};
    }

    final int offset = strContext.indexOf(placeholderName);
    PsiElement element = file.findElementAt(offset);
    if (element == null) {
      return PsiElement.EMPTY_ARRAY;
    }

    PsiElement topElement = element;
    element = element.getParent();

    final int patternLength = text.length();
    while (element != null) {
      if (element.getTextRange().getStartOffset() == offset && element.getTextLength() <= patternLength) {
        topElement = element;
      }
      element = element.getParent();
    }

    if (topElement instanceof PsiFile) {
      return topElement.getChildren();
    }

    final List<PsiElement> result = new SmartList<>();
    result.add(topElement);
    topElement = topElement.getNextSibling();

    final int endOffset = offset + patternLength;
    while (topElement != null && topElement.getTextRange().getEndOffset() <= endOffset) {
      result.add(topElement);
      topElement = topElement.getNextSibling();
    }

    return result.toArray(PsiElement.EMPTY_ARRAY);
  }
@NotNull
  private PsiElement @NotNull [] doCreatePatternTree(@NotNull String text,
                                                     @NotNull PatternTreeContext context,
                                                     @NotNull LanguageFileType fileType,
                                                     @NotNull Language language,
                                                     @NotNull Project project,
                                                     boolean physical,
                                                     @NotNull String strContext)