# 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()
# 
# def max_calls(limit = 1500, name=""):
#     """Decorator which allows its wrapped function to be called `limit` times"""
#     def decorator(func):
#         # Disable limit:
#         return func
#         @wraps(func)
#         def wrapper(*args, **kwargs):
#             calls = getattr(wrapper, 'calls', 0)
#             calls += 1
#             setattr(wrapper, 'calls', calls)
#             fname = name if name != "" else func.__name__
# 
#             if calls == limit + 1:
#                 Debug('max_calls', "LIMIT !! ## !!: Fkt %s has %i calls, stop" % (fname, calls - 1))
# 
#             if calls >= limit + 1:
#                 return None
# 
#             Debug('max_calls', "CALL: Fkt %s has %i calls -> +1" % (fname, calls - 1))
# 
#             return func(*args, **kwargs)
#         setattr(wrapper, 'calls', 0)
#         return wrapper
#     return decorator
# 
# Path: lib/utils/fileutils.py
# def fn2k(filename):
#     """ shortcut for filename2key """
#     return filename2key(filename)


import sublime
import json
import re
from ..utils import max_calls, Debug
from ..utils.fileutils import fn2k
            if not isinstance(self.lasterrors, list):
                raise Warning("tss.js internal error: %s" % errors)
            self._provide_better_explanations_for_some_errors()
            self._tssjs_to_errorview()

        except BaseException as e: # Also catches JSON exceptions
            self.lasterrors = []
            self.failure = "%s" % e
            Debug('error', 'Internal ArcticTypescript error during show_errors: %s (Exception Message: %s)' % (errors, e))

        self.project.highlighter.highlight_all_open_files()
        sublime.active_window().run_command('typescript_error_panel_set_text',
                                            { "project_id": self.project.id } )


    def _provide_better_explanations_for_tss_errors(self, errorstr):
        """ Provides better explatations for hard tss errors,
            which cause typescript-tools to return a string
            instead of an error list []
            Returns an error dict like typescript-tools would have
                done for usual errors."""

        # File <match1> is not registered in tsconfig.json
        match1 = re.match("(.*)(Could not find file: ')(.*)'.*", errorstr)
        if match1:
            missing_file = match1.groups()[2]
            better_error = "\"Maybe this file is missing in your tsconfig.json['files'] list:\n    %s \"" % missing_file
            Debug('notify', better_error)
            return {
                "file": missing_file,

# 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()
# 
# def max_calls(limit = 1500, name=""):
#     """Decorator which allows its wrapped function to be called `limit` times"""
#     def decorator(func):
#         # Disable limit:
#         return func
#         @wraps(func)
#         def wrapper(*args, **kwargs):
#             calls = getattr(wrapper, 'calls', 0)
#             calls += 1
#             setattr(wrapper, 'calls', calls)
#             fname = name if name != "" else func.__name__
# 
#             if calls == limit + 1:
#                 Debug('max_calls', "LIMIT !! ## !!: Fkt %s has %i calls, stop" % (fname, calls - 1))
# 
#             if calls >= limit + 1:
#                 return None
# 
#             Debug('max_calls', "CALL: Fkt %s has %i calls -> +1" % (fname, calls - 1))
# 
#             return func(*args, **kwargs)
#         setattr(wrapper, 'calls', 0)
#         return wrapper
#     return decorator
# 
# Path: lib/utils/fileutils.py
# def fn2k(filename):
#     """ shortcut for filename2key """
#     return filename2key(filename)


# Path: lib/system/Errors.py
import sublime
import json
import re
from ..utils import max_calls, Debug
from ..utils.fileutils import fn2k

            if not isinstance(self.lasterrors, list):
                raise Warning("tss.js internal error: %s" % errors)
            self._provide_better_explanations_for_some_errors()
            self._tssjs_to_errorview()

        except BaseException as e: # Also catches JSON exceptions
            self.lasterrors = []
            self.failure = "%s" % e
            Debug('error', 'Internal ArcticTypescript error during show_errors: %s (Exception Message: %s)' % (errors, e))

        self.project.highlighter.highlight_all_open_files()
        sublime.active_window().run_command('typescript_error_panel_set_text',
                                            { "project_id": self.project.id } )


    def _provide_better_explanations_for_tss_errors(self, errorstr):
        """ Provides better explatations for hard tss errors,
            which cause typescript-tools to return a string
            instead of an error list []
            Returns an error dict like typescript-tools would have
                done for usual errors."""

        # File <match1> is not registered in tsconfig.json
        match1 = re.match("(.*)(Could not find file: ')(.*)'.*", errorstr)
        if match1:
            missing_file = match1.groups()[2]
            better_error = "\"Maybe this file is missing in your tsconfig.json['files'] list:\n    %s \"" % missing_file
            Debug('notify', better_error)
            return {
                "file": missing_file,

                "start": {"line": 1, "character": 1},