Skip to content

Fix all does not work on part of files. #4813

Closed

Description

@nero-angela

Reproduce

  1. Turn on the fix all option when saving in VSCode.
  2. Create the main.dart file and sub.dart file using dart’s part & part of syntax as follows.
    • main.dart
    import 'package:flutter/material.dart';
    
    part 'sub.dart';
    
    void main() {
      runApp(const Sub());
    }
    • sub.dart
    part of 'main.dart';
    
    class Sub extends StatelessWidget {
      const Sub({super.key});
    
      @override
      Widget build(BuildContext context) {
        return Column(
          children: [
            SizedBox(), /// 👈 Use 'const' with the constructor to improve performance.
          ],
        );
      }
    }
  3. Even if you save in the sub.dart file, fix all does not work, so const is not added before SizedBox().
  4. If you save in the main.dart file, fix all will work in the sub.dart file.

Expected

I think even if saved in the sub.dart file, const must be added in front of SizedBox().

Video

2023-10-25.1.09.45.mov

Activity

  1. added this to the v3.76.0 milestone on Oct 25, 2023
  2. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    on Oct 25, 2023
  3. DanTup commented on Oct 26, 2023

    @DanTup
    Member

    Fixed by dart-lang/sdk@28456ae

    The change is in the Dart analysis server so will show up in a future Dart/Flutter SDK release (not a VS Code extension release).

  4. whesse commented on Oct 26, 2023

    @whesse

    [EDIT]: The error is most likely due to another CL, https://dart-review.googlesource.com/c/sdk/+/331740
    Ignore this comment.

    Does this fix also fix this error in Flutter tests?

    Error from the analysis server: Exception while getting bulk fixes: type 'NotLibraryButPartResult' is not a subtype of type 'ParsedLibraryResult' in type cast
    | #0      BulkFixProcessor._computeChangesToPubspec (package:analysis_server/src/services/correction/bulk_fix_processor.dart:373:13)
    | #1      BulkFixProcessor.fixPubspec (package:analysis_server/src/services/correction/bulk_fix_processor.dart:284:7)
    | #2      EditBulkFixes.handle (package:analysis_server/src/handler/legacy/edit_bulk_fixes.dart:56:38)
    | #3      LegacyAnalysisServer.handleRequest.<anonymous closure>.<anonymous closure> (package:analysis_server/src/legacy_analysis_server.dart:559:25)
    

    flutter/flutter#137298

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bugrelies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions