Esempio n. 1
0
def lsp_codeeditor(lsp_manager, qtbot_module, request):
    """CodeEditor instance with LSP services activated."""
    # Create a CodeEditor instance
    editor = CodeEditor(parent=None)
    editor.setup_editor(language='Python',
                        tab_mode=False,
                        markers=True,
                        close_quotes=True,
                        close_parentheses=True,
                        color_scheme='spyder/dark',
                        font=QFont("Monospace", 10))
    editor.resize(640, 480)
    qtbot_module.addWidget(editor)
    editor.show()

    # Redirect editor LSP requests to lsp_manager
    editor.sig_perform_lsp_request.connect(lsp_manager.send_request)

    editor.filename = 'test.py'
    editor.language = 'Python'
    lsp_manager.register_file('python', 'test.py', editor)
    server_settings = lsp_manager.main.editor.lsp_editor_settings['python']
    editor.start_lsp_services(server_settings)

    with qtbot_module.waitSignal(editor.lsp_response_signal, timeout=30000):
        editor.document_did_open()

    def teardown():
        editor.hide()
        editor.completion_widget.hide()

    request.addfinalizer(teardown)
    return editor, lsp_manager
Esempio n. 2
0
def fallback(qtbot_module, request):
    fallback = FallbackActor(None)
    qtbot_module.addWidget(fallback)

    with qtbot_module.waitSignal(fallback.sig_fallback_ready, timeout=30000):
        fallback.start()

    def teardown():
        fallback.stop()

    request.addfinalizer(teardown)
    return fallback
Esempio n. 3
0
def fallback(qtbot_module, request):
    fallback = FallbackActor(None)
    qtbot_module.addWidget(fallback)

    with qtbot_module.waitSignal(fallback.sig_fallback_ready, timeout=30000):
        fallback.start()

    def teardown():
        fallback.stop()

    request.addfinalizer(teardown)

    def call_editor(editor, tokens):
        editor.receive_text_tokens(tokens)

    fallback.sig_set_tokens.connect(call_editor)
    return fallback
Esempio n. 4
0
def fallback_codeeditor(fallback, qtbot_module, request):
    """CodeEditor instance with Fallback enabled."""
    def send_fallback_request(request):
        fallback.sig_mailbox.emit(request)

    # Create a CodeEditor instance
    editor = codeeditor_factory()
    qtbot_module.addWidget(editor)
    editor.show()

    # Redirect editor fallback requests to FallbackActor
    editor.sig_perform_fallback_request.connect(send_fallback_request)
    editor.filename = 'test.py'
    editor.language = 'Python'
    editor.start_fallback()
    qtbot_module.wait(2000)

    def teardown():
        editor.hide()
        editor.completion_widget.hide()

    request.addfinalizer(teardown)
    return editor, fallback