         else
           counts.project++
           message.currentFile = false
-        @_messages.add message
+        @messages.add message
 module.exports = LinterViews

    bubble

  _renderPanel: ->
    @_panel.innerHTML = ''
    @_removeMarkers()
    @_removeBubble()
    if not @_messages.size
      return @setPanelVisibility(false)
    @setPanelVisibility(true)
    activeEditor = atom.workspace.getActiveTextEditor()
    @_messages.forEach (message) =>
      if @_scope is 'file' then return unless message.currentFile
      if @_underlineIssues and message.currentFile and message.range #Add the decorations to the current TextEditor
        @_markers.push marker = activeEditor.markBufferRange message.range, {invalidate: 'never'}
        activeEditor.decorateMarker(
          marker, type: 'line-number', class: "linter-highlight #{message.class}"
        )
        activeEditor.decorateMarker(
          marker, type: 'highlight', class: "linter-highlight #{message.class}"
        )
      Element = Message.fromMessage(message, addPath: @_scope is 'project', cloneNode: true)
      @_panel.appendChild Element
    @updateBubble()


  _removeMarkers: ->
    return unless @_markers.length
    for marker in @_markers
      try marker.destroy()
    @_markers = []

  # This method is called in render, and classifies the messages according to scope
  _extractMessages: (Gen, counts) ->
    isProject = @_scope is 'project'
    activeEditor = atom.workspace.getActiveTextEditor()
    activeFile = activeEditor?.getPath()
    Gen.forEach (Entry) =>

  # This message is called in editor-linter.coffee
  render: ->
    counts = {project: 0, file: 0}
    @messages.clear()
    @linter.eachEditorLinter (editorLinter) =>
      @extractMessages(editorLinter.getMessages(), counts)
    @._extractMessages(@linter.getProjectMessages(), counts)

    @renderPanel()
    @bottomTabFile.count = counts.file
    @bottomTabProject.count = counts.project
    @bottomStatus.count = counts.project
    hasActiveEditor = typeof atom.workspace.getActiveTextEditor() isnt 'undefined'
    @bottomTabFile.visibility = hasActiveEditor
    @bottomTabProject.visibility = hasActiveEditor

  # consumed in editor-linter, _renderPanel
  updateBubble: (point) ->
    @removeBubble()
    return unless @showBubble
    return unless @messages.size
    activeEditor = atom.workspace.getActiveTextEditor()
    return unless activeEditor?.getPath()
    point = point || activeEditor.getCursorBufferPosition()
    try @messages.forEach (message) =>
      return unless message.currentFile
      return unless message.range?.containsPoint point
      @bubble = activeEditor.markBufferRange([point, point], {invalidate: 'never'})
      activeEditor.decorateMarker(
        @bubble
        {
          type: 'overlay',
          position: 'tail',
          item: @renderBubble(message)
        }
      )
      throw null

  # This method is called when we get the status-bar service
  attachBottom: (statusBar) ->
    @statusTiles.push statusBar.addLeftTile
      item: @bottomTabFile,
      priority: -1001
    @statusTiles.push statusBar.addLeftTile
      item: @bottomTabProject,
      priority: -1000
    statusIconPosition = atom.config.get('linter.statusIconPosition')
    @statusTiles.push statusBar["add#{statusIconPosition}Tile"]
      item: @bottomStatus,
      priority: 999

  # this method is called on package deactivate
  destroy: ->
    @messages.clear()
    @removeMarkers()
    @panelWorkspace.destroy()
    @removeBubble()
    for statusTile in @statusTiles
      statusTile.destroy()

  _changeTab: (Tab) ->
    if @bottomTabFile.active and Tab is 'file'
      @showPanel = not @showPanel
    else if @bottomTabProject.active and Tab is 'project'
      @showPanel = not @showPanel
    else
      @showPanel = true
    @setShowPanel(@showPanel)
    if @showPanel
      @scope = Tab
      @bottomTabProject.active = Tab is 'project'
      @bottomTabFile.active = Tab is 'file'
      @renderPanel()
    else
      @bottomTabProject.active = no
      @bottomTabFile.active = no

  _removeBubble: ->
    return unless @bubble
    @bubble.destroy()
    @bubble = null

  _renderBubble: (message) ->
    bubble = document.createElement 'div'
