private void doVisitElement(@NotNull PsiElement element) {
      final CompiledPattern pattern = myGlobalVisitor.getContext().getPattern();

      if (myGlobalVisitor.getCodeBlockLevel() == 0) {
        initTopLevelElement(element);
        return;
      }

      if (canBePatternVariable(element) && pattern.isRealTypedVar(element)) {
        myGlobalVisitor.handle(element);
        final MatchingHandler handler = pattern.getHandler(element);
        handler.setFilter(other -> canBePatternVariableValue(other));

        super.visitElement(element);

        return;
      }

      super.visitElement(element);

      if (myGlobalVisitor.getContext().getSearchHelper().doOptimizing() && element instanceof LeafElement) {
        final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(element.getLanguage());
        if (parserDefinition != null) {
          final String text = element.getText();

          // todo: support variables inside comments
          if (StringUtil.isJavaIdentifier(text)) {
            myGlobalVisitor.processTokenizedName(text, GlobalCompilingVisitor.OccurenceKind.CODE);
          }
        }
      }
    }
private void doVisitElement(@NotNull PsiElement element)