def recalc(self): # plugin-wide stuff (immutable) self.settings = sublime.load_settings("Ensime.sublime-settings") server_dir = self.settings.get("ensime_server_path", "Ensime" + os.sep + "server") self.server_path = (server_dir if os.path.isabs(server_dir) else os.path.join(sublime.packages_path(), server_dir)) self.ensime_executable = ( self.server_path + os.sep + ("bin\\server.bat" if os.name == 'nt' else "bin/server")) self.ensime_args = self.settings.get("ensime_server_args") self.plugin_root = os.path.normpath( os.path.join(self.server_path, "..")) self.log_root = os.path.normpath(os.path.join(self.plugin_root, "logs")) # instance-specific stuff (immutable) (root, conf, _) = dotensime.load(self.w) self._project_root = root self._project_config = conf self.valid = self.project_config != None # system stuff (mutable) self.session_id = uuid4() self.running = False self.controller = None # injected by EnsimeStartup to ensure smooth reloading self.compiler_ready = False # core stuff (mutable) self._notes = [] self.notee = None # Tracks the most recent completion prefix that has been shown to yield empty # completion results. Use this so we don't repeatedly hit ensime for results # that don't exist. self.completion_ignore_prefix = None # debugger stuff (mutable) # didn't prefix it with "debugger_", because there are no name clashes yet self.profile_being_launched = None self.profile = None # launch config used in current debug session self.breakpoints = [] self.focus = None self._output = "" # load the session (if exists) self.load_session()
def recalc(self): # plugin-wide stuff (immutable) self.settings = sublime.load_settings("Ensime.sublime-settings") server_dir = self.settings.get("ensime_server_path", "Ensime" + os.sep + "server") self.server_path = (server_dir if os.path.isabs(server_dir) else os.path.join(sublime.packages_path(), server_dir)) self.ensime_executable = (self.server_path + os.sep + ("bin\\server.bat" if os.name == 'nt' else "bin/server")) self.ensime_args = self.settings.get("ensime_server_args") self.plugin_root = os.path.normpath(os.path.join(self.server_path, "..")) self.log_root = os.path.normpath(os.path.join(self.plugin_root, "logs")) # instance-specific stuff (immutable) (root, conf, _) = dotensime.load(self.w) self._project_root = root self._project_config = conf self.valid = self.project_config != None # system stuff (mutable) self.session_id = uuid4() self.running = False self.controller = None # injected by EnsimeStartup to ensure smooth reloading self.compiler_ready = False # core stuff (mutable) self._notes = [] self.notee = None # Tracks the most recent completion prefix that has been shown to yield empty # completion results. Use this so we don't repeatedly hit ensime for results # that don't exist. self.completion_ignore_prefix = None # debugger stuff (mutable) # didn't prefix it with "debugger_", because there are no name clashes yet self.profile_being_launched = None self.profile = None # launch config used in current debug session self.breakpoints = [] self.focus = None self._output = "" # load the session (if exists) self.load_session()
def recalc(self): """Recalculates the ensime environment variables and return True if if successfull else raises an exception. Calls dotensime.load for loading .ensime config which might raise error if config is not found or cannot be parsed. It also : Creates the cache-dir if it doesn't already exist. Create the logger. Resets the client. """ # plugin-wide stuff (immutable) self.settings = sublime.load_settings("Ensime.sublime-settings") debug = self.settings.get("debug", False) # for better experience s = sublime.load_settings("Preferences.sublime-settings") self.previous_auto_complete = s.get("auto_complete", True) s.set("auto_complete", False) self.previous_show_definitions = s.get("show_definitons", True) s.set("show_definitions", False) sublime.save_settings("Preferences.sublime-settings") # initialize parameters () self.config = dotensime.load(self.window) self.valid = self.config is not None self.project_root = self.config['root-dir'] self.notes_storage = NotesStorage() self.cache_dir = self.config['cache-dir'] self.editor = Editor(self.window, self.settings, self.notes_storage) self.client = None # ensure the cache_dir exists otherwise log initialisation will fail Util.mkdir_p(self.cache_dir) self.log_file = os.path.join(self.cache_dir, "ensime.log") if self.logger is None: self.logger = self.create_logger(debug, self.log_file) return True
def recalc(self): # plugin-wide stuff (immutable) self.settings = sublime.load_settings("Ensime.sublime-settings") server_dir = self.settings.get("ensime_server_path", "Ensime" + os.sep + "server") self.server_path = (server_dir if os.path.isabs(server_dir) else os.path.join(sublime.packages_path(), server_dir)) self.ensime_executable = ( self.server_path + os.sep + ("bin\\server.bat" if os.name == 'nt' else "bin/server")) self.ensime_args = self.settings.get("ensime_server_args") self.plugin_root = os.path.normpath( os.path.join(self.server_path, "..")) self.log_root = os.path.normpath(os.path.join(self.plugin_root, "logs")) # instance-specific stuff (immutable) (root, conf, _) = dotensime.load(self.w) self._project_root = root self._project_config = conf self.valid = self.project_config != None # system stuff (mutable) self.session_id = uuid4() self.running = False self.controller = None # injected by EnsimeStartup to ensure smooth reloading self.compiler_ready = False # TODO: find a better place for this beast class NoteStorage(object): def __init__(self): self.data = [] self.normalized_cache = {} self.per_file_cache = {} def append(self, data): self.data += data for datum in data: if not datum.file_name in self.normalized_cache: self.normalized_cache[ datum.file_name] = normalize_path(datum.file_name) file_name = self.normalized_cache[datum.file_name] if not file_name in self.per_file_cache: self.per_file_cache[file_name] = [] self.per_file_cache[file_name].append(datum) def filter(self, pred): dropouts = set( map(lambda n: self.normalized_cache[n.file_name], filter(lambda n: not pred(n), self.data))) # doesn't take into account pathological cases when a "*.scala" file # is actually a symlink to something without a ".scala" extension for file_name in self.per_file_cache.keys(): if file_name in dropouts: del self.per_file_cache[file_name] self.data = filter(pred, self.data) def clear(self): self.filter(lambda f: False) def for_file(self, file_name): if not file_name in self.normalized_cache: self.normalized_cache[file_name] = normalize_path( file_name) file_name = self.normalized_cache[file_name] if not file_name in self.per_file_cache: self.per_file_cache[file_name] = [] return self.per_file_cache[file_name] # core stuff (mutable) self._notes = NoteStorage() self.notee = None # Tracks the most recent completion prefix that has been shown to yield empty # completion results. Use this so we don't repeatedly hit ensime for results # that don't exist. self.completion_ignore_prefix = None # debugger stuff (mutable) # didn't prefix it with "debugger_", because there are no name clashes yet self.profile_being_launched = None self.profile = None # launch config used in current debug session self.breakpoints = [] self.focus = None self.backtrace = None self.stackframe = None self.watchstate = None self._output = "" # load the session (if exists) self.load_session()
def test_raises_DotEnsimeNotFound(): attrs = {'folders.return_value': [str(resources / 'mockempty')]} window = mock.NonCallableMock(name='mockwindow', **attrs) with raises(DotEnsimeNotFound): config = load(window)
def test_loads_dot_ensime(): attrs = {'folders.return_value': [str(resources / 'mockproject')]} window = mock.NonCallableMock(name='mockwindow', **attrs) config = load(window) assert type(config) == ProjectConfig
def recalc(self): # plugin-wide stuff (immutable) self.settings = sublime.load_settings("Ensime.sublime-settings") server_dir = self.settings.get("ensime_server_path", "Ensime" + os.sep + "server") self.server_path = (server_dir if os.path.isabs(server_dir) else os.path.join(sublime.packages_path(), server_dir)) self.ensime_executable = (self.server_path + os.sep + ("bin\\server.bat" if os.name == 'nt' else "bin/server")) self.ensime_args = self.settings.get("ensime_server_args") self.plugin_root = os.path.normpath(os.path.join(self.server_path, "..")) self.log_root = os.path.normpath(os.path.join(self.plugin_root, "logs")) # instance-specific stuff (immutable) (root, conf, _) = dotensime.load(self.w) self._project_root = root self._project_config = conf self.valid = self.project_config != None # system stuff (mutable) self.session_id = uuid4() self.running = False self.controller = None # injected by EnsimeStartup to ensure smooth reloading self.compiler_ready = False # TODO: find a better place for this beast class NoteStorage(object): def __init__(self): self.data = [] self.normalized_cache = {} self.per_file_cache = {} def append(self, data): self.data += data for datum in data: if not datum.file_name in self.normalized_cache: self.normalized_cache[datum.file_name] = normalize_path(datum.file_name) file_name = self.normalized_cache[datum.file_name] if not file_name in self.per_file_cache: self.per_file_cache[file_name] = [] self.per_file_cache[file_name].append(datum) def filter(self, pred): dropouts = set(map(lambda n: self.normalized_cache[n.file_name], filter(lambda n: not pred(n), self.data))) # doesn't take into account pathological cases when a "*.scala" file # is actually a symlink to something without a ".scala" extension for file_name in self.per_file_cache.keys(): if file_name in dropouts: del self.per_file_cache[file_name] self.data = filter(pred, self.data) def clear(self): self.filter(lambda f: False) def for_file(self, file_name): if not file_name in self.normalized_cache: self.normalized_cache[file_name] = normalize_path(file_name) file_name = self.normalized_cache[file_name] if not file_name in self.per_file_cache: self.per_file_cache[file_name] = [] return self.per_file_cache[file_name] # core stuff (mutable) self._notes = NoteStorage() self.notee = None # Tracks the most recent completion prefix that has been shown to yield empty # completion results. Use this so we don't repeatedly hit ensime for results # that don't exist. self.completion_ignore_prefix = None # debugger stuff (mutable) # didn't prefix it with "debugger_", because there are no name clashes yet self.profile_being_launched = None self.profile = None # launch config used in current debug session self.breakpoints = [] self.focus = None self.backtrace = None self.stackframe = None self.watchstate = None self._output = "" # load the session (if exists) self.load_session()