|
| 1 | +# from types import NoneType |
| 2 | +from setup_tests import ( |
| 3 | + path_to_uri, |
| 4 | + run_request, |
| 5 | + test_dir, |
| 6 | + write_rpc_request, |
| 7 | +) |
| 8 | +from fortls.json_templates import uri_json |
| 9 | + |
| 10 | + |
| 11 | +def imp_request(file, line, char): |
| 12 | + return write_rpc_request( |
| 13 | + 1, |
| 14 | + "textDocument/implementation", |
| 15 | + { |
| 16 | + "textDocument": {"uri": path_to_uri(str(file))}, |
| 17 | + "position": {"line": line, "character": char}, |
| 18 | + }, |
| 19 | + ) |
| 20 | + |
| 21 | + |
| 22 | +def check_imp_request(response: dict, references: dict): |
| 23 | + for uri, changes in response.items(): |
| 24 | + refs = references[uri] |
| 25 | + # Loop over all the changes in the current URI, instances of object |
| 26 | + for c, r in zip(changes, refs): |
| 27 | + assert c["range"] == r["range"] |
| 28 | + |
| 29 | + |
| 30 | +def create(file, line, schar, echar): |
| 31 | + return uri_json(path_to_uri(str(file)), line, schar, line, echar) |
| 32 | + |
| 33 | + |
| 34 | +def test_implementation_type_bound(): |
| 35 | + """Go to implementation of type-bound procedures""" |
| 36 | + string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir)}) |
| 37 | + file_path = test_dir / "test.f90" |
| 38 | + string += imp_request(file_path, 3, 17) |
| 39 | + errcode, results = run_request(string, ["-n", "1"]) |
| 40 | + assert errcode == 0 |
| 41 | + assert results[1] == create(test_dir / "subdir" / "test_free.f90", 49, 11, 28) |
0 commit comments