Skip to content
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
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 submodule crashing bug and document/Symbol request failure
([#233](https://github.com/fortran-lang/fortls/issues/233))
- Fixed debug interface parser not loading all configuration files
([#221](https://github.com/fortran-lang/fortls/issues/221))
- Fixed name mangling of type-bound procedure pointers while hovering
Expand Down
7 changes: 6 additions & 1 deletion fortls/langserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,12 @@ def map_types(type, in_class: bool = False):
# Add scopes to outline view
test_output = []
for scope in file_obj.ast.get_scopes():
if (scope.name[0] == "#") or (scope.get_type() == SELECT_TYPE_ID):

if (
not scope.name # Skip empty strings
or scope.name.startswith("#") # Skip comments
or scope.get_type() == SELECT_TYPE_ID # Skip select types
):
continue
scope_tree = scope.FQSN.split("::")
if len(scope_tree) > 2:
Expand Down
4 changes: 2 additions & 2 deletions fortls/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def __init__(
file_ast: FortranAST,
line_number: int,
name: str,
ancestor_name: str = None,
ancestor_name: str = "",
):
super().__init__(file_ast, line_number, name)
self.ancestor_name = ancestor_name
Expand All @@ -766,7 +766,7 @@ def get_ancestors(self):
return []

def resolve_inherit(self, obj_tree, inherit_version):
if self.ancestor_name is None:
if not self.ancestor_name:
return
if self.ancestor_name in obj_tree:
self.ancestor_obj = obj_tree[self.ancestor_name][0]
Expand Down
4 changes: 2 additions & 2 deletions fortls/parse_fortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,8 @@ def read_submod_def(line: str):
if submod_match is None:
return None

parent_name: str = None
name: str = None
parent_name: str = ""
name: str = ""
trailing_line = line[submod_match.end(0) :].split("!")[0]
trailing_line = trailing_line.strip()
parent_match = FRegex.WORD.match(trailing_line)
Expand Down
17 changes: 17 additions & 0 deletions test/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,20 @@ def test_line_continuations():
except Exception as e:
print(e)
assert False


def test_submodule():
file_path = test_dir / "parse" / "submodule.f90"
file = FortranFile(str(file_path))
err_str, _ = file.load_from_disk()
assert err_str is None
try:
ast = file.parse()
assert True
assert ast.scope_list[0].name == "val"
assert ast.scope_list[0].ancestor_name == "p1"
assert ast.scope_list[1].name == ""
assert ast.scope_list[1].ancestor_name == "p2"
except Exception as e:
print(e)
assert False
4 changes: 4 additions & 0 deletions test/test_source/parse/submodule.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
submodule (p1) val
end

submodule (p2)