Skip to content

Commit 008e47c

Browse files
authored
Merge pull request #84 from gnikit/bug/got--imp-intrinsic
Fixes GoTo Implementation for intrinsics
2 parents 2d4609e + 3fed18c commit 008e47c

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELONG
22

3+
## 2.2.10
4+
5+
### Fixed
6+
7+
- Fixes GoTo Implementation error for intrinsics
8+
([#80](https://github.com/gnikit/fortls/issues/80))
9+
310
## 2.2.9
411

512
### Changed

fortls/langserver.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,9 @@ def serve_implementation(self, request: dict):
11221122
var_obj = self.get_definition(file_obj, def_line, def_char)
11231123
if var_obj is None:
11241124
return None
1125+
# Intrinsics do not have implementations we can access
1126+
if isinstance(var_obj, fortran_intrinsic_obj):
1127+
return None
11251128
# Construct implementation reference
11261129
if var_obj.parent.get_type() == CLASS_TYPE_ID:
11271130
impl_obj = var_obj.link_obj

test/test_server_implementation.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,43 @@ def test_implementation_type_bound():
3535
errcode, results = run_request(string, ["-n", "1"])
3636
assert errcode == 0
3737
assert results[1] == create(test_dir / "subdir" / "test_free.f90", 49, 11, 28)
38+
39+
40+
def test_implementation_intrinsics():
41+
"""Go to implementation of implicit methods is handled gracefully"""
42+
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")})
43+
file_path = test_dir / "rename" / "test_rename_intrinsic.f90"
44+
string += imp_request(file_path, 11, 18)
45+
errcode, results = run_request(string, ["-n", "1"])
46+
assert errcode == 0
47+
assert results[1] is None
48+
49+
50+
def test_implementation_integer():
51+
"""Go to implementation when no implementation is present is handled gracefully"""
52+
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")})
53+
file_path = test_dir / "rename" / "test_rename_intrinsic.f90"
54+
string += imp_request(file_path, 20, 31)
55+
errcode, results = run_request(string, ["-n", "1"])
56+
assert errcode == 0
57+
assert results[1] is None
58+
59+
60+
def test_implementation_empty():
61+
"""Go to implementation for empty lines is handled gracefully"""
62+
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")})
63+
file_path = test_dir / "rename" / "test_rename_intrinsic.f90"
64+
string += imp_request(file_path, 13, 0)
65+
errcode, results = run_request(string, ["-n", "1"])
66+
assert errcode == 0
67+
assert results[1] is None
68+
69+
70+
def test_implementation_no_file():
71+
"""Go to implementation for empty lines is handled gracefully"""
72+
string = write_rpc_request(1, "initialize", {"rootPath": str(test_dir / "rename")})
73+
file_path = test_dir / "rename" / "fake.f90"
74+
string += imp_request(file_path, 13, 0)
75+
errcode, results = run_request(string, ["-n", "1"])
76+
assert errcode == 0
77+
assert results[1] is None

0 commit comments

Comments
 (0)