private static void checkForUnknownVariables(CompiledPattern pattern, PsiElement element) {
    element.accept(new PsiRecursiveElementWalkingVisitor() {
      @Override
      public void visitElement(@NotNull PsiElement element) {
        if (element.getUserData(CompiledPattern.HANDLER_KEY) != null) {
          return;
        }
        super.visitElement(element);

        if (!(element instanceof LeafElement)) {
          return;
        }
        final String text = element.getText();
        if (!pattern.isTypedVar(text)) {
          for (String prefix : pattern.getTypedVarPrefixes()) {
            if (text.contains(prefix)) {
              throw new MalformedPatternException();
            }
          }
          return;
        }
        final MatchingHandler handler = pattern.getHandler(pattern.getTypedVarString(element));
        if (handler == null) {
          throw new MalformedPatternException();
        }
      }
    });
  }
private static void checkForUnknownVariables(CompiledPattern pattern, PsiElement element)