hansec / fortran-language-server

Fortran Language Server for the Language Server Protocol
MIT License
295 stars 57 forks source link

Exception thrown at hover #151

Closed mystery-e204 closed 4 years ago

mystery-e204 commented 4 years ago

An exception is thrown if a source file only contains

A%B

and the mouse hovers over B. This example might seem ridiculous (and indeed it sort of is) but in combination with pre-processor directives in more complicated source files this actually turns out to be a problem.

Here is the error I'm getting from within vsCode:

[Error - 11:22:15 AM] Request textDocument/hover failed.
  Message: 'NoneType' object has no attribute 'get_children'
  Code: -32603 
[object Object]
error handling request {'jsonrpc': '2.0', 'id': 102, 'method': 'textDocument/hover', 'params': {'textDocument': {'uri': 'file:///.../test.f90'}, 'position': {'line': 0, 'character': 2}}}
Traceback (most recent call last):
  File "/.../lib/python3.7/site-packages/fortls/langserver.py", line 165, in handle
    resp = handler(request)
  File "/.../lib/python3.7/site-packages/fortls/langserver.py", line 970, in serve_hover
    var_obj = self.get_definition(file_obj, def_line, def_char)
  File "/.../lib/python3.7/site-packages/fortls/langserver.py", line 703, in get_definition
    type_scope = climb_type_tree(var_stack, curr_scope, self.obj_tree)
  File "/.../lib/python3.7/site-packages/fortls/objects.py", line 319, in climb_type_tree
    var_obj = find_in_scope(curr_scope, var_name, obj_tree)
  File "/.../lib/python3.7/site-packages/fortls/objects.py", line 172, in find_in_scope
    tmp_var = check_scope(scope, var_name_lower)
  File "/.../lib/python3.7/site-packages/fortls/objects.py", line 158, in check_scope
    for child in local_scope.get_children():
AttributeError: 'NoneType' object has no attribute 'get_children'