<commit_before>"use babel"

const path = require("path")
const fs = require("fs-plus")

import { CompositeDisposable } from "atom"

import DscReactToolsView from "./dsc-react-tools-view"
import { findSourceDir, isPathInReactNativeProject } from "./dscHelpers"
import create from "./actions/create"
import rename from "./actions/rename"

// ----------------------------------------------------------------------------

export default {
  dscReactToolsView: null,
  modalPanel: null,
  subscriptions: null,

  activate(state) {
    this.dscReactToolsView = new DscReactToolsView(state.dscReactToolsViewState)
    this.modalPanel = atom.workspace.addModalPanel({
      item: this.dscReactToolsView.getElement(),
      visible: false,
    })

    this.subscriptions = new CompositeDisposable()
    this.subscriptions.add(
      atom.commands.add("atom-workspace", {
        "dsc-react-tools:create": () => this.createAction(),
      })
    )
    this.subscriptions.add(
      atom.commands.add("atom-workspace", {
        "dsc-react-tools:rename": () => this.renameAction(),
      })
    )
  },

  deactivate() {
    this.modalPanel.destroy()
    this.subscriptions.dispose()
    this.dscReactToolsView.destroy()
  },

  serialize() {
    return {
      dscReactToolsViewState: this.dscReactToolsView.serialize(),
    }
  },

  // ----------------------------------------------------------------------------

  closeModalPannel() {
    this.modalPanel.hide()
  },

  // ----------------------------------------------------------------------------

  createAction() {
    const filePath = getPathOfActiveItem()

    if (!filePath) {
      return
    }

    let dirname
    if (fs.isDirectorySync(filePath)) {
      dirname = filePath
    } else {
      dirname = path.dirname(filePath)
    }

    const isReactNative = isPathInReactNativeProject(dirname)

    const onCreate = givenName => {
      const { name, indexFilePath } = create(givenName, dirname, isReactNative)
      atom.notifications.addSuccess(`Component ${name} created`)
      focusAndRevealOnTreeView(indexFilePath)
    }

    let promptMessage
    if (isReactNative) {
      promptMessage = "Enter the name for the React Native component"<commit_msg>clear suggestion after every invocation<commit_after>"use babel"

const path = require("path")
const fs = require("fs-plus")

import { CompositeDisposable } from "atom"

import DscReactToolsView from "./dsc-react-tools-view"
import { findSourceDir, isPathInReactNativeProject } from "./dscHelpers"
import create from "./actions/create"
import rename from "./actions/rename"

// ----------------------------------------------------------------------------

export default {
  dscReactToolsView: null,
  modalPanel: null,
  subscriptions: null,

  activate(state) {
    this.dscReactToolsView = new DscReactToolsView(state.dscReactToolsViewState)
    this.modalPanel = atom.workspace.addModalPanel({
      item: this.dscReactToolsView.getElement(),
      visible: false,
    })

    this.subscriptions = new CompositeDisposable()
    this.subscriptions.add(
      atom.commands.add("atom-workspace", {
        "dsc-react-tools:create": () => this.createAction(),
      })
    )
    this.subscriptions.add(
      atom.commands.add("atom-workspace", {
        "dsc-react-tools:rename": () => this.renameAction(),
      })
    )
  },

  deactivate() {
    this.modalPanel.destroy()
    this.subscriptions.dispose()
    this.dscReactToolsView.destroy()
  },

  serialize() {
    return {
      dscReactToolsViewState: this.dscReactToolsView.serialize(),
    }
  },

  // ----------------------------------------------------------------------------

  closeModalPannel() {
    this.dscReactToolsView.setSuggestion("")
    this.modalPanel.hide()
  },

  // ----------------------------------------------------------------------------

  createAction() {
    const filePath = getPathOfActiveItem()

    if (!filePath) {
      return
    }

    let dirname
    if (fs.isDirectorySync(filePath)) {
      dirname = filePath
    } else {
      dirname = path.dirname(filePath)
    }

    const isReactNative = isPathInReactNativeProject(dirname)

    const onCreate = givenName => {
      const { name, indexFilePath } = create(givenName, dirname, isReactNative)
      atom.notifications.addSuccess(`Component ${name} created`)
      focusAndRevealOnTreeView(indexFilePath)
    }

    let promptMessage
    if (isReactNative) {
      promptMessage = "Enter the name for the React Native component"
{'fraction_non_alphanumeric': 0.209472981987992, 'fraction_numerical': 0.0, 'mean_word_length': 2.1631504922644162, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 9, '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': '3181758', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1266, 'n_words': 230}