Skip to content

support adding import statements for entities reference in comments. #4792

Closed

Description

@bsutton

dart-code is very helpful when offering to add a missing import for a class of function.

However, if I reference an entity in a comment dart-code doesn't offer to import the required library.

/// see also: [PanelClipboards]

A lint error is generated:

[{
	"resource": "dvault_ui/lib/src/view/clipboard/clipboard_summary_card.dart",
	"owner": "_generated_diagnostic_collection_name_#0",
	"code": {
		"value": "comment_references",
		"target": {
			"$mid": 1,
			"external": "https://dart.dev/lints/comment_references",
			"path": "/lints/comment_references",
			"scheme": "https",
			"authority": "dart.dev"
		}
	},
	"severity": 2,
	"message": "The referenced name isn't visible in scope.\nTry adding an import for the referenced name.",
	"source": "dart",
	"startLineNumber": 11,
	"startColumn": 16,
	"endLineNumber": 11,
	"endColumn": 31
}]
`

To fix this we need a quick fix for `comment_references' that offers to import the required library.


Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Oct 15, 2023
  2. added this to the v3.76.0 milestone on Oct 17, 2023
  3. 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 17, 2023
  4. DanTup commented on Oct 17, 2023

    @DanTup
    Member

    I've landed a change in dart-lang/sdk@6489835 which enables that fix for this lint. It'll ship in a future SDK release.

  5. bsutton commented on Oct 17, 2023

    @bsutton
    Author
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 enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.relies 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