Skip to content

Commit 1d3c022

Browse files
committed
Fixes private variables seen in other scopes
Closes Private variable declaration in module seen in other scopes #3 Closes Private variable declaration in module seen in other scopes #191
1 parent f4ab433 commit 1d3c022

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
### Fixed
1515

1616
- Fixed some mutable default argument warnings in methods and classes
17+
- Fixed private variables showing in autocomplete
18+
([#191](https://github.com/hansec/fortran-language-server/issues/191))
19+
([gnikit/fortls#3](https://github.com/gnikit/fortls/issues/3))
1720

1821
## 2.0.0
1922

fortls/regex_patterns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
TATTR_LIST_REGEX = re.compile(
8080
r"[ ]*,[ ]*(PUBLIC|PRIVATE|ABSTRACT|EXTENDS\([a-z0-9_]*\))", re.I
8181
)
82-
VIS_REGEX = re.compile(r"[ ]*(PUBLIC|PRIVATE)[ :]", re.I)
82+
VIS_REGEX = re.compile(r"[ ]*\b(PUBLIC|PRIVATE)\b", re.I)
8383
WORD_REGEX = re.compile(r"[a-z_][a-z0-9_]*", re.I)
8484
NUMBER_REGEX = re.compile(
8585
r"[\+\-]?(\b\d+\.?\d*|\.\d+)(_\w+|d[\+\-]?\d+|e[\+\-]?\d+(_\w+)?)?(?![a-z_])",

test/test_server.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def check_return(result_array):
187187
["test_mod", 2, 0],
188188
["test_nonint_mod", 2, 0],
189189
["test_preproc_keywords", 2, 0],
190+
["test_private", 2, 8],
190191
["test_program", 2, 0],
191192
["test_rename_sub", 6, 9],
192193
["test_select", 2, 0],
@@ -279,6 +280,9 @@ def comp_request(file_path, line, char):
279280
string += comp_request(file_path, 8, 10)
280281
file_path = os.path.join(test_dir, "test_import.f90")
281282
string += comp_request(file_path, 15, 20)
283+
file_path = os.path.join(test_dir, "completion", "test_vis_mod_completion.f90")
284+
string += comp_request(file_path, 12, 16)
285+
string += comp_request(file_path, 12, 24)
282286
errcode, results = run_request(string)
283287
assert errcode == 0
284288
#
@@ -330,7 +334,11 @@ def comp_request(file_path, line, char):
330334
[3, "some_type", "TYPE"],
331335
# test_import.f90
332336
# TODO: this should be 1, mytype2 should not appear in autocomplete
337+
# see #5 and #8 on GitHub
333338
[2, "mytype", "TYPE"],
339+
# completion/test_vis_mod_completion.f90
340+
[1, "some_var", "INTEGER"],
341+
[3, "length", "INTEGER"],
334342
)
335343
assert len(exp_results) + 1 == len(results)
336344
for i in range(len(exp_results)):
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module foo
2+
implicit none
3+
public :: length
4+
private
5+
integer :: len
6+
integer :: length
7+
end module foo
8+
9+
program test_private
10+
use foo, only: length
11+
use test_vis_mod
12+
implicit none
13+
print*, some_var, length
14+
end program test_private

0 commit comments

Comments
 (0)