Skip to content

Do not re-index deleted files #2078

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

Merged
merged 1 commit into from
Mar 21, 2025

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Mar 20, 2025

This wasn’t an issue when we were always waiting for an up-to-date build graph before indexing files but now we could still have an old build graph that contains the deleted files and thus start an indexing process for a file that doesn’t exist anymore on disk. And it’s cleaner anyway.

This wasn’t an issue when we were always waiting for an up-to-date build graph before indexing files but now we could still have an old build graph that contains the deleted files and thus start an indexing process for a file that doesn’t exist anymore on disk. And it’s cleaner anyway.
@ahoppen
Copy link
Member Author

ahoppen commented Mar 20, 2025

@swift-ci Please test

@@ -379,7 +379,7 @@ package final actor SemanticIndexManager {
package func filesDidChange(_ events: [FileEvent]) async {
// We only re-index the files that were changed and don't re-index any of their dependencies. See the
// `Documentation/Files_To_Reindex.md` file.
let changedFiles = events.map(\.uri)
let changedFiles = events.filter { $0.type != .deleted }.map(\.uri)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not be marking preparation for dependent targets out-of-date for deleted files?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, we can’t rely on being able to get the target that the file used to be part of. The build system might have already processed the removal of the file, which means that it won’t give us any targets for the file.

This should happen through the build system. It also receives the workspace/didChangeWatchedFiles notification and should send us a buildTargets/didChange notification if the deletion of the file changed that target. And we mark the file’s target as out-of-date based on this from SemanticIndexManager.buildTargetsChanged.

Does this make sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, yeah makes sense

@ahoppen ahoppen merged commit 4220b7f into swiftlang:main Mar 21, 2025
3 checks passed
@ahoppen ahoppen deleted the no-reindex-deleted-files branch March 21, 2025 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants