# Path: lib/utils/debug.py
# def Debug(classification, text):
#     if 'all' in print_classifications or classification in print_classifications:
#         print("ArcticTypescript: %s: %s" % (classification.ljust(8), text))
#     if classification not in possible_classifications:
#         print("ArcticTypescript: debug: got unknown debug message classification: %s. " \
#             "Consider adding this to possible_classifications" % classification)
#     sys.stdout.flush()
# 
# Path: lib/utils/fileutils.py
# def read_file(filename):
#     """ returns None or file contents if available """
#     filename = os.path.normcase(filename) # back to \\ in nt
#     if os.path.isfile(filename):
#         try:
#             if os.name == 'nt':
#                 return open(filename, 'r', encoding='utf8').read()
#             else:
#                 return codecs.open(filename, 'r', 'utf-8').read()
#         except IOError:
#             pass
#     return None
# 
# def file_exists(filename):
#     """ returns weather the file exists """
#     return os.path.isfile(os.path.normcase(filename))
# 
# def fn2k(filename):
#     """ shortcut for filename2key """
#     return filename2key(filename)


from threading import Thread
from ..utils import Debug
from ..utils.fileutils import read_file, file_exists, fn2k
import sublime
import os


    def start(self):
        self.run()

    def run(self):
        self.sort_by_file()
        Debug('refactor', self.refs_by_file)

        for (file_, refs_in) in self.refs_by_file.values():
            self.refactor_file(file_, refs_in)


    def sort_by_file(self):
        """ sort references by file """

        self.refs_by_file = {} # key is the fn2k'ed filename

        for ref in self.refs:
            file_ = fn2k(ref['file'])
            if file_ not in self.refs_by_file:
                self.refs_by_file[file_] = []

            self.refs_by_file[file_].append(ref)


    def refactor_file(self, file_name_keyed, refs_in):




# Path: lib/utils/debug.py
# def Debug(classification, text):
#     if 'all' in print_classifications or classification in print_classifications:
#         print("ArcticTypescript: %s: %s" % (classification.ljust(8), text))
#     if classification not in possible_classifications:
#         print("ArcticTypescript: debug: got unknown debug message classification: %s. " \
#             "Consider adding this to possible_classifications" % classification)
#     sys.stdout.flush()
# 
# Path: lib/utils/fileutils.py
# def read_file(filename):
#     """ returns None or file contents if available """
#     filename = os.path.normcase(filename) # back to \\ in nt
#     if os.path.isfile(filename):
#         try:
#             if os.name == 'nt':
#                 return open(filename, 'r', encoding='utf8').read()
#             else:
#                 return codecs.open(filename, 'r', 'utf-8').read()
#         except IOError:
#             pass
#     return None
# 
# def file_exists(filename):
#     """ returns weather the file exists """
#     return os.path.isfile(os.path.normcase(filename))
# 
# def fn2k(filename):
#     """ shortcut for filename2key """
#     return filename2key(filename)


# Path: lib/commands/Refactor.py
from threading import Thread
from ..utils import Debug
from ..utils.fileutils import read_file, file_exists, fn2k
import sublime
import os



    def start(self):
        self.run()

    def run(self):
        self.sort_by_file()
        Debug('refactor', self.refs_by_file)

        for (file_, refs_in) in self.refs_by_file.values():
            self.refactor_file(file_, refs_in)


    def sort_by_file(self):
        """ sort references by file """

        self.refs_by_file = {} # key is the fn2k'ed filename

        for ref in self.refs:
            file_ = fn2k(ref['file'])
            if file_ not in self.refs_by_file:
                self.refs_by_file[file_] = []

            self.refs_by_file[file_].append(ref)


    def refactor_file(self, file_name_keyed, refs_in):




        Debug('refactor', 'got here! :D')