     if err?
       @handleError(err)
       return false
-      
+
     return true
 
   setupRuntime: (codeContext) ->
-    
+
     # Store information about the run
     commandContext = {}
 


    codeContext = new CodeContext(filename, filepath, textSource)
    codeContext.selection = selection
    
    # Get language
    lang = @getLang editor

    if @validateLang lang
      codeContext.lang = lang
    
    return codeContext

  lineRun: ->
    @resetView()
    codeContext = @buildCodeContext('Line Based')
    @start(codeContext) unless not codeContext?
  
  defaultRun: ->
    @resetView()
    codeContext = @buildCodeContext() # Until proven otherwise
    @start(codeContext) unless not codeContext?
    
  buildCodeContext: (argType='Selection Based') ->
    # Get current editor
    editor = atom.workspace.getActiveEditor()
    # No editor available, do nothing
    return unless editor?
    
    codeContext = @initCodeContext(editor)
    
    codeContext.argType = argType
    
    if argType == 'Line Based'
      cursor = editor.getCursor()
      codeContext.lineNumber = cursor.getScreenRow() + 1
      editor.save()
    else if codeContext.selection.isEmpty() and codeContext.filepath?
      codeContext.argType = 'File Based'
      editor.save()
        
    return codeContext

  start: (codeContext) ->
    
    # If language was not determined, do nothing
    if not codeContext.lang?
      # In the future we could handle a runner without the language being part
      # of the grammar map, using the options runner
      return
    
    commandContext = @setupRuntime codeContext
    @run commandContext.command, commandContext.args if commandContext


    @detach() if @hasParent()

  getLang: (editor) -> editor.getGrammar().name

  validateLang: (lang) ->
    err = null

