def on_post_save(self, view): if not is_view_dart_script(view): _logger.debug("not a dart file: %s", view.file_name()) return # The file has been (potentially) changed, so make a note. with g_edits_lock: DartLint.edits[view.buffer_id()] += 1 self.load_settings(view) if not self.do_lint_on_post_save: _logger.debug("linter is disabled (on_post_save)") _logger.debug("do_lint: %s", str(self.do_lint)) _logger.debug("do_save: %s", str(self.do_save)) return self.check_theme(view) file_name = view.file_name() print("Dart lint: Running dartanalyzer on ", file_name) _logger.debug("running dartanalyzer on %s", file_name) # run dartanalyzer in its own thread # TODO(guillermooo): Disable quick list error navigation, since we are # enabling output panel-based error navigation (via F4). We should # choose one of the two and remove the other. RunDartanalyzer(view, file_name, self.settings, show_popup=False)
def on_activated(self, view): if not is_view_dart_script(view): _logger.debug("not a dart file: %s", view.file_name()) return # TODO(guillermooo): Some of this stuff is duplicated. self.load_settings(view) if not self.do_lint_on_load: _logger.debug("linter is disabled (on_load)") _logger.debug("do_lint: %s", str(self.do_lint)) _logger.debug("do_save: %s", str(self.do_save)) return self.check_theme(view) if view.id() == sublime.active_window().active_view().id(): file_name = view.file_name() print("Dart lint: Running dartanalyzer on ", file_name) _logger.debug("running dartanalyzer on %s", file_name) # run dartanalyzer in its own thread RunDartanalyzer(view, file_name, self.settings, show_popup=False, force=True)
def on_idle(self, view): if not is_view_dart_script(view): return # _logger.debug("active view was idle; could send requests") if AnalysisServer.ping(): if view.is_dirty() and is_active(view): _logger.debug('sending overlay data for %s', view.file_name()) g_server.send_add_content(view)
def on_load(self, view): if not is_view_dart_script(view): return with ActivityTracker.edits_lock: ActivityTracker.edits[view.id()] = 0 if AnalysisServer.ping(): g_server.send_remove_content(view)
def on_selection_modified_async(self, view): if not is_view_dart_script(view): return if len(view.sel()) > 1 or len(view.sel()) == 0: return if not view.is_auto_complete_visible(): return with editor_context.autocomplete_context as actx: if actx.should_hide_auto_complete_list(view): view.run_command('hide_auto_complete')
def on_modified(self, view): if not is_view_dart_script(view): # Don't log here -- it'd impact performance. # _logger.debug('on_modified - not a dart file; aborting: %s', # view.file_name()) return if not view.file_name(): # Don't log here -- it'd impact performance. # _logger.debug( # 'aborting because file does not exist on disk: %s', # view.file_name()) return self.increment_edits(view)
def on_post_save(self, view): if not is_view_dart_script(view): # _logger.debug('on_post_save - not a dart file %s', # view.file_name()) return with ActivityTracker.edits_lock: # TODO(guillermooo): does .id() uniquely identify views # across windows? ActivityTracker.edits[view.id()] += 1 sublime.set_timeout(lambda: self.check_idle(view), 1000) # The file has been saved, so force use of filesystem content. if AnalysisServer.ping(): g_server.send_remove_content(view)
def on_activated(self, view): if not is_view_dart_script(view): # _logger.debug('on_activated - not a dart file %s', # view.file_name()) return if AnalysisServer.ping() and not view.is_loading(): g_server.add_root(view.file_name()) if is_active(view): g_server.send_set_priority_files([view.file_name()]) if view.is_dirty(): g_server.send_add_content(view) else: after(250, self.on_activated, view)
def on_activated(self, view): if not is_view_dart_script(view): # _logger.debug('on_activated - not a dart file %s', # view.file_name()) return if AnalysisServer.ping(): g_server.add_root(view.file_name()) if is_active(view): g_server.send_set_priority_files([view.file_name()]) if view.is_dirty(): g_server.send_add_content(view) else: after(250, self.on_activated, view)
def on_query_completions(self, view, prefix, locations): if not is_view_dart_script(view): return ([], 0) if view.settings().get('command_mode') is True: return ([], self._INHIBIT_OTHER) if self._in_string_or_comment(view, locations): return ([], 0) completions = [] with editor_context.autocomplete_context as actx: completions = actx.formatted_results actx.invalidate_results() if completions: return (completions, self._INHIBIT_OTHER) return ([], self._INHIBIT_OTHER)
def on_modified(self, view): if not is_view_dart_script(view): # Don't log here -- it'd impact performance. # _logger.debug('on_modified - not a dart file; aborting: %s', # view.file_name()) return if not view.file_name(): # Don't log here -- it'd impact performance. # _logger.debug( # 'aborting because file does not exist on disk: %s', # view.file_name()) return # if we've `revert`ed the buffer, it'll be clean if not view.is_dirty(): self.on_load(view) return self.increment_edits(view)
def on_pre_save(self, view): if not is_view_dart_script(view): _logger.debug("not a dart file: %s", view.file_name()) return settings = sublime.load_settings('Dart - Plugin Settings.sublime-settings') dartfmt_on_save = settings.get('dartfmt_on_save') if not dartfmt_on_save: _logger.debug("dartfmt is disabled (dartfmt_on_save is false)") return print("Dart format: Running dartfmt on ", view.file_name()) # Format the whole view using the dartfmt command, rather than the # analyzer, since we need it to happen synchronously. Otherwise, the # formatting would happen after the save, leaving a dirty view. text = view.substr(sublime.Region(0, view.size())) formatted_text = DartFormat().format(text) view.run_command('dart_replace_region', { 'region': [0, view.size()], 'text': formatted_text + '\n' })
def on_deactivated(self, view): # Any ongoing searches must be invalidated. del editor_context.search_id if not is_view_dart_script(view): return
def testFailsIfFileNotOnDisk(self): self.assertFalse(is_view_dart_script(self.view))
def on_deactivated(self, view): # Any ongoing searches must be invalidated. del g_editor_context.search_id if not is_view_dart_script(view): return
def is_dart_file(self): return is_view_dart_script(self.view)
def on_deactivated(self, view): # FIXME: what's this supposed to do? # Perhaps we should remove this file from the priority files? if not is_view_dart_script(view): return