Skip to content

Analysis Server double-watches file system #54220

Open
@scheglov

Description

@scheglov

See https://dart-review.googlesource.com/c/sdk/+/339232/2/pkg/analysis_server/test/domain_analysis_test.dart#195

Apparently we add watchers for both the included directory, and nested package.

[newFile][path: /home/test/AndroidManifest.xml]
[_notifyWatchers]
  /home/test/AndroidManifest.xml isWithin /home
  /home/test/AndroidManifest.xml isWithin /home/test

This is a simple example that demonstrates that PhysicalResourceProvider behaves the same as our MemoryResourceProvider.

import 'package:analyzer/file_system/physical_file_system.dart';

main() {
  PhysicalResourceProvider.INSTANCE
      .getFolder('/Users/scheglov/tmp/20231203')
      .watch()
      .changes
      .listen((event) {
    print('[root][event: $event]');
  });

  PhysicalResourceProvider.INSTANCE
      .getFolder('/Users/scheglov/tmp/20231203/test')
      .watch()
      .changes
      .listen((event) {
    print('[test][event: $event]');
  });
}

When I create a.dart file, both watches are notified.

[root][event: add /Users/scheglov/tmp/20231203/test/a.dart]
[test][event: add /Users/scheglov/tmp/20231203/test/a.dart]

@DanTup do you know if this is an expected behavior, or accidental?

I think this does not affect significantly analysis of Dart files, we add changed files to the list, but if it was not yet (or ever be) read as FileState, we quickly exit from collectAffected().

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onanalyzer-technical-debtarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-serverIssues related to some aspect of the analysis servertype-code-healthInternal changes to our tools and workflows to make them cleaner, simpler, or more maintainable

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions