Skip to content

Commit

Permalink
Fixes GoTo Implementation for intrinsics
Browse files Browse the repository at this point in the history
Closes Request textDocument/implementation failed. #80
  • Loading branch information
gnikit committed Mar 25, 2022
1 parent 2d4609e commit c0ef77b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELONG

## 2.2.10

### Fixed

- Fixes GoTo Implementation error for intrinsics
([#80](https://github.com/gnikit/fortls/issues/80))

## 2.2.9

### Changed
Expand Down
3 changes: 3 additions & 0 deletions fortls/langserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,9 @@ def serve_implementation(self, request: dict):
var_obj = self.get_definition(file_obj, def_line, def_char)
if var_obj is None:
return None
# Intrinsics do not have implementations we can access
if isinstance(var_obj, fortran_intrinsic_obj):
return None
# Construct implementation reference
if var_obj.parent.get_type() == CLASS_TYPE_ID:
impl_obj = var_obj.link_obj
Expand Down
10 changes: 10 additions & 0 deletions test/test_server_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,13 @@ def test_implementation_type_bound():
errcode, results = run_request(string, ["-n", "1"])
assert errcode == 0
assert results[1] == create(test_dir / "subdir" / "test_free.f90", 49, 11, 28)


def test_implementation_intrinsics():
"""Go to implementation of implicit methods is handled gracefully"""
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")})
file_path = test_dir / "rename" / "test_rename_intrinsic.f90"
string += imp_request(file_path, 11, 18)
errcode, results = run_request(string, ["-n", "1"])
assert errcode == 0
assert results[1] is None

0 comments on commit c0ef77b

Please sign in to comment.