Skip to content

Auto-imports not working for extension members #4143

Closed

Description

@DanTup

Using a recent nightly (which uses NotImportedContributor), completing on firstOrNull from package:collection does not add the import statement:

Screenshot 2022-09-05 at 16 56 06

Importing on something else (like calculate() from the default command line project) does insert the import statement.

Activity

  1. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Sep 5, 2022
  2. added this to the v3.50.0 milestone on Sep 5, 2022
  3. DanTup commented on Sep 5, 2022

    @DanTup
    MemberAuthor

    Seems to be failing to resolve. Completion:

    {
    	"data": {
    		"file": "/Users/danny/Desktop/dart_samples/autoimportextension/lib/a.dart",
    		"libraryUri": "package:collection/collection.dart"
    	},
    	"detail": "T?",
    	"kind": 10,
    	"label": "firstOrNull",
    	"sortText": "9999497",
    	"textEdit": {
    		"newText": "firstOrNull",
    		"range": {
    			"end": {
    				"character": 19,
    				"line": 2
    			},
    			"start": {
    				"character": 12,
    				"line": 2
    			}
    		}
    	}
    }

    Resolve response:

    {
    	"id": 10,
    	"jsonrpc": "2.0",
    	"error": {
    		"code": -32602,
    		"data": "firstOrNull",
    		"message": "No such element: firstOrNull in package:collection/collection.dart"
    	}
    }
    
  4. changed the title [-]auto-imports not working for extension members[/-] [+]Auto-imports not working for extension members[/+] on Sep 5, 2022
  5. DanTup commented on Sep 6, 2022

    @DanTup
    MemberAuthor
  6. added
    relies on sdk changesSomething that requires changes in the Dart/Flutter SDK to ship before it will become available
    on Sep 6, 2022
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