<commit_before>package org.scalaide.ui.internal.wizards

import org.eclipse.core.runtime.CoreException
import org.scalaide.logging.HasLogger
import org.scalaide.ui.wizards.FileCreator
import org.scalaide.util.internal.eclipse.EclipseUtils

object FileCreatorMapping extends HasLogger {

  final val FileCreatorId = "org.scala-ide.sdt.core.fileCreator"

  /**
   * Returns all existing file creator extensions mapped to the
   * `FileCreatorMapping` class.
   */
  def mappings: Seq[FileCreatorMapping] = {
    val elems = EclipseUtils.configElementsForExtension(FileCreatorId)

    try
      elems.filterNot(_.getAttribute("id") == "org.scalaide.ui.wizards.scalaCreator").map(e => FileCreatorMapping(
        e.getAttribute("id"),
        e.getAttribute("name"),
        e.getAttribute("templateId"),
        Option(e.getAttribute("icon")).getOrElse(""),
        e.getContributor().getName()
      )(e.createExecutableExtension("class").asInstanceOf[FileCreator]))
    catch {
      case e: CoreException =>
        eclipseLog.error(s"Error while trying to retrieve information from extension '$FileCreatorId'", e)
        Seq()
    }
  }<commit_msg>Wrap creation of every file creator in safe runner<commit_after>package org.scalaide.ui.internal.wizards

import org.scalaide.logging.HasLogger
import org.scalaide.ui.wizards.FileCreator
import org.scalaide.util.internal.eclipse.EclipseUtils

object FileCreatorMapping extends HasLogger {

  final val FileCreatorId = "org.scala-ide.sdt.core.fileCreator"

  /**
   * Returns all existing file creator extensions mapped to the
   * `FileCreatorMapping` class.
   */
  def mappings: Seq[FileCreatorMapping] = {
    val elems = EclipseUtils.configElementsForExtension(FileCreatorId)

    elems.filterNot(_.getAttribute("id") == "org.scalaide.ui.wizards.scalaCreator") flatMap { e =>
      EclipseUtils.withSafeRunner(s"Error while trying to retrieve information from extension '$FileCreatorId'") {
        FileCreatorMapping(
          e.getAttribute("id"),
          e.getAttribute("name"),
          e.getAttribute("templateId"),
          Option(e.getAttribute("icon")).getOrElse(""),
          e.getContributor().getName()
        )(e.createExecutableExtension("class").asInstanceOf[FileCreator])
      }
    }
  }
{'fraction_non_alphanumeric': 0.11699779249448124, 'fraction_numerical': 0.0, 'mean_word_length': 3.9047619047619047, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '7395594', 'n_tokens_mistral': 691, 'n_tokens_neox': 662, 'n_words': 121}