def _handle_welcome(self, welcome): """ Identifies if we support the current version of the stack ide api """ expected_version = (0,1,1) version_got = tuple(welcome) if type(welcome) is list else welcome if expected_version > version_got: Log.error("Old stack-ide protocol:", version_got, '\n', 'Want version:', expected_version) complain("wrong-stack-ide-version", "Please upgrade stack-ide to a newer version.") elif expected_version < version_got: Log.warning("stack-ide protocol may have changed:", version_got) else: Log.debug("stack-ide protocol version:", version_got)
def _handle_welcome(self, welcome): """ Identifies if we support the current version of the stack ide api """ expected_version = (0, 1, 1) version_got = tuple(welcome) if type(welcome) is list else welcome if expected_version > version_got: Log.error("Old stack-ide protocol:", version_got, '\n', 'Want version:', expected_version) complain("wrong-stack-ide-version", "Please upgrade stack-ide to a newer version.") elif expected_version < version_got: Log.warning("stack-ide protocol may have changed:", version_got) else: Log.debug("stack-ide protocol version:", version_got)
def configure_instance(window, settings): folder = first_folder(window) if not folder: msg = "No folder to monitor for window " + str(window.id()) Log.normal("Window {}: {}".format(str(window.id()), msg)) instance = NoStackIDE(msg) elif not has_cabal_file(folder): msg = "No cabal file found in " + folder Log.normal("Window {}: {}".format(str(window.id()), msg)) instance = NoStackIDE(msg) elif not os.path.isfile(expected_cabalfile(folder)): msg = "Expected cabal file " + expected_cabalfile(folder) + " not found" Log.normal("Window {}: {}".format(str(window.id()), msg)) instance = NoStackIDE(msg) elif not is_stack_project(folder): msg = "No stack.yaml in path " + folder Log.warning("Window {}: {}".format(str(window.id()), msg)) instance = NoStackIDE(msg) # TODO: We should also support single files, which should get their own StackIDE instance # which would then be per-view. Have a registry per-view that we check, then check the window. else: try: # If everything looks OK, launch a StackIDE instance Log.normal("Initializing window", window.id()) instance = StackIDE(window, settings) except FileNotFoundError as e: instance = NoStackIDE("instance init failed -- stack not found") Log.error(e) complain('stack-not-found', "Could not find program 'stack'!\n\n" "Make sure that 'stack' and 'stack-ide' are both installed. " "If they are not on the system path, edit the 'add_to_PATH' " "setting in SublimeStackIDE preferences." ) except Exception: instance = NoStackIDE("instance init failed -- unknown error") Log.error("Failed to initialize window " + str(window.id()) + ":") Log.error(traceback.format_exc()) return instance
def configure_instance(window, settings): folder = first_folder(window) if not folder: msg = "No folder to monitor for window " + str(window.id()) Log.normal("Window {}: {}".format(str(window.id()), msg)) instance = NoStackIDE(msg) elif not has_cabal_file(folder): msg = "No cabal file found in " + folder Log.normal("Window {}: {}".format(str(window.id()), msg)) instance = NoStackIDE(msg) elif not os.path.isfile(expected_cabalfile(folder)): msg = "Expected cabal file " + expected_cabalfile( folder) + " not found" Log.normal("Window {}: {}".format(str(window.id()), msg)) instance = NoStackIDE(msg) elif not is_stack_project(folder): msg = "No stack.yaml in path " + folder Log.warning("Window {}: {}".format(str(window.id()), msg)) instance = NoStackIDE(msg) # TODO: We should also support single files, which should get their own StackIDE instance # which would then be per-view. Have a registry per-view that we check, then check the window. else: try: # If everything looks OK, launch a StackIDE instance Log.normal("Initializing window", window.id()) instance = StackIDE(window, settings) except FileNotFoundError as e: instance = NoStackIDE("instance init failed -- stack not found") Log.error(e) complain( 'stack-not-found', "Could not find program 'stack'!\n\n" "Make sure that 'stack' and 'stack-ide' are both installed. " "If they are not on the system path, edit the 'add_to_PATH' " "setting in SublimeStackIDE preferences.") except Exception: instance = NoStackIDE("instance init failed -- unknown error") Log.error("Failed to initialize window " + str(window.id()) + ":") Log.error(traceback.format_exc()) return instance
def test_complaints_not_repeated(self): utility.complain('complaint', 'waaaah') self.assertEqual(sublime.current_error, 'waaaah') utility.complain('complaint', 'waaaah 2') self.assertEqual(sublime.current_error, 'waaaah') utility.reset_complaints() utility.complain('complaint', 'waaaah 2') self.assertEqual(sublime.current_error, 'waaaah 2')