@@ -206,12 +206,12 @@ def serve_initialize(self, request):
206
206
datefmt = "%H:%M:%S" ,
207
207
level = logging .INFO ,
208
208
)
209
- self .__config_logger (request )
209
+ self ._config_logger (request )
210
210
init_debug_log = self ._load_config_file ()
211
211
if init_debug_log :
212
- self .__config_logger (request )
213
- self .__load_intrinsics ()
214
- self .__add_source_dirs ()
212
+ self ._config_logger (request )
213
+ self ._load_intrinsics ()
214
+ self ._add_source_dirs ()
215
215
216
216
# Initialize workspace
217
217
self .workspace_init ()
@@ -905,7 +905,7 @@ def get_all_references(self, def_obj, type_mem, file_obj=None):
905
905
ref_match = True
906
906
elif var_def .parent .get_type () == CLASS_TYPE_ID :
907
907
if type_mem :
908
- for inherit_def in var_def .parent .get_overriden (
908
+ for inherit_def in var_def .parent .get_overridden (
909
909
def_name
910
910
):
911
911
if def_fqsn == inherit_def .FQSN :
@@ -984,19 +984,7 @@ def serve_definition(self, request):
984
984
return None
985
985
# Construct link reference
986
986
if var_obj .file_ast .file is not None :
987
- var_file = var_obj .file_ast .file
988
- sline , schar , echar = var_file .find_word_in_code_line (
989
- var_obj .sline - 1 , var_obj .name
990
- )
991
- if schar < 0 :
992
- schar = echar = 0
993
- return {
994
- "uri" : path_to_uri (var_file .path ),
995
- "range" : {
996
- "start" : {"line" : sline , "character" : schar },
997
- "end" : {"line" : sline , "character" : echar },
998
- },
999
- }
987
+ return self ._create_ref_link (var_obj )
1000
988
return None
1001
989
1002
990
def serve_hover (self , request : dict ):
@@ -1052,7 +1040,7 @@ def create_signature_hover():
1052
1040
hover_array .append (create_hover (hover_str , highlight ))
1053
1041
elif self .variable_hover and (var_type == VAR_TYPE_ID ):
1054
1042
# Unless we have a Fortran literal include the desc in the hover msg
1055
- # See get_definition for an explanaiton about this default name
1043
+ # See get_definition for an explanation about this default name
1056
1044
if not var_obj .desc .startswith (FORTRAN_LITERAL ):
1057
1045
hover_str , highlight = var_obj .get_hover ()
1058
1046
hover_array .append (create_hover (hover_str , highlight ))
@@ -1095,19 +1083,7 @@ def serve_implementation(self, request):
1095
1083
if var_obj .parent .get_type () == CLASS_TYPE_ID :
1096
1084
impl_obj = var_obj .link_obj
1097
1085
if (impl_obj is not None ) and (impl_obj .file_ast .file is not None ):
1098
- impl_file = impl_obj .file_ast .file
1099
- sline , schar , echar = impl_file .find_word_in_code_line (
1100
- impl_obj .sline - 1 , impl_obj .name
1101
- )
1102
- if schar < 0 :
1103
- schar = echar = 0
1104
- return {
1105
- "uri" : path_to_uri (impl_file .path ),
1106
- "range" : {
1107
- "start" : {"line" : sline , "character" : schar },
1108
- "end" : {"line" : sline , "character" : echar },
1109
- },
1110
- }
1086
+ return self ._create_ref_link (impl_obj )
1111
1087
return None
1112
1088
1113
1089
def serve_rename (self , request ):
@@ -1379,7 +1355,7 @@ def update_workspace_file(
1379
1355
1380
1356
def workspace_init (self ):
1381
1357
1382
- file_list = self .__get_source_files ()
1358
+ file_list = self ._get_source_files ()
1383
1359
# Process files
1384
1360
pool = Pool (processes = self .nthreads )
1385
1361
results = {}
@@ -1440,13 +1416,13 @@ def _load_config_file(self) -> bool | None:
1440
1416
config_dict = json .load (jsonfile )
1441
1417
1442
1418
# Include and Exclude directories
1443
- self .__load_config_file_dirs (config_dict )
1419
+ self ._load_config_file_dirs (config_dict )
1444
1420
1445
1421
# General options
1446
- self .__load_config_file_general (config_dict )
1422
+ self ._load_config_file_general (config_dict )
1447
1423
1448
1424
# Preprocessor options
1449
- self .__load_config_file_preproc (config_dict )
1425
+ self ._load_config_file_preproc (config_dict )
1450
1426
1451
1427
# Debug options
1452
1428
debugging : bool = config_dict .get ("debug_log" , self .debug_log )
@@ -1467,7 +1443,7 @@ def _load_config_file(self) -> bool | None:
1467
1443
self .post_messages .append ([1 , msg ])
1468
1444
log .error (msg )
1469
1445
1470
- def __load_config_file_dirs (self , config_dict : dict ) -> None :
1446
+ def _load_config_file_dirs (self , config_dict : dict ) -> None :
1471
1447
# Exclude paths (directories & files)
1472
1448
# with glob resolution
1473
1449
for path in config_dict .get ("excl_paths" , []):
@@ -1492,7 +1468,7 @@ def __load_config_file_dirs(self, config_dict: dict) -> None:
1492
1468
self .FORTRAN_SRC_EXT_REGEX = src_file_exts (self .incl_suffixes )
1493
1469
self .excl_suffixes = set (config_dict .get ("excl_suffixes" , []))
1494
1470
1495
- def __load_config_file_general (self , config_dict : dict ) -> None :
1471
+ def _load_config_file_general (self , config_dict : dict ) -> None :
1496
1472
# General options ------------------------------------------------------
1497
1473
self .nthreads = config_dict .get ("nthreads" , self .nthreads )
1498
1474
self .notify_init = config_dict .get ("notify_init" , self .notify_init )
@@ -1541,7 +1517,7 @@ def __load_config_file_general(self, config_dict: dict) -> None:
1541
1517
"enable_code_actions" , self .enable_code_actions
1542
1518
)
1543
1519
1544
- def __load_config_file_preproc (self , config_dict : dict ) -> None :
1520
+ def _load_config_file_preproc (self , config_dict : dict ) -> None :
1545
1521
self .pp_suffixes = config_dict .get ("pp_suffixes" , None ) # TODO: set def
1546
1522
self .pp_defs = config_dict .get ("pp_defs" , {}) # TODO: set other dif?
1547
1523
if isinstance (self .pp_defs , list ):
@@ -1552,7 +1528,7 @@ def __load_config_file_preproc(self, config_dict: dict) -> None:
1552
1528
only_dirs (resolve_globs (path , self .root_path ), self .post_messages )
1553
1529
)
1554
1530
1555
- def __add_source_dirs (self ) -> None :
1531
+ def _add_source_dirs (self ) -> None :
1556
1532
"""Will recursively add all subdirectories that contain Fortran
1557
1533
source files only if the option `source_dirs` has not been specified
1558
1534
in the configuration file or no configuration file is present
@@ -1570,7 +1546,7 @@ def __add_source_dirs(self) -> None:
1570
1546
if root not in self .source_dirs and root not in self .excl_paths :
1571
1547
self .source_dirs .add (str (Path (root ).resolve ()))
1572
1548
1573
- def __get_source_files (self ) -> list [str ]:
1549
+ def _get_source_files (self ) -> list [str ]:
1574
1550
"""Get all the source files present in `self.source_dirs`,
1575
1551
exclude any files found in `self.excl_paths`^ and ignore
1576
1552
any files ending with `self.excl_suffixes`.
@@ -1603,7 +1579,7 @@ def __get_source_files(self) -> list[str]:
1603
1579
file_list .append (p )
1604
1580
return file_list
1605
1581
1606
- def __config_logger (self , request ) -> None :
1582
+ def _config_logger (self , request ) -> None :
1607
1583
"""Configures the logger to save Language Server requests/responses to a file
1608
1584
the logger will by default output to the main (stderr, stdout) channels.
1609
1585
"""
@@ -1619,7 +1595,7 @@ def __config_logger(self, request) -> None:
1619
1595
log .debug ("REQUEST %s %s" , request .get ("id" ), request .get ("method" ))
1620
1596
self .post_messages .append ([3 , "FORTLS debugging enabled" ])
1621
1597
1622
- def __load_intrinsics (self ) -> None :
1598
+ def _load_intrinsics (self ) -> None :
1623
1599
# Load intrinsics
1624
1600
set_keyword_ordering (True ) # Always sort intrinsics
1625
1601
if self .lowercase_intrinsics :
@@ -1635,6 +1611,20 @@ def __load_intrinsics(self) -> None:
1635
1611
# Set object settings
1636
1612
set_keyword_ordering (self .sort_keywords )
1637
1613
1614
+ def _create_ref_link (self , obj ):
1615
+ """Create a link reference to an object"""
1616
+ obj_file = obj .file_ast .file
1617
+ sline , schar , echar = obj_file .find_word_in_code_line (obj .sline - 1 , obj .name )
1618
+ if schar < 0 :
1619
+ schar = echar = 0
1620
+ return {
1621
+ "uri" : path_to_uri (obj_file .path ),
1622
+ "range" : {
1623
+ "start" : {"line" : sline , "character" : schar },
1624
+ "end" : {"line" : sline , "character" : echar },
1625
+ },
1626
+ }
1627
+
1638
1628
1639
1629
class JSONRPC2Error (Exception ):
1640
1630
def __init__ (self , code , message , data = None ):
0 commit comments