# Path: lib/display/Message.py
# MESSAGE = Message()
# 
# 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/utils.py
# def encode(message):
#     return bytes(message,'UTF-8')
# 
# Path: lib/utils/pathutils.py
# def get_tss_path():
#     """ Return path to tss.js """
#     return os.path.join(package_path, 'bin', 'tss.js')
# 
# def find_tsconfigdir(rootdir):
#     """ Returns the normalized dir, in which the tsconfig.json file is located"""
#     rootdir = os.path.abspath(rootdir)
#     try:
#         if file_exists(os.path.join(rootdir, "tsconfig.json")):
#             return os.path.normcase(rootdir)
#     except FileNotFoundError:
#         pass
# 
#     parentdir = os.path.abspath(os.path.join(rootdir, os.pardir))
#     if parentdir == rootdir:
#         return None
#     else:
#         return find_tsconfigdir(parentdir)
# 
# def default_node_path(node_path, project=None):
#     if node_path == 'none':
#         Debug('notify', 'The setting node_path is set to "none". That is depreciated. Remove the setting.')
#         node_path = None
# 
#     if node_path == "" or node_path is None:
#         if sys.platform == "linux":
#             return "nodejs"
#         elif sys.platform == "nt":
#             return "node"
#         elif sys.platform == "darwin":
#             return "/usr/local/bin/node"
#         else:
#             return "node"
#     else:
#         return expand_variables(node_path, project)
# 
# Path: lib/utils/osutils.py
# def get_kwargs(stderr=True):
#     if os.name == 'nt':
#         startupinfo = subprocess.STARTUPINFO()
#         startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
#         if stderr:
#             #errorlog = open(os.devnull, 'w')
#             return {'stderr':subprocess.DEVNULL, 'startupinfo': startupinfo}
#         return {'startupinfo': startupinfo}
#     else:
#         return {}
# 
# Path: lib/utils/disabling.py
# def set_plugin_temporarily_disabled(folder=None):
#     """ Enables the plugin globally or for folder.
#         Folder can be a view """
#     if folder is None:
#         if not is_plugin_globally_disabled():
#             plugin_disabled_for_folders.append("*global")
#     else:
#         if isinstance(folder, sublime.View):
#             folder = os.path.dirname(folder.file_name())
#         folder = os.path.normcase(folder)
#         Debug('project', 'Disable ArcticTypescript for %s' % folder)
#         if folder not in plugin_disabled_for_folders:
#             plugin_disabled_for_folders.append(folder)


from subprocess import Popen, PIPE
from threading import Thread
    from queue import Queue, Empty
    from Queue import Queue, Empty
from ..display.Message import MESSAGE
from ..utils import encode, Debug
from ..utils.pathutils import get_tss_path, find_tsconfigdir, default_node_path
from ..utils.osutils import get_kwargs
from ..utils.disabling import set_plugin_temporarily_disabled
import sublime
import os
import time
                self.middleware_queue.remove(c)
            Debug('adapter+', "MERGED with %i other commands (procrastinated): %s" % (len(commands_to_remove), command.id) )
            return None # defer, no execution in this round
        else:
            return command # no defer, execute now, command has already been poped


    def execute(self, async_command):
        """
            Executes Command.
            If debouncing enabled und timeout not finished, add back to the end of the queue.
            This may cause unexpected behaviour but should be unnoticed mostly.
        """
        if not async_command.can_be_executed_now():
            self.append_to_middlewarequeue(async_command, set_timer=True) # reappend to end
            Debug('adapter+', "MOVED to end of queue, debouncing")
            return
        async_command.time_execute = time.time()
        try:
            self.stdin.write(encode(async_command.command))
            self.stdin.write(encode("\n"))
            self.stdin.flush()
            Debug('tss++', "Send to tss.js: %s" % async_command.command[0:100])

            async_command.on_execute()
            # causes result callback to be called async
            results = self.stdout.readline().decode('UTF-8')
            Debug('tss++', "Received from tss.js: %s" % results[0:100])
            async_command.on_result(results)
        except Exception as e:

# Path: lib/display/Message.py
# MESSAGE = Message()
# 
# 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/utils.py
# def encode(message):
#     return bytes(message,'UTF-8')
# 
# Path: lib/utils/pathutils.py
# def get_tss_path():
#     """ Return path to tss.js """
#     return os.path.join(package_path, 'bin', 'tss.js')
# 
# def find_tsconfigdir(rootdir):
#     """ Returns the normalized dir, in which the tsconfig.json file is located"""
#     rootdir = os.path.abspath(rootdir)
#     try:
#         if file_exists(os.path.join(rootdir, "tsconfig.json")):
#             return os.path.normcase(rootdir)
#     except FileNotFoundError:
#         pass
# 
#     parentdir = os.path.abspath(os.path.join(rootdir, os.pardir))
#     if parentdir == rootdir:
#         return None
#     else:
#         return find_tsconfigdir(parentdir)
# 
# def default_node_path(node_path, project=None):
#     if node_path == 'none':
#         Debug('notify', 'The setting node_path is set to "none". That is depreciated. Remove the setting.')
#         node_path = None
# 
#     if node_path == "" or node_path is None:
#         if sys.platform == "linux":
#             return "nodejs"
#         elif sys.platform == "nt":
#             return "node"
#         elif sys.platform == "darwin":
#             return "/usr/local/bin/node"
#         else:
#             return "node"
#     else:
#         return expand_variables(node_path, project)
# 
# Path: lib/utils/osutils.py
# def get_kwargs(stderr=True):
#     if os.name == 'nt':
#         startupinfo = subprocess.STARTUPINFO()
#         startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
#         if stderr:
#             #errorlog = open(os.devnull, 'w')
#             return {'stderr':subprocess.DEVNULL, 'startupinfo': startupinfo}
#         return {'startupinfo': startupinfo}
#     else:
#         return {}
# 
# Path: lib/utils/disabling.py
# def set_plugin_temporarily_disabled(folder=None):
#     """ Enables the plugin globally or for folder.
#         Folder can be a view """
#     if folder is None:
#         if not is_plugin_globally_disabled():
#             plugin_disabled_for_folders.append("*global")
#     else:
#         if isinstance(folder, sublime.View):
#             folder = os.path.dirname(folder.file_name())
#         folder = os.path.normcase(folder)
#         Debug('project', 'Disable ArcticTypescript for %s' % folder)
#         if folder not in plugin_disabled_for_folders:
#             plugin_disabled_for_folders.append(folder)


# Path: lib/server/Processes.py
from subprocess import Popen, PIPE
from threading import Thread
    from queue import Queue, Empty
    from Queue import Queue, Empty
from ..display.Message import MESSAGE
from ..utils import encode, Debug
from ..utils.pathutils import get_tss_path, find_tsconfigdir, default_node_path
from ..utils.osutils import get_kwargs
from ..utils.disabling import set_plugin_temporarily_disabled
import sublime
import os
import time

                self.middleware_queue.remove(c)
            Debug('adapter+', "MERGED with %i other commands (procrastinated): %s" % (len(commands_to_remove), command.id) )
            return None # defer, no execution in this round
        else:
            return command # no defer, execute now, command has already been poped


    def execute(self, async_command):
        """
            Executes Command.
            If debouncing enabled und timeout not finished, add back to the end of the queue.
            This may cause unexpected behaviour but should be unnoticed mostly.
        """
        if not async_command.can_be_executed_now():
            self.append_to_middlewarequeue(async_command, set_timer=True) # reappend to end
            Debug('adapter+', "MOVED to end of queue, debouncing")
            return
        async_command.time_execute = time.time()
        try:
            self.stdin.write(encode(async_command.command))
            self.stdin.write(encode("\n"))
            self.stdin.flush()
            Debug('tss++', "Send to tss.js: %s" % async_command.command[0:100])

            async_command.on_execute()
            # causes result callback to be called async
            results = self.stdout.readline().decode('UTF-8')
            Debug('tss++', "Received from tss.js: %s" % results[0:100])
            async_command.on_result(results)
        except Exception as e:

            Debug('tss++', "ERROR: %s" % e)