# 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


import sublime
from ...utils import Debug, max_calls
        """
            searches for open views with the title of this view (eg 'Typescript : Errors List')
            and uses them. If no such view can be found, it creates one and layoutes it to group 1
        """
        if self.get_view() is None:

            ## add next to existing t3s views
            ## or create layout if not created yet
            self.t3sviews.get_window_and_group_for_new_views()
            if not self.t3sviews.has_open_views():
                self.t3sviews.layout.create(self.t3sviews.window)

            view = self.t3sviews.window.new_file()
            self._set_up_view(view)

            self.t3sviews.layout.add_view(self.t3sviews.window, view, self.t3sviews.group)
            self._view_reference = view

        return self._view_reference

    @max_calls()
    def _set_up_view(self, view):
        view.set_name(self.name)
        view.set_scratch(True)
        view.set_read_only(True)
        view.set_syntax_file('Packages/ArcticTypescript/theme/Typescript.tmLanguage')
        view.settings().set('line_numbers', False)
        view.settings().set('word_wrap', True)
        view.settings().set('extensions',['js'])


# 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/display/views/Base.py
import sublime
from ...utils import Debug, max_calls

        """
            searches for open views with the title of this view (eg 'Typescript : Errors List')
            and uses them. If no such view can be found, it creates one and layoutes it to group 1
        """
        if self.get_view() is None:

            ## add next to existing t3s views
            ## or create layout if not created yet
            self.t3sviews.get_window_and_group_for_new_views()
            if not self.t3sviews.has_open_views():
                self.t3sviews.layout.create(self.t3sviews.window)

            view = self.t3sviews.window.new_file()
            self._set_up_view(view)

            self.t3sviews.layout.add_view(self.t3sviews.window, view, self.t3sviews.group)
            self._view_reference = view

        return self._view_reference

    @max_calls()
    def _set_up_view(self, view):
        view.set_name(self.name)
        view.set_scratch(True)
        view.set_read_only(True)
        view.set_syntax_file('Packages/ArcticTypescript/theme/Typescript.tmLanguage')
        view.settings().set('line_numbers', False)
        view.settings().set('word_wrap', True)
        view.settings().set('extensions',['js'])


    @max_calls()