RegExpGroup (@NotNull PsiFile regExpFile, int offset) { PsiElement element = regExpFile.findElementAt(offset); RegExpGroup group = null; while (element != null) { if (element instanceof RegExpGroup g) { if (g.isCapturing()) { group = g; break; } } element = element.getParent(); } return group; }