answer for the imports a renamed module leaves behind - #184
Merged
Conversation
KotlinIsland
force-pushed
the
sourcemaps
branch
from
August 17, 2026 08:25
e0d7ec0 to
6f0349a
Compare
KotlinIsland
force-pushed
the
module-rename
branch
from
August 17, 2026 08:27
36bef7d to
aed4ea3
Compare
KotlinIsland
force-pushed
the
sourcemaps
branch
from
August 17, 2026 08:52
6f0349a to
2f35435
Compare
KotlinIsland
force-pushed
the
module-rename
branch
from
August 17, 2026 08:52
aed4ea3 to
a11225a
Compare
KotlinIsland
force-pushed
the
sourcemaps
branch
2 times, most recently
from
August 17, 2026 10:28
d2c27d4 to
83c2f47
Compare
KotlinIsland
force-pushed
the
module-rename
branch
from
August 17, 2026 10:29
a11225a to
e3cb882
Compare
KotlinIsland
force-pushed
the
sourcemaps
branch
from
August 17, 2026 13:06
83c2f47 to
ebe7a22
Compare
KotlinIsland
force-pushed
the
module-rename
branch
2 times, most recently
from
August 17, 2026 16:20
046afc5 to
5a47fbd
Compare
renaming `util.by` to `helpers.by` renames the module `alpha.util`, and every `from alpha.util import thing` in the project is now naming a module that is not there. an editor cannot find those on its own: it would have to resolve every import against the same search paths the checker uses. so the protocol has it ask first, and the server had no answer — `workspace/willRenameFiles` was never advertised, and `rename` is a symbol rename that refuses an import's module component outright. the request is now handled. it arrives before the file moves, which is what makes it answerable at all: the old path still holds the file, so the module it is today resolves, while the new path is a path to read a name out of. that is the one thing `file_to_module` cannot do — it resolves the name it derives back to a file and checks the answer is the same file, which nothing at the new path can satisfy — so `path_to_module_name` answers the narrower, purely path-shaped question, for directories as well as files. what is rewritten is the module paths in import statements, at any depth in the file (an `if TYPE_CHECKING:` import is exactly the one written carefully), and the *uses* of a name an import binds when that name changes: `import alpha.util` binds `alpha`, so `alpha.util.thing()` moves too. those uses are found by their text and confirmed by their type — an expression is only rewritten when the checker says it is the module that moved, so a local called `util` in a file that also imports a module of that name is left alone. a relative import inside a package that is being renamed as a whole comes out unchanged, which is the truth: the dots go on meaning the file's own package, and that package is moving with it. two things are deliberately not rewritten, and both are reported rather than half-done: a module named as a string, and an import that would have to change shape — moving `alpha.util` to `beta.util` leaves `from alpha import util` needing a different statement, not a different word. folders are asked about as well as files, because renaming a directory renames every module under it and the client sends only the directory. a folder pattern cannot be narrowed the way the file one is — a directory has no extension, and whether it is a package is a question about the search paths — so every folder rename costs one request that usually answers with no edits. name a path by the deepest search path that contains it caught by driving the server against a real uv workspace. the member's package sits inside two search paths at once — the project root, and the editable entry uv writes for the member itself, pointing at its own `src` — and taking the first one consulted named `packages/alpha/src/alpha` as `packages.alpha.src.alpha`. that is not a module anything imports and not the name any `import alpha` resolves to, so a rename of it found nothing to rewrite and answered no edits at all. the deepest search path is the one whose name resolves back to the path, which is what `file_to_module` verifies for a file that exists. with the rule fixed, the same workspace answers with all three edits: the `from alpha import thing`, the `import alpha`, and the `alpha.thing()` in the body.
KotlinIsland
force-pushed
the
module-rename
branch
from
August 18, 2026 01:28
5a47fbd to
4f753f6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.