     @lineRange = new Range [0, @options.bufferPosition.row],
       @options.bufferPosition
 
-  genTypeSearch: =>
-    unless @controller.backend
-      return Promise.reject(Error('no backend'))
-    r = new Range @options.bufferPosition, @options.bufferPosition
-    @controller.backend.getType(@editor.getBuffer(), r)
+  lineSearch: (rx,idx=0) =>
+    res=""
+    @editor.backwardsScanInBufferRange rx,
+      @lineRange, ({match,stop})->
+        res=match[idx]
+        stop()
+    res
+
+  isIn: (scope) ->
+    scope.every (s1) =>
+      @scopes.some (s) ->
+        s==s1
+
+  getPrefix: (rx=/[\w.']+/) =>
+    @lineSearch rx
 
   #ghc-mod search
-  getModule: (prefix) =>
+  getModule: =>
+    prefix = @getPrefix()
     @info.moduleList
       .filter (line) ->
         line.startsWith prefix

    replacementPrefix: prefix
    description: s.name+" :: "+s.typeSignature

  getMatches: (prefix,type) =>
    @symbols
      .filter (s) ->
        s.name.startsWith(prefix)\

  moduleScope: ['meta.import.haskell', 'support.other.module.haskell']
  preprocessorScope: ['meta.preprocessor.haskell']
  exportsScope: ['meta.import.haskell', 'meta.declaration.exports.haskell']

  pragmaWords: [
    'LANGUAGE', 'OPTIONS_GHC', 'INCLUDE', 'WARNING', 'DEPRECATED', 'INLINE',
    'NOINLINE', 'ANN', 'LINE', 'RULES', 'SPECIALIZE', 'UNPACK', 'SOURCE'
  ]

  constructor: (@options,@info,@controller) ->
    @editor = @options.editor
