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

Renaming is not possible if file is excluded from analysis_options #59912

Open
FMorschel opened this issue Jan 15, 2025 · 2 comments
Open

Renaming is not possible if file is excluded from analysis_options #59912

FMorschel opened this issue Jan 15, 2025 · 2 comments
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request

Comments

@FMorschel
Copy link
Contributor

If you have on your analysis_options.yaml the following:

analyzer:
  exclude:
    - "**.g.dart"

When you use build_runner and a file with that ending is created, it is not analyzed (whatever that means besides showing warnings/lints).

That is what I expected but renaming doesn't work - "is outside of project" message. Since this file is still within my project I was not expecting this message but mainly I expected the rename to work.

Image

I'd expect it to allow me to rename if the file is inside any of the original analysis roots, regardless of where excludes and actual contexts are.


FYI @bwilkerson @DanTup

@FMorschel FMorschel added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Jan 15, 2025
@DanTup
Copy link
Collaborator

DanTup commented Jan 15, 2025

Now I think about this more, this might actually be WAI. I first thought we just had a naive check to prevent you accidentally renaming something outside of your project (for example in the Pub Cache!). But now I'm wondering if the index that's used to find references for renaming actually exists for an excluded folder?

I'm also curious about what it is you're trying to rename here - if the declaration is in generated code, would you want to modify it at all? (shouldn't the code generator update it?)

@FMorschel
Copy link
Contributor Author

In this case, it was a simple propriety I wanted to rename (the screenshot is merely demonstrative) because when generating it I mistyped where it would copy the name for it (forgot an s). There was no need to regenerate it all and I wasn't using watch. I could of course build again but that would take longer than:

  • Opening the declaration, fixing there
  • Finding the (in this case only three) problems with the vscode workspace search and replacing them there

It would have been even faster with the rename index of course but way slower to run build_runner again.


At the very least the message got me confused, if you still want to keep this behaviour we could think of a better message to display here instead.

@scheglov scheglov added P3 A lower priority bug or feature request analyzer-server labels Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

3 participants