               else 'while true'
           # For now, update autocomplete to use hero instead of self/this, if hero is already used in the source.
           # Later, we should make this happen all the time - or better yet update the snippets.
-          source = spellView.getSource()
           if /hero/.test(source) or not /(self[\.\:]|this\.|\@)/.test(source)
             thisToken =
               'python': /self/,


  addCodeCombatSnippets: (level, spellView, e) ->
    snippetEntries = []
    haveFindNearestEnemy = false
    haveFindNearest = false
    for group, props of e.propGroups

        attackEntry.content = attackEntry.content.replace '${1:enemy}', '"${1:Enemy Name}"'
      snippetEntries.push attackEntry

    # Add copied hero. entries for most important ones that start with hero.
    sortedEntries = _.sortBy snippetEntries, (entry) -> -1 * parseInt(entry.importance ? 0)
    for entry in sortedEntries
      if entry.content?.indexOf('hero.') is 0
        newEntry = _.cloneDeep(entry)
        entry.name = "hero.#{newEntry.name}"
        snippetEntries.push(newEntry)
        break if snippetEntries.length - sortedEntries.length >= 10

    if haveFindNearest and not haveFindNearestEnemy
      spellView.translateFindNearest()

