Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: UriError on wind variable rename #1087

Open
2 tasks done
EricStimpsonWSU opened this issue May 11, 2024 · 6 comments
Open
2 tasks done

bug: UriError on wind variable rename #1087

EricStimpsonWSU opened this issue May 11, 2024 · 6 comments
Labels

Comments

@EricStimpsonWSU
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

I have tried the Pre-Release of the extension.

  • I have replicated the Issue in the latest Pre-Release

Description

I am trying to rename a variable in an F03 source file using the F2 key. When I enter the new variable name, I get an error '[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")'. I've tried several different variables in the same file, as well as a minimal file. The behavior is the same everywhere.

Screenshots

Screenshot 2024-05-11 185735
Screenshot 2024-05-11 185654

Expected Behaviour

Should rename the variable in all places

Version of Modern Fortran

v3.4.2024051001 (pre-release)

Version of Visual Studio Code

v1.89.1

Platform and Architecture

Windows

Additional Information

I had to manually set the path to fortls in my settings file, which looks like this:
"fortran.fortls.path": "c:/Users/xxx/miniconda3/envs/general/scripts/fortls"

The version of fortls is v3.0.0 and python is 3.11.7. I also checked the fortls github to see if there were UriErrors reported there

@gnikit
Copy link
Member

gnikit commented May 11, 2024

Can you try and get the same error with the fortls command line interface. It should be something like this.
What is the output of the command.

fortls --debug_filepath your_file.f90 --debug_rootpath ./project_root_dir --debug_rename newName --debug_line X --debug_char Y

Where debug_line and debug_char are the line and column numbers (any column number that is within your variable name will do) of the variable.

@gnikit
Copy link
Member

gnikit commented May 11, 2024

Also turn on the Debug logging and post the complete output of the Modern Fortran OUTPUT channel (with the error).

@EricStimpsonWSU
Copy link
Author

Can you try and get the same error with the fortls command line interface. It should be something like this. What is the output of the command.

fortls --debug_filepath your_file.f90 --debug_rootpath ./project_root_dir --debug_rename newName --debug_line X --debug_char Y

Where debug_line and debug_char are the line and column numbers (any column number that is within your variable name will do) of the variable.

The command line didn't report any errors and the output showed the lines affected with the appropriate changes.

Here is the output:

Testing "initialize" request:
  Root = "./"
[INFO - 11:07:24] fortls - Fortran Language Server 3.0.0 Initialized
================================================================================
  Successful!

  Source directories:
    \\wsl.localhost\Ubuntu\home\estimpson\wsu\FFTW-test\tutorial_src
================================================================================

Testing "textDocument/rename" request:
  File = "block.f90"
  Line = 9
  Char = 13

================================================================================
File: "\\wsl.localhost\Ubuntu\home\estimpson\wsu\FFTW-test\tutorial_src\block.f90"
  9, 9
  -     real :: x
  +     real :: xx

  15, 15
  -         x = y ** n
  +         xx = y ** n

  22, 22
  -     print *, x
  +     print *, xx

File: "\\wsl.localhost\Ubuntu\home\estimpson\wsu\FFTW-test\tutorial_src\block.f90"
  9, 9
  -     real :: x
  +     real :: xx

  15, 15
  -         x = y ** n
  +         xx = y ** n

  22, 22
  -     print *, x
  +     print *, xx

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

@EricStimpsonWSU
Copy link
Author

Also turn on the Debug logging and post the complete output of the Modern Fortran OUTPUT channel (with the error).

The following is the output from Modern Fortran. No additional output is generated when I try to rename a variable, however:

[INFO - 11:02:47 AM] Extension Name: Modern Fortran
[INFO - 11:02:47 AM] Extension Version: 3.4.0
[INFO - 11:02:47 AM] Linter set to: "gfortran"
[INFO - 11:02:47 AM] Formatter set to: "findent"
[INFO - 11:02:47 AM] Autocomplete set to: "fortls"
[INFO - 11:02:47 AM] Hover set to: "fortls"
[INFO - 11:02:47 AM] Symbols set to: "fortls"
[ERROR - 11:02:48 AM] [lint] Could not spawn gfortran to check version.
[INFO - 11:02:50 AM] [lsp.client] Initialising Language Server for workspace: file:///u%3A/home/estimpson/wsu/FFTW-test
[INFO - 11:02:50 AM] [lsp.client] Language Server arguments: --enable_code_actions --hover_signature --use_signature_help --lowercase_intrinsics --nthreads=4 --incremental_sync
[INFO - 11:02:53] fortls - Fortran Language Server 3.0.0 Initialized

I don't [currently] have gfortran installed locally in windows, as I am accessing the compiler only from WSL. However, if the extension wants a local install of gfortran, I can try that.

@gnikit
Copy link
Member

gnikit commented May 13, 2024

fortls seems to be working okay. To be sure, using the the following VS Code settings, replicate in VS Code the behaviour that caused the error to be thrown and then post the complete output of the Modern Fortran. From the output you posted above I things seem to be working as expected.

Settings

  "fortran.logging.level": "Debug",
  "fortran.fortls.extraArgs": [
    "--debug_log"
  ],

@EricStimpsonWSU
Copy link
Author

fortls seems to be working okay. To be sure, using the the following VS Code settings, replicate in VS Code the behaviour that caused the error to be thrown and then post the complete output of the Modern Fortran. From the output you posted above I things seem to be working as expected.

Settings

  "fortran.logging.level": "Debug",
  "fortran.fortls.extraArgs": [
    "--debug_log"
  ],
[INFO - 10:11:39 AM] Extension Name: Modern Fortran
[INFO - 10:11:39 AM] Extension Version: 3.4.0
[INFO - 10:11:39 AM] Linter set to: "gfortran"
[INFO - 10:11:39 AM] Formatter set to: "findent"
[INFO - 10:11:39 AM] Autocomplete set to: "fortls"
[INFO - 10:11:39 AM] Hover set to: "fortls"
[INFO - 10:11:39 AM] Symbols set to: "fortls"
[ERROR - 10:11:39 AM] [lint] Could not spawn gfortran to check version.
[DEBUG - 10:11:39 AM] [lsp.client] Fortran Language Server -- constructor
[DEBUG - 10:11:40 AM] [lsp.client] Language Server arguments:
[
  "--enable_code_actions",
  "--hover_signature",
  "--use_signature_help",
  "--lowercase_intrinsics",
  "--nthreads=4",
  "--incremental_sync",
  "--debug_log"
]
[DEBUG - 10:11:40 AM] [lsp.client] Language Server version: 3.0.0
[INFO - 10:11:40 AM] [lsp.client] Initialising Language Server for workspace: file:///u%3A/home/estimpson/wsu/FFTW-test
[INFO - 10:11:40 AM] [lsp.client] Language Server arguments: --enable_code_actions --hover_signature --use_signature_help --lowercase_intrinsics --nthreads=4 --incremental_sync --debug_log
REQUEST 0 initialize
fortls - Fortran Language Server 3.0.0 Initialized
SEND {
  "jsonrpc":"2.0",
  "id":0,
  "result":{
    "capabilities":{
      "completionProvider":{
        "resolveProvider":false,
        "triggerCharacters":[
          "%"
        ]
      },
      "definitionProvider":true,
      "documentSymbolProvider":true,
      "referencesProvider":true,
      "hoverProvider":true,
      "implementationProvider":true,
      "renameProvider":true,
      "workspaceSymbolProvider":true,
      "textDocumentSync":2,
      "signatureHelpProvider":{
        "triggerCharacters":[
          "(",
          ","
        ]
      },
      "codeActionProvider":true
    }
  }
}
SEND {
  "jsonrpc":"2.0",
  "method":"window/showMessage",
  "params":{
    "type":3,
    "message":"fortls debugging enabled"
  }
}
fortls debugging enabled
RECV {
  "jsonrpc":"2.0",
  "method":"initialized",
  "params":{}
}
REQUEST None initialized
RECV {
  "jsonrpc":"2.0",
  "method":"textDocument/didOpen",
  "params":{
    "textDocument":{
      "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90",
      "languageId":"FortranFreeForm",
      "version":1,
      "text":"module whats_a_module\r\n    implicit none\r\n    integer :: n = 2\r\nend module\r\n\r\nprogram main\r\n    implicit none\r\n    \r\n    real :: x\r\n\r\n    block\r\n        use whats_a_module, only: n ! you can import modules within blocks\r\n        real :: y ! locally scoped variable\r\n        y = 2.0\r\n        x = y ** n\r\n\r\n        print *, y\r\n\r\n    end block\r\n    ! print *, y ! this will not work because y is not in scope\r\n    ! print *, n ! this will not work because n is not in scope\r\n    print *, x\r\nend program"
    }
  }
}
REQUEST None textDocument/didOpen
SEND {
  "jsonrpc":"2.0",
  "method":"textDocument/publishDiagnostics",
  "params":{
    "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90",
    "diagnostics":[]
  }
}
RECV {
  "jsonrpc":"2.0",
  "method":"workspace/didChangeConfiguration",
  "params":{
    "settings":{
      "fortran":{
        "provide":{
          "autocomplete":"fortls",
          "hover":"fortls",
          "symbols":"fortls"
        },
        "preferredCase":"lowercase",
        "logging":{
          "level":"Debug"
        },
        "linter":{
          "compiler":"gfortran",
          "initialize":false,
          "compilerPath":"",
          "includePaths":[
            "/usr/include/**",
            "${workspaceFolder}/include/**"
          ],
          "extraArgs":[],
          "modOutput":"",
          "fypp":{
            "enabled":false,
            "path":"fypp",
            "definitions":{},
            "includes":[],
            "lineNumberingMode":"full",
            "lineMarkerFormat":"cpp",
            "extraArgs":[]
          }
        },
        "formatting":{
          "formatter":"findent",
          "findentArgs":[],
          "fprettifyArgs":[],
          "path":""
        },
        "fortls":{
          "path":"c:/Users/estim/miniconda3/envs/general/scripts/fortls",
          "configure":"",
          "notifyInit":false,
          "incrementalSync":true,
          "nthreads":4,
          "sortKeywords":false,
          "symbolTypes":true,
          "suffixes":[],
          "directories":[],
          "excludeSuffixes":[],
          "excludeDirectories":[],
          "preprocessor":{
            "suffixes":[],
            "directories":[],
            "definitions":{}
          },
          "disableDiagnostics":false,
          "maxLineLength":-1,
          "maxCommentLineLength":-1,
          "extraArgs":[
            "--debug_log"
          ],
          "disableAutoupdate":false,
          "disabled":false,
          "preserveKeywordOrder":null
        },
        "notifications":{
          "releaseNotes":true
        },
        "experimental":{
          "keepInitDiagnostics":true
        },
        "includePaths":null,
        "gfortranExecutable":null,
        "linterEnabled":null,
        "linterExtraArgs":null,
        "linterModOutput":null,
        "provideSymbols":null,
        "symbols":null,
        "provideHover":null,
        "provideCompletion":null
      }
    }
  }
}
REQUEST None workspace/didChangeConfiguration
RECV {
  "jsonrpc":"2.0",
  "id":1,
  "method":"textDocument/documentSymbol",
  "params":{
    "textDocument":{
      "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90"
    }
  }
}
REQUEST 1 textDocument/documentSymbol
SEND {
  "jsonrpc":"2.0",
  "id":1,
  "result":[
    {
      "name":"whats_a_module",
      "kind":2,
      "location":{
        "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90",
        "range":{
          "start":{
            "line":0,
            "character":0
          },
          "end":{
            "line":3,
            "character":0
          }
        }
      }
    },
    {
      "name":"main",
      "kind":2,
      "location":{
        "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90",
        "range":{
          "start":{
            "line":5,
            "character":0
          },
          "end":{
            "line":22,
            "character":0
          }
        }
      }
    }
  ]
}
RECV {
  "jsonrpc":"2.0",
  "id":2,
  "method":"textDocument/codeAction",
  "params":{
    "textDocument":{
      "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90"
    },
    "range":{
      "start":{
        "line":8,
        "character":13
      },
      "end":{
        "line":8,
        "character":13
      }
    },
    "context":{
      "diagnostics":[],
      "triggerKind":2
    }
  }
}
REQUEST 2 textDocument/codeAction
SEND {
  "jsonrpc":"2.0",
  "id":2,
  "result":null
}
RECV {
  "jsonrpc":"2.0",
  "method":"$/cancelRequest",
  "params":{
    "id":2
  }
}
REQUEST None $/cancelRequest
RECV {
  "jsonrpc":"2.0",
  "id":3,
  "method":"textDocument/codeAction",
  "params":{
    "textDocument":{
      "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90"
    },
    "range":{
      "start":{
        "line":8,
        "character":13
      },
      "end":{
        "line":8,
        "character":13
      }
    },
    "context":{
      "diagnostics":[],
      "triggerKind":2
    }
  }
}
REQUEST 3 textDocument/codeAction
SEND {
  "jsonrpc":"2.0",
  "id":3,
  "result":null
}
RECV {
  "jsonrpc":"2.0",
  "id":4,
  "method":"textDocument/codeAction",
  "params":{
    "textDocument":{
      "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90"
    },
    "range":{
      "start":{
        "line":8,
        "character":13
      },
      "end":{
        "line":8,
        "character":13
      }
    },
    "context":{
      "diagnostics":[],
      "triggerKind":2
    }
  }
}
REQUEST 4 textDocument/codeAction
SEND {
  "jsonrpc":"2.0",
  "id":4,
  "result":null
}
RECV {
  "jsonrpc":"2.0",
  "method":"$/cancelRequest",
  "params":{
    "id":4
  }
}
REQUEST None $/cancelRequest
RECV {
  "jsonrpc":"2.0",
  "id":5,
  "method":"textDocument/codeAction",
  "params":{
    "textDocument":{
      "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90"
    },
    "range":{
      "start":{
        "line":8,
        "character":13
      },
      "end":{
        "line":8,
        "character":13
      }
    },
    "context":{
      "diagnostics":[],
      "triggerKind":2
    }
  }
}
REQUEST 5 textDocument/codeAction
SEND {
  "jsonrpc":"2.0",
  "id":5,
  "result":null
}
RECV {
  "jsonrpc":"2.0",
  "method":"$/cancelRequest",
  "params":{
    "id":5
  }
}
REQUEST None $/cancelRequest
RECV {
  "jsonrpc":"2.0",
  "id":6,
  "method":"textDocument/codeAction",
  "params":{
    "textDocument":{
      "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90"
    },
    "range":{
      "start":{
        "line":8,
        "character":13
      },
      "end":{
        "line":8,
        "character":13
      }
    },
    "context":{
      "diagnostics":[],
      "triggerKind":2
    }
  }
}
REQUEST 6 textDocument/codeAction
SEND {
  "jsonrpc":"2.0",
  "id":6,
  "result":null
}
RECV {
  "jsonrpc":"2.0",
  "id":7,
  "method":"textDocument/documentSymbol",
  "params":{
    "textDocument":{
      "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90"
    }
  }
}
REQUEST 7 textDocument/documentSymbol
SEND {
  "jsonrpc":"2.0",
  "id":7,
  "result":[
    {
      "name":"whats_a_module",
      "kind":2,
      "location":{
        "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90",
        "range":{
          "start":{
            "line":0,
            "character":0
          },
          "end":{
            "line":3,
            "character":0
          }
        }
      }
    },
    {
      "name":"main",
      "kind":2,
      "location":{
        "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90",
        "range":{
          "start":{
            "line":5,
            "character":0
          },
          "end":{
            "line":22,
            "character":0
          }
        }
      }
    }
  ]
}
RECV {
  "jsonrpc":"2.0",
  "id":8,
  "method":"textDocument/hover",
  "params":{
    "textDocument":{
      "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90"
    },
    "position":{
      "line":8,
      "character":13
    }
  }
}
REQUEST 8 textDocument/hover
SEND {
  "jsonrpc":"2.0",
  "id":8,
  "result":{
    "contents":{
      "kind":"markdown",
      "value":"```fortran90\nREAL :: x\n```"
    }
  }
}
RECV {
  "jsonrpc":"2.0",
  "id":9,
  "method":"textDocument/rename",
  "params":{
    "textDocument":{
      "uri":"file:///u%3A/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90"
    },
    "position":{
      "line":8,
      "character":13
    },
    "newName":"xxx"
  }
}
REQUEST 9 textDocument/rename
SEND {
  "jsonrpc":"2.0",
  "id":9,
  "result":{
    "changes":{
      "file://///wsl.localhost/Ubuntu/home/estimpson/wsu/FFTW-test/tutorial_src/block.f90":[
        {
          "range":{
            "start":{
              "line":8,
              "character":12
            },
            "end":{
              "line":8,
              "character":13
            }
          },
          "newText":"xxx"
        },
        {
          "range":{
            "start":{
              "line":14,
              "character":8
            },
            "end":{
              "line":14,
              "character":9
            }
          },
          "newText":"xxx"
        },
        {
          "range":{
            "start":{
              "line":21,
              "character":13
            },
            "end":{
              "line":21,
              "character":14
            }
          },
          "newText":"xxx"
        }
      ]
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants