Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes GoTo Implementation for intrinsics #84

Merged
merged 2 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
40 changes: 40 additions & 0 deletions test/test_server_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,43 @@ 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


def test_implementation_integer():
"""Go to implementation when no implementation is present 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, 20, 31)
errcode, results = run_request(string, ["-n", "1"])
assert errcode == 0
assert results[1] is None


def test_implementation_empty():
"""Go to implementation for empty lines 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, 13, 0)
errcode, results = run_request(string, ["-n", "1"])
assert errcode == 0
assert results[1] is None


def test_implementation_no_file():
"""Go to implementation for empty lines is handled gracefully"""
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")})
file_path = test_dir / "rename" / "fake.f90"
string += imp_request(file_path, 13, 0)
errcode, results = run_request(string, ["-n", "1"])
assert errcode == 0
assert results[1] is None