-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
includedSuggestionSets contains duplicates #37211
Comments
I was not able to reproduce this. |
Hmm, I tested it a few times and it seems to be intermittent on the same project (I can restart the analyzer, then sometimes I'll see it and sometimes I won't). I'll do some more digging tomorrow to see if I can understand it better. |
Ok, I'm failing to understand what's going on here, but I seem to be able to reliably reproduce it in one folder, and reliably not reproduce it in another folder. The folders are identical (just copy/pasted) except for their paths. Could this be related to something in Here are the logs: analyzer_with_dupes.txt The logs have some requests in different orders, but I don't think that should matter. One has duplicates in The exact repo I'm using (though I commented out the SDK path in |
Ok, it seems like the dupes already exist in @scheglov is it expected that there may be dupes here? If so, then I think the bug is in I thought this might be confused because I'm working in the Flutter repo (so I have types in the loaded SDK, as well as in my current project), however my original repro above was with my own local types, so I don't think that's related. |
No, |
Correct; The only thing I can think of off the top of my head that would cause it to return the same file more than once is if there is a symbolic link inside the context root. Under the covers we're using |
I can only repro this in Flutter right now (using the changeset above), but here's what I found... If I hack some logging into It just prints the folder and all of its children when it gets to the lib folder, it outputs this:
So it seems like The only symlinks in the tree (assuming this command works as I expect) appear to only point further down their own trees:
But to eliminate them, I deleted the darwin-x64 folder and there was no change. I'll see if I can attach a debugger and do some more digging later (and if you have any ideas about what it could be in the meantime, do lmk!). |
Ok, I had another look at this, and I found the first place the duplicates show up here: sdk/pkg/analyzer/lib/file_system/overlay_file_system.dart Lines 343 to 365 in 7acecda
For my Flutter example above (where If I'm understanding the code correctly, this is loading children from the file system and then adding the overlay ones on top? If so, shouldn't there be some logic to handle when things are already in |
@bwilkerson if my understanding above is correct, I think this is a test (added to @soloTest
test_getChildren_existing_withOverlay() {
Folder folder = _folder(exists: true);
Folder child1 = _folder(
exists: true, path: provider.pathContext.join(folder.path, 'lib'));
_file(
exists: true,
path: provider.pathContext.join(child1.path, 'a.dart'),
withOverlay: true);
List<Resource> children = folder.getChildren();
children.forEach((r) => print(r.path));
expect(children, hasLength(1));
} Output looks like this:
Is the answer to change the list in the code above to use a (if this is the problem though, I'm not sure why it doesn't seem to affect more things 🤔) |
Yes, the returned list should not contain duplicates.
If by "code above" you mean the implementation of |
Ok great, I've opened a fix: https://dart-review.googlesource.com/c/sdk/+/108600/ There was another path that resulted in dupes - multiple descendant overlays (the overlay loop would add their containing folders one-per-file). I think that one might've been a bigger impact because instead of getting just one extra dupe (file + overlay file), you could get folders repeated for every descendant overlay file at each level of the tree it (eg. five overlays down in Both issues should be fixed by the CL above and have tests. |
I noticed I was seeing dupes in the completion list, and it seems like the server can include suggestion sets multiple times in a completion response.
The libraries here are all in my local workspace alongside the
workfile.dart
file.Source project is like:
lib/proxy1.dart
lib/proxy2.dart
lib/real_def.dart
lib/workfile.dart
pubspec.yaml
I use using the latest nightly build of the Dart SDK.
@scheglov I can add code to skip these, but it seems like it might be better done in the server so that each client doesn't need to know to do it?
The text was updated successfully, but these errors were encountered: