 CP = require('child_process')
+{Range} = require 'atom'
 module.exports=
 class SuggestionBuilder
   typeScope: 'meta.function.type-declaration.haskell'
   sourceScope: 'source.haskell'
   moduleScope: 'support.other.module.haskell'
+  preprocessorScope: 'meta.preprocessor.haskell'
 
   constructor: (@options,@info) ->
     @editor = @options.editor

          label: @trim label
          prefix: @prefix
        }
  getModule: (data) =>
    data
      .filter (line) ->
        line.contains('module')
      .map (line) =>
        label='module'
        line=line.slice(line.indexOf(' ')+1)
        line=line.slice(line.indexOf(' ')+1)
        name=line
        {
          word: name
          label: @trim label
          prefix: @prefix
        }

  replaceModuleName: (search) ->
    search.replace('_','.')

  isIn: (scope) ->
    @scopes.some (s) -> s==scope

  getSuggestions: =>
    if @isIn(@typeScope)

        .then(@getType)
    else if @isIn(@moduleScope)
      console.log('moduleScope')
      @genSpaceSearch()
        .then(@getModule)
    else if @isIn(@preprocessorScope)
      console.log('preprocessorScope')
      @genSpaceSearch()
        .then(@getPreprocessor)
    #should be last as least sepcialized
    else if @isIn(@sourceScope)
      console.log('sourceScope')
