Skip to content

Commit

Permalink
Move process_file into fortran_file
Browse files Browse the repository at this point in the history
This method truly belongs inside the class.

TODO: investigate if pp variables need to be passed as args
The benefit of having the as args in the function level is that we can
update them from the server options i.e. config file
and pass them
  • Loading branch information
gnikit committed Feb 27, 2022
1 parent e97b812 commit 7ae210c
Show file tree
Hide file tree
Showing 3 changed files with 601 additions and 596 deletions.
15 changes: 2 additions & 13 deletions fortls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .interface import commandline_args
from .jsonrpc import JSONRPC2Connection, ReadWriter, path_from_uri
from .langserver import LangServer
from .parse_fortran import fortran_file, process_file
from .parse_fortran import fortran_file
from .version import __version__

__all__ = ["__version__"]
Expand Down Expand Up @@ -492,18 +492,7 @@ def debug_server_parser(args):
error_exit(f"Reading file failed: {err_str}")
print(f" Detected format: {'fixed' if file_obj.fixed else 'free'}")
print("\n=========\nParser Output\n=========\n")
_, file_ext = os.path.splitext(os.path.basename(args.debug_filepath))
preproc_file = False
if pp_suffixes is not None:
preproc_file = file_ext in pp_suffixes
else:
preproc_file = file_ext == file_ext.upper()
if preproc_file:
file_ast = process_file(
file_obj, debug=True, pp_defs=pp_defs, include_dirs=include_dirs
)
else:
file_ast = process_file(file_obj, debug=True)
file_ast = file_obj.parse(debug=True, pp_defs=pp_defs, include_dirs=include_dirs)
print("\n=========\nObject Tree\n=========\n")
for obj in file_ast.get_scopes():
print("{0}: {1}".format(obj.get_type(), obj.FQSN))
Expand Down
10 changes: 4 additions & 6 deletions fortls/langserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
fortran_var,
get_use_tree,
)
from fortls.parse_fortran import fortran_file, get_line_context, process_file
from fortls.parse_fortran import fortran_file, get_line_context
from fortls.regex_patterns import src_file_exts
from fortls.version import __version__

Expand Down Expand Up @@ -1312,8 +1312,8 @@ def update_workspace_file(
return False, err_string # Error during file read
if not file_changed:
return False, None
ast_new = process_file(
file_obj, pp_defs=self.pp_defs, include_dirs=self.include_dirs
ast_new = file_obj.parse(
pp_defs=self.pp_defs, include_dirs=self.include_dirs
)
# Add the included read in pp_defs from to the ones specified in the
# configuration file
Expand Down Expand Up @@ -1377,9 +1377,7 @@ def file_init(
# This is a bypass.
# For more see on SO: shorturl.at/hwAG1
set_keyword_ordering(sort)
file_ast = process_file(
file_obj, pp_defs=pp_defs, include_dirs=include_dirs
)
file_ast = file_obj.parse(pp_defs=pp_defs, include_dirs=include_dirs)
except:
log.error("Error while parsing file %s", filepath, exc_info=True)
return "Error during parsing"
Expand Down
Loading

0 comments on commit 7ae210c

Please sign in to comment.