 class AnalysisServer
   id: 1
   promiseMap = {}
-  writable: false
+  isRunning: false
 
   constructor: ->
     @emitter = new Emitter()

  sendMessage: (obj) =>
    obj.id ||= "dart-tools-#{(@id++)}"
    msg = JSON.stringify(obj)
    if @writable
      @process?.stdin?.write(msg + "\n")

    deferred = Q.defer()

    cmd = Utils.getExecPath 'dart'
    Utils.whenDartSdkFound =>
      @process = spawn cmd, args
      @isRunning = true
      @process.stdout.pipe(StreamSplitter("\n")).on 'token', @processMessage
      @process.on 'exit', =>
        @isRunning = false

      # Set analysis root.
      @setAnalysisRoots analysisRoots
