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

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

      # Set analysis root.
      @setAnalysisRoots analysisRoots

class AnalysisServer
  id: 1
  promiseMap = {}
  isRunning: false

  constructor: ->
    @emitter = new Emitter()
