def editor_splitter_lsp(qtbot_module, lsp_plugin, request): text = """ import sys """ completions = lsp_plugin def report_file_open(options): filename = options['filename'] language = options['language'] callback = options['codeeditor'] completions.register_file(language.lower(), filename, callback) capabilities = ( completions.main.editor.completion_capabilities['python']) callback.start_completion_services() callback.register_completion_capabilities(capabilities) with qtbot_module.waitSignal(callback.lsp_response_signal, timeout=30000): callback.document_did_open() def register_editorstack(editorstack): editorstack.sig_perform_completion_request.connect( completions.send_request) editorstack.sig_open_file.connect(report_file_open) capabilities = ( completions.main.editor.completion_capabilities['python']) editorstack.register_completion_capabilities(capabilities, 'python') def clone(editorstack, template=None): # editorstack.clone_from(template) editor_stack = EditorStack(None, []) editor_stack.set_find_widget(Mock()) editor_stack.set_io_actions(Mock(), Mock(), Mock(), Mock()) # Emulate "cloning" editorsplitter.editorstack.new('test.py', 'utf-8', text) mock_plugin = Mock() editorsplitter = EditorSplitter( None, mock_plugin, [], register_editorstack_cb=register_editorstack) editorsplitter.editorstack.set_find_widget(Mock()) editorsplitter.editorstack.set_io_actions(Mock(), Mock(), Mock(), Mock()) editorsplitter.editorstack.new('test.py', 'utf-8', text) mock_plugin.clone_editorstack.side_effect = partial( clone, template=editorsplitter.editorstack) qtbot_module.addWidget(editorsplitter) editorsplitter.show() def teardown(): editorsplitter.hide() editorsplitter.close() request.addfinalizer(teardown) lsp = completions.get_client('lsp') return editorsplitter, lsp
def editor_splitter_bot(qtbot): """Create editor splitter.""" es = EditorSplitter(None, Mock(), [], first=True) qtbot.addWidget(es) es.resize(640, 480) es.show() return es
def __init__(self, parent=None): Qt.QSplitter.__init__(self, parent) self.editorstacks = [] self.editorwindows = [] self.menu_actions, self.io_actions = self.createMenuActions() self.find_widget = FindReplace(self, enable_replace=True) self.outlineexplorer = OutlineExplorerWidget(self, show_fullpath=False, show_all_files=False) self.outlineexplorer.edit_goto.connect(self.go_to_file) self.editor_splitter = EditorSplitter(self, self, self.menu_actions, first=True) editor_widgets = Qt.QWidget(self) editor_layout = Qt.QVBoxLayout() editor_layout.setContentsMargins(0, 0, 0, 0) editor_widgets.setLayout(editor_layout) editor_layout.addWidget(self.editor_splitter) editor_layout.addWidget(self.find_widget) self.setContentsMargins(0, 0, 0, 0) self.addWidget(editor_widgets) self.addWidget(self.outlineexplorer) self.setStretchFactor(0, 5) self.setStretchFactor(1, 1) self.toolbar_list = None self.menu_list = None self.setup_window([], []) try: # spyder v3 from spyder.utils.introspection.manager import IntrospectionManager # Set introspector introspector = IntrospectionManager() editorstack = self.editor_splitter.editorstack editorstack.set_introspector(introspector) introspector.set_editor_widget(editorstack) except ImportError: pass # TODO: support introspection with spyder v4
def editor_splitter_bot(qtbot): """Create editor splitter.""" es = EditorSplitter(None, Mock(), [], first=True) qtbot.addWidget(es) es.show() return es