hansec / fortran-language-server

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

Fortran literal constants hover support #188

Closed gnikit closed 2 years ago

gnikit commented 3 years ago

When you call a function/subroutine and pass a number as an input argument fortls does not display the type that is supposed to be matching on the said function/subroutine, which at time can be confusing.

Therefore, hovering over 1 in call test(start, 1, finish) will generate no hover message, in this specific case it should be integer, intent(in) :: something and will also produce the following log in fortls

DEBUG:fortls.langserver:REQUEST 52 textDocument/hover
DEBUG:fortls.jsonrpc:SEND {"jsonrpc":"2.0","id":52,"result":null}
gnikit commented 2 years ago

So the origin of this is from expand_name and more specifically the WORD_REGEX that requires a a-z character to return a match. I believe the right solution in this case would be to retry with a NUMBER_REGEX after the WORD_REGEX and then return.

gnikit commented 2 years ago

Update, this is substantially harder than what I originally thought mostly because after having implemented the regex to return the number variable we still need to retrieve it's caller's object which is done through LangServer>get_definition>find_in_scope The problem is that technically speaking, a number e.g. 10000 is not an implicit variable so it cannot be detected in the scope and hence find_in_scope will return None, instead we would want it to return the scope of its child.

gnikit commented 2 years ago

This has been fixed in fortls