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 hook("language_server_response_processed") 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 hook("language_server_response_processed") 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")
def run_test(): buf = GPS.EditorBuffer.get(GPS.File('main.adb')) buf.current_view().goto(buf.at(5, 10)) GPS.execute_action('goto declaration') yield hook("language_server_response_processed") 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") GPS.execute_action('goto body') yield hook("language_server_response_processed") 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")
def run_test(): ls_pid = get_language_server_pid() gps_assert(ls_pid is not None, True, "couldn't get the language server PID") # Kill the language server os.kill(ls_pid, signal.SIGKILL) # Wait for the language server to relaunch yield hook("language_server_started") # Give the language server the time to process all the events # (init, didChangeConfiguration, didOpenFile, etc) # because otherwise the call to "lanugage_server_response_processed" # below will catch one of those. yield timeout(1000) # Get the new language server PID new_ls_pid = get_language_server_pid() gps_assert(new_ls_pid is not None, True, "couldn't get the new language server PID after kill") gps_assert(ls_pid != new_ls_pid, True, "the language server wasn't killed") # Verify the functionality of the new language server 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 hook("language_server_response_processed") current_buf = GPS.EditorBuffer.get() gps_assert(current_buf.file(), GPS.File('hello_world.ads'), "'goto declaration' did not open the right file") # Verify that there isn't the error message in the console gps_assert("had to be restarted more than" in GPS.Console().get_text(), False, "the error message about language server showed unexpectedly") # Now try to kill the language server too many times for j in range(5): ls_pid = get_language_server_pid() if ls_pid: os.kill(ls_pid, signal.SIGKILL) yield timeout(200) # Verify that there is the error message in the console gps_assert("had to be restarted more than" in GPS.Console().get_text(), True, "the error message about language server showed unexpectedly")
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")
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")
def run_test(): buf = GPS.EditorBuffer.get(GPS.File('main.adb')) yield wait_idle() GPS.execute_action("Build Main Number 1") yield hook("compilation_finished") yield wait_idle() gps_assert( GPS.dump_elaborations(), ['b (body):a (spec):pragma Elaborate_All', 'a (body):b (spec):withed'], "The elaboration Ccrcularities view has wrong content")
def driver(): yield wait_tasks() b = GPS.EditorBuffer.get(GPS.File("t.cpp")) # Wait until the semantic tree is available, then move the cursor yield hook('semantic_tree_updated') # Move the cursor line by line and verify that GPS doesn't freeze for line in range(20, 40): b.current_view().goto(b.at(line, 1)) yield timeout(500)
def driver(): prj_view = Project_View() yield prj_view.open_and_yield() explorer = prj_view.dialog explorer.expand_all() filt = get_widget_by_name("Project Explorer Filter") filt.set_text("be") yield hook("filter_view_changed") dump = dump_tree_model(explorer.get_model(), 1) gps_assert(dump, ['p', ['src1', ['beau.adb']]], "Project view content wrong after filtering") filt.set_text("") yield wait_tasks() dump = dump_tree_model(explorer.get_model(), 1) GPS.Console().write(str(dump)) gps_assert(dump, ['p', ['src1', ['beau.adb'], 'src2', ['nico.adb'], '.']], "Project view content wrong after removing the filter text")
def driver(): prj_view = Project_View() yield prj_view.open_and_yield() explorer = prj_view.dialog dump = dump_tree_model(explorer.get_model(), 1) gps_assert(dump, ['p', ['.', ['beau.adb', 'nico.adb'], '.']], "Initial project view contents wrong") filt = get_widget_by_name("Project Explorer Filter") filt.set_text("be") yield hook("filter_view_changed") dump = dump_tree_model(explorer.get_model(), 1) gps_assert(dump, ['p', ['.', ['beau.adb'], '.']], "Project view content wrong after filtering") GPS.execute_action("reload project") yield wait_tasks() dump = dump_tree_model(explorer.get_model(), 1) gps_assert(dump, ['p', ['.', ['beau.adb'], '.']], "Project view not filtered properly after reload")
def driver(): # This is an UTF-8 test GPS.Preference("General-Charset").set("UTF-8") main = GPS.EditorBuffer.get(GPS.File("main.adb")) # # Goodmorning # GPS.Console().clear() main.current_view().goto(main.at(4, 4)) GPS.execute_action("find all references") yield hook("language_server_response_processed") yield wait_tasks() # Verify the references m = [ to_str(m) for m in GPS.Message.list("References for Goodmorning (main.adb:4)") ] m.sort() gps_assert(m, ["main.adb:4:4", "p.ads:2:37"], "references for goodmorning are off") gps_assert(GPS.Console().get_text(), "", "the console should be empty") # # доброеутро # GPS.Console().clear() main.current_view().goto(main.at(5, 4)) GPS.execute_action("find all references") yield hook("language_server_response_processed") yield wait_tasks() # Verify the references m = [ to_str(m) for m in GPS.Message.list(u"References for доброеутро (main.adb:5)") ] m.sort() gps_assert(m, ['main.adb:5:4', 'main.adb:6:4', 'p.ads:2:14'], u"references for доброеутро are off") gps_assert(GPS.Console().get_text(), "", "the console should be empty") # # доброеутро*56 # GPS.Console().clear() main.current_view().goto(main.at(7, 4)) GPS.execute_action("find all references") yield hook("language_server_response_processed") yield wait_tasks() # Verify the references m = [ to_str(m) for m in GPS.Message.list("References for " + u"доброеутро" * 56 + " (main.adb:7)") ] m.sort() gps_assert(m, ['main.adb:7:4', 'p.ads:3:14'], u"references for the long identifier are off") gps_assert(GPS.Console().get_text(), "", "the console should be empty")