fortran-lang / fortls

fortls - Fortran Language Server
https://fortls.fortran-lang.org/
MIT License
258 stars 41 forks source link

line continuation at beginning of the line trips the tooltip information #365

Closed smoothdeveloper closed 6 months ago

smoothdeveloper commented 8 months ago
integer(8) function foo(i,j
& ,k)
    foo = i+j+k
end function

At call sites, this function tooltip will incorrectly show no arguments.

If the continuation character is put at the end of the line, it works properly.

I'm dealing with a sizeable codebase where the continuation character is always put at the beginning of the next line.

Environment:

Related: #235, #85

smoothdeveloper commented 7 months ago

It seems code in .f90 files don't require the "&", so this is minor issue (we should 100% encourage migrating to modern fortran format).

It would be great if the language server had newcomer suggestions, that would be displayed first time a condition about legacy code or non recommended things occurs in the code, and the user could disable the notification forever.

I don't know if this fits more the LSP or the individual editor extensions.

gnikit commented 6 months ago

I am not sure the posted code is legal Fortran. Free Form Fortran, which is what I am assuming this is from the usage of .f90, requires & as the last non whitespace character to mark the next line as a continuation. The hover request displays correctly, where the i and j arguments are omitted from the explicit declaration since you use implicit typing.

image

I will be closing this Issue for now. If to reopen can you post a complete MWE and how you compile it, and the debug command from a terminal with its output vs the expected output.

The latter should look something like this:

fortls --debug_filepath line_continuations_p2.f90 --debug_rootpath . --debug_hover --debug_line 1 --debug_char 23
Testing "initialize" request:
  Root = "."
[INFO - 20:26:19] fortls - Fortran Language Server 3.0.0rc7.dev1+g8b511d5 Initialized
================================================================================
  Successful!

  Source directories:
    /home/gn/Code/Python/fortls/test/test_source/parse
================================================================================

Testing "textDocument/hover" request:
  File = "line_continuations_p2.f90"
  Line = 1
  Char = 23

================================================================================
```fortran90
FUNCTION foo(val) RESULT(r)
 REAL(8), INTENT(IN) :: val
 REAL*8 :: r

================================================================================