示例#1
0
  // Refresh the list of submodules in the repository.
  //
  // Returns a {Promise} which resolves to an {Object} keyed by {String}
  // submodule names with {GitRepositoryAsync} values.
  async _refreshSubmodules () {
    const repo = await this.getRepo()
    const wd = await this.getWorkingDirectory()
    const submoduleNames = await repo.getSubmoduleNames()
    for (const name of submoduleNames) {
      const alreadyExists = Boolean(this.submodules[name])
      if (alreadyExists) continue

      const submodule = await Git.Submodule.lookup(repo, name)
      const absolutePath = path.join(wd, submodule.path())
      const submoduleRepo = GitRepositoryAsync.open(absolutePath, {openExactPath: true, refreshOnWindowFocus: false})
      this.submodules[name] = submoduleRepo
    }

    for (const name in this.submodules) {
      const repo = this.submodules[name]
      const gone = submoduleNames.indexOf(name) < 0
      if (gone) {
        repo.destroy()
        delete this.submodules[name]
      } else {
        try {
          await repo.refreshStatus()
        } catch (e) {
          // libgit2 will sometimes report submodules that aren't actually valid
          // (https://github.com/libgit2/libgit2/issues/3580). So check the
          // validity of the submodules by removing any that fail.
          repo.destroy()
          delete this.submodules[name]
        }
      }
    }

    return _.values(this.submodules)
  }
示例#2
0
  reset (packageManager) {
    this.packageManager = packageManager
    this.emitter.dispose()
    this.emitter = new Emitter()

    this.paneContainer.destroy()
    _.values(this.panelContainers).forEach(panelContainer => { panelContainer.destroy() })

    this.paneContainer = new PaneContainer({
      config: this.config,
      applicationDelegate: this.applicationDelegate,
      notificationManager: this.notificationManager,
      deserializerManager: this.deserializerManager
    })
    this.paneContainer.onDidDestroyPaneItem(this.didDestroyPaneItem)

    this.panelContainers = {
      top: new PanelContainer({location: 'top'}),
      left: new PanelContainer({location: 'left'}),
      right: new PanelContainer({location: 'right'}),
      bottom: new PanelContainer({location: 'bottom'}),
      header: new PanelContainer({location: 'header'}),
      footer: new PanelContainer({location: 'footer'}),
      modal: new PanelContainer({location: 'modal'})
    }

    this.originalFontSize = null
    this.openers = []
    this.destroyedItemURIs = []
    this.consumeServices(this.packageManager)
  }
  // Private: Given an array of actions taken previously in the hand, returns
  // an array of available actions.
  //
  // player - The player who is acting
  // previousActions - A map of players to their most recent action
  //
  // Returns an array of strings
  static getAvailableActions(player, previousActions) {
    let actions = _.values(previousActions);
    let betActions = _.filter(actions, a => a.name === 'bet' || a.name === 'raise');
    let hasBet = betActions.length > 0;

    let availableActions = [];

    if (player.hasOption) {
      availableActions.push('check');
      availableActions.push('raise');
    } else if (hasBet) {
      availableActions.push('call');
      availableActions.push('raise');
    } else {
      availableActions.push('check');
      availableActions.push('bet');
    }

    // Prevent players from raising when they don't have enough chips.
    let raiseIndex = availableActions.indexOf('raise');
    if (raiseIndex > -1) {
      let previousWager = player.lastAction ? player.lastAction.amount : 0;
      let availableChips = player.chips + previousWager;
      
      if (_.max(betActions, a => a.amount).amount >= availableChips) {
        availableActions.splice(raiseIndex, 1);
      }
    }

    availableActions.push('fold');
    return availableActions;
  }
      this.invoke('all').then((items) => {
        // De-duplicate by merging together all duplicate items
        // This has the lovely bonus of adding timestamps to
        // projects.cson - provided projects
        let result = {}
        for (let item of items) {
          let key = atom.getStateKey(item.paths)
          result[key] = _.extend(result[key] || {}, item)
        }

        result = _.values(result)

        // Filter
        result = util.filterProjects(result, options)

        resolve(result)
      })
  getSnippetProperties () {
    const packageProperties = {}
    for (const {name, properties, selectorString} of this.snippetsProvider.getSnippets()) {
      if (name && name.indexOf && name.indexOf(this.packagePath) === 0) {
        const object = properties.snippets != null ? properties.snippets : {}
        for (let key in object) {
          const snippet = object[key]
          if (snippet != null) {
            snippet.selectorString = selectorString
            if (packageProperties[key] == null) {
              packageProperties[key] = snippet
            }
          }
        }
      }
    }

    return _.values(packageProperties).sort((snippet1, snippet2) => {
      const prefix1 = snippet1.prefix != null ? snippet1.prefix : ''
      const prefix2 = snippet2.prefix != null ? snippet2.prefix : ''
      return prefix1.localeCompare(prefix2)
    })
  }
 getProviders () {
   return _.values(this.providers)
 }
 let task = this.runLoadSymbolsTask((results) => {
   // We now have all the symbols..
   this.setItems(_.flatten(_.values(results)));
 });