<commit_before>// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.internal.statistic.eventLog

import com.intellij.openapi.components.ServiceManager

fun getUiEventLogger(): FeatureUsageUiEvents {
  return try {
    ServiceManager.getService(FeatureUsageUiEvents::class.java) ?: EmptyFeatureUsageUiEvents
  }
  catch (e : Exception) {
    EmptyFeatureUsageUiEvents
  }
}

interface FeatureUsageUiEvents {
  fun logSelectConfigurable(name: String, context: Class<*>)

  fun logApplyConfigurable(name: String, context: Class<*>)

  fun logResetConfigurable(name: String, context: Class<*>)

  fun logShowDialog(name: String, context: Class<*>)

  fun logCloseDialog(name: String, exitCode: Int, context: Class<*>)
}

object EmptyFeatureUsageUiEvents : FeatureUsageUiEvents {
  override fun logSelectConfigurable(name: String, context: Class<*>) {
  }

  override fun logApplyConfigurable(name: String, context: Class<*>) {
  }

  override fun logResetConfigurable(name: String, context: Class<*>) {
  }

  override fun logShowDialog(name: String, context: Class<*>) {
  }

  override fun logCloseDialog(name: String, exitCode: Int, context: Class<*>) {
  }
}<commit_msg>FB-125 Filter settings and dialogs: explicitly check if application exists<commit_after>// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.internal.statistic.eventLog

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.ServiceManager

fun getUiEventLogger(): FeatureUsageUiEvents {
  if (ApplicationManager.getApplication() != null) {
    return ServiceManager.getService(FeatureUsageUiEvents::class.java) ?: EmptyFeatureUsageUiEvents
  }
  // cannot load service if application is not initialized
  return EmptyFeatureUsageUiEvents
}

interface FeatureUsageUiEvents {
  fun logSelectConfigurable(name: String, context: Class<*>)

  fun logApplyConfigurable(name: String, context: Class<*>)

  fun logResetConfigurable(name: String, context: Class<*>)

  fun logShowDialog(name: String, context: Class<*>)

  fun logCloseDialog(name: String, exitCode: Int, context: Class<*>)
}

object EmptyFeatureUsageUiEvents : FeatureUsageUiEvents {
  override fun logSelectConfigurable(name: String, context: Class<*>) {
  }

  override fun logApplyConfigurable(name: String, context: Class<*>) {
  }

  override fun logResetConfigurable(name: String, context: Class<*>) {
  }

  override fun logShowDialog(name: String, context: Class<*>) {
  }

  override fun logCloseDialog(name: String, exitCode: Int, context: Class<*>) {
  }
}
{'fraction_non_alphanumeric': 0.10373594486760972, 'fraction_numerical': 0.008342401160681901, 'mean_word_length': 5.459016393442623, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5741997', 'n_tokens_mistral': 837, 'n_tokens_neox': 795, 'n_words': 228}