Example #1
0
def run_test():
    buf = GPS.EditorBuffer.get(GPS.File('main.adb'))
    buf.current_view().goto(buf.at(5, 10))

    # wait LSP responses has been processed to have folding information
    if GPS.LanguageServer.is_enabled_for_language_name("Ada"):
        yield wait_tasks(other_than=known_tasks)

    GPS.execute_action('goto declaration')
    yield wait_language_server('textDocument/declaration')

    current_buf = GPS.EditorBuffer.get()
    gps_assert(current_buf.file(), GPS.File('hello_world.ads'),
               "'goto declaration' did not open the right file")

    current_loc = current_buf.main_cursor().location()
    gps_assert(current_loc, current_buf.at(3, 33),
               "'goto declaration' did not jump to right location")

    # wait LSP responses has been processed to have folding information
    if GPS.LanguageServer.is_enabled_for_language_name("Ada"):
        yield wait_tasks(other_than=known_tasks)

    GPS.execute_action('goto body')
    yield wait_language_server('textDocument/implementation')

    current_buf = GPS.EditorBuffer.get()
    gps_assert(current_buf.file(), GPS.File('hello_world.adb'),
               "'goto body' did not open the right file")

    current_loc = current_buf.main_cursor().location()
    gps_assert(current_loc, current_buf.at(5, 33),
               "'goto body' did not jump to right location")
Example #2
0
def test_driver():
    server = GPS.LanguageServer.get_by_language_name("ada")
    yield wait_tasks()

    GPS.Project.load('../b/p2.gpr')
    server = GPS.LanguageServer.get_by_language_name("ada")
    yield wait_tasks()
Example #3
0
def driver():
    b = GPS.EditorBuffer.get(GPS.File("main.adb"))
    b.current_view().goto(b.at(4, 7))
    yield wait_tasks(other_than=known_tasks)

    # First verify that the navigation does *not* work
    GPS.execute_action('goto declaration')
    # At this point "language_server_response_processed" shouldn't work,
    # timeout instead
    yield timeout(500)
    current_buf = GPS.EditorBuffer.get()
    gps_assert(current_buf.file(), GPS.File('main.adb'),
               "'goto declaration' should not have worked at this point")

    # Now set the project path and reload the project
    GPS.setenv("GPR_PROJECT_PATH", os.path.join(GPS.pwd(), "subdir"))

    # Restart the language server
    GPS.LanguageServer.get_by_language_name("Ada").restart()
    GPS.Project.load("p.gpr")
    yield timeout(1000)

    # Verify that the navigation works now
    b = GPS.EditorBuffer.get(GPS.File("main.adb"))
    b.current_view().goto(b.at(4, 7))
    yield wait_idle()
    GPS.execute_action('goto declaration')
    # using this hook to be sure that declaration is found by ALS
    yield hook("language_server_response_processed")
    gps_assert(GPS.EditorBuffer.get().file(), GPS.File('foo.ads'),
               "'goto declaration' did not open the right file")

    GPS.Project.load("p1.gpr")
    b = GPS.EditorBuffer.get(GPS.File("main1.adb"))
    b.current_view().goto(b.at(6, 26))
    yield wait_tasks()
    GPS.execute_action('goto declaration')
    yield hook("language_server_response_processed")
    yield wait_idle()
    gps_assert(b.current_view().cursor().line(), 4,
               "'goto declaration' did not find a proper line")

    GPS.LanguageServer.get_by_language_name("Ada").restart()
    yield timeout(1000)

    b.current_view().goto(b.at(6, 26))
    yield wait_idle()
    GPS.execute_action('goto declaration')
    yield hook("language_server_response_processed")
    yield wait_idle()
    yield timeout(300)
    gps_assert(b.current_view().cursor().line(), 4,
               "'goto declaration' did not find a proper line")
Example #4
0
def driver():
    yield wait_tasks()
    b = GS.EditorBuffer.get(GS.File("main.adb"))
    GPS.execute_action("Expand alias under cursor")
    yield wait_idle()

    gps_assert(b.get_chars(), expected, "Autofix failed")
Example #5
0
def driver():
    # Create a new file with no name
    GPS.execute_action("new file")
    b = GPS.EditorBuffer.get()

    # Insert some ada code
    b.insert(b.at(1, 1), "package pack is\n")

    # Now save the file to its rightful name
    f = GPS.File("pack.ads")
    b.save(file=f)

    # Add some more Ada Code
    b.insert(b.at(2, 1), "   Foo : Integer := 42;\n")
    b.insert(b.at(3, 1), "   Bla : Integer := Foo;\n")
    b.insert(b.at(4, 1), "end pack;\n")

    # Do a "goto declaration" on Foo at line 3
    b.current_view().goto(b.at(3, 22))

    # wait LSP responses has been processed to have folding information
    if GPS.LanguageServer.is_enabled_for_language_name("Ada"):
        yield wait_tasks(other_than=known_tasks)

    GPS.execute_action("goto declaration")
    yield hook('language_server_response_processed')

    # Check that "Foo" is selected at line 2
    gps_assert(b.get_cursors()[0].location().line(), 2,
               "Wrong line selected after goto declaration")
    gps_assert(b.get_chars(b.selection_start(), b.selection_end()), "Foo ",
               "'Foo' wasn't selected after the call to goto declaration")