Skip to content

Commit

Permalink
Merge pull request #239 from fortran-lang/gnikit/issue150
Browse files Browse the repository at this point in the history
fix: completion of USE ONLY interaces
  • Loading branch information
gnikit authored Nov 18, 2022
2 parents f98d79c + ef05393 commit d658fb4
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

### Fixed

- Fixed bug where completion of interfaces in USE ONLY would produce the snippet
([#150](https://github.com/fortran-lang/fortls/issues/150))
- Fixed bug where diagnostic messages were raised for non-existent variables
([#173](https://github.com/fortran-lang/fortls/issues/173))
([#175](https://github.com/fortran-lang/fortls/issues/175))
Expand Down
2 changes: 1 addition & 1 deletion fortls/langserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def build_comp(
continue
#
name_replace = rename_list[i]
if candidate_type == INTERFACE_TYPE_ID:
if candidate_type == INTERFACE_TYPE_ID and not line_context == "mod_mems":
tmp_list = []
if name_replace is None:
name_replace = candidate.name
Expand Down
17 changes: 17 additions & 0 deletions test/test_server_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,20 @@ def test_comp_documentation():
]
assert len(exp_results) == len(results[1])
assert exp_results == results[1]


def test_comp_use_only_interface():
"""Test completion of interfaces when using USE ONLY give the right signature."""
string = write_rpc_request(
1, "initialize", {"rootPath": str(test_dir / "completion")}
)
file_path = test_dir / "completion" / "use_only_interface.f90"
string += comp_request(file_path, 21, 29)
errcode, results = run_request(
string,
)
assert errcode == 0
exp_results = [[1, "some_sub", "INTERFACE"]]
assert len(exp_results) == len(results) - 1
for i, ref in enumerate(exp_results):
validate_comp(results[i + 1], ref)
24 changes: 24 additions & 0 deletions test/test_source/completion/use_only_interface.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module some_mod
implicit none
private
public :: some_sub
interface some_sub
module procedure a_subroutine
module procedure b_subroutine
end interface
contains
subroutine a_subroutine(x)
integer, intent(in) :: x
write(*,*) 'x = ', x
end subroutine a_subroutine
subroutine b_subroutine(x, y)
integer, intent(in) :: x, y
write(*,*) 'x = ', x
write(*,*) 'y = ', y
end subroutine b_subroutine
end module some_mod

program main
use some_mod, only: some_sub
implicit none
end program main

0 comments on commit d658fb4

Please sign in to comment.