joelday / papyrus-lang

📜Advanced language tools for the Papyrus scripting language.
Other
105 stars 17 forks source link

Refactoring with "Rename Symbol" doesnt work as intended with script names. #74

Open Scrivener07 opened 5 years ago

Scrivener07 commented 5 years ago

Describe the bug Refactoring of scripts with "Rename Symbol" does not work as intended with script names. The symbol usage is renamed across files but but the script name identifier must match the script file name.

If I recall correctly, in Visual Studio with CSharp, the "Rename Symbol" also behaves this way, leaving the *.cs file name unchanged.

However, in Visual Studio if you rename the *.cs within the project explorer, it will rename the file and prompt if you would also like to run "Rename Symbol" on the class name. What do you think about matching this behavior both ways in the extension?

In CSharp it does not matter is the class name matches the file name but in Papyrus this will cause a compiler error. It does not seem well to leave code in a broken state resulting from a refactoring command.

Rename in VS Code Explorer
  1. Begin editing a script file name within the VS Code Explorer and commit the changes.
  2. A VS Code prompt appears asking, "would you also like to rename the script name?". Yes. Rename the script name too. No. Only the file name is changed, causing compiler errors.
"Rename Symbol"
  1. Run the "Rename Symbol" command on script name and commit the changes.
  2. A VS Code prompt appears asking, "would you also like to rename the script file?".

Additional Prompts

This applies to refactoring in general. Refactoring a symbol which reaches beyond the current file may do well with some additional checks.

For example is a user tries to rename an inherited function or event originating from a Base import or other library such as F4SE.

In cases where a refactored symbol's usage originates outside of the current user source folder, then prompt the user with.

The symbol "X" belongs to the import "Y". Are you Sure?

Or something like that to think about.

Scrivener07 commented 5 years ago

I broke "Additional Prompts" off into its own issue #75.

minkir014 commented 5 years ago

Is this a feature plan to add this good feature or it's a feature announcement?? I mean Is that already available in your extension or it's a feature plan??

Scrivener07 commented 5 years ago

Is this a feature plan to add this good feature or it's a feature announcement?? I mean Is that already available in your extension or it's a feature plan??

The "Rename Symbol" feature is available in the current versions. It only has a problem in the particular context I detailed above.