CompiledPattern () { return new CompiledPattern() { @NotNull @Override protected SubstitutionHandler doCreateSubstitutionHandler(@NotNull String name, boolean target, int minOccurs, int maxOccurs, boolean greedy) { return new MySubstitutionHandler(name, target, minOccurs, maxOccurs, greedy); } @Override public String @NotNull [] getTypedVarPrefixes() { return getVarPrefixes(); } @Override public boolean isTypedVar(@NotNull String str) { for (String prefix : getVarPrefixes()) { if (str.startsWith(prefix)) { return true; } } return false; } @NotNull @Override public String getTypedVarString(@NotNull PsiElement element) { final PsiElement initialElement = element; PsiElement child = SkippingHandler.getOnlyNonWhitespaceChild(element); while (child != element && child != null && !(child instanceof LeafElement)) { element = child; child = SkippingHandler.getOnlyNonWhitespaceChild(element); } return child instanceof LeafElement ? element.getText() : initialElement.getText(); } }; }