'use babel'

import {CompositeDisposable} from 'atom'
import {provider as validateProvider} from './validate'
import Commands from './commands'
import IntentionsView from './view'

export default class Intentions {
  constructor() {
    this.subscriptions = new CompositeDisposable()
    this.commands = new Commands()
    this.view = new IntentionsView()
    this.providers = new Set()

    this.subscriptions.add(this.commands)
    this.subscriptions.add(this.view)
    this.commands.onShouldShow(_ => this.showIntentions())
    this.commands.onShouldHide(_ => this.hideIntentions())
  }
  activate() {
    this.commands.activate()
  }
  consumeProvider(provider) {
    validateProvider(provider)
    this.providers.add(provider)
  }
  showIntentions() {
    const textEditor = atom.workspace.getActiveTextEditor()
    const bufferPosition = textEditor.getCursorBufferPosition()
    console.log(textEditor, bufferPosition)
  }
  hideIntentions() {
    this.view.clear()
  }
  dispose() {
    this.subscriptions.dispose()
    this.providers.clear()
  }
}

@@ -379,16 +379,50 @@
 ew Set()
+%0A    this.intentionsLocked = false
 %0A%0A    th
@@ -780,24 +780,110 @@
 entions() %7B%0A
+    if (this.intentionsLocked) %7B%0A      return%0A    %7D%0A    this.intentionsLocked = true%0A%0A
     const te
@@ -994,24 +994,25 @@
 ition()%0A
+%0A
     cons
 ole.log(
@@ -1007,69 +1007,809 @@
 cons
-ole.log(textEditor, bufferPosition)%0A  %7D%0A  hideIntentions() %7B%0A
+t promises = %5B%5D%0A    for (const provider of this.providers) %7B%0A      promises.push(new Promise(function(resolve) %7B%0A        // TODO: Check scopes to determine if we should trigger provider%0A        resolve(provider.getIntentions(%7BtextEditor, bufferPosition%7D))%0A      %7D))%0A    %7D%0A%0A    Promise.all(promises)%0A      .then(function(results) %7B%0A        let suggestions = %5B%5D%0A        for (const result of results) %7B%0A          if (Array.isArray(result)) %7B%0A            suggestions = suggestions.concat(result)%0A          %7D%0A        %7D%0A        if (suggestions.length === 0) %7B%0A          // Got nothing to show%0A          return%0A        %7D%0A        console.log(suggestions)%0A      %7D)%0A      .catch(e =%3E console.error(e))%0A      .then(_ =%3E this.intentionsLocked = false)%0A  %7D%0A  hideIntentions() %7B%0A    if (!this.intentionsLocked) %7B%0A  
     
@@ -1822,24 +1822,30 @@
 iew.clear()%0A
+    %7D%0A
   %7D%0A  dispos

Add basic provider triggering logic