Skip to content

Filename completion doesn't work for conditional imports #4530

Closed

Description

@DanTup

Filed by @mosuem at #4529. Splitting it up because the issues may be fixed separately.

  1. There is no code completion for source file paths in conditional imports.

Activity

  1. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on May 9, 2023
  2. added this to the v3.66.0 milestone on May 9, 2023
  3. DanTup commented on May 9, 2023

    @DanTup
    MemberAuthor

    @bwilkerson I thought this would be a trivial fix, but I hit some issues because when completing at eof in code like:

    import '' if (a) '^
    

    The completion entity is a synthetic ; whose parent is ImportDirective. This means in a few places where I'd like to see Configuration I see ImportDirective. There are a few places that assume given an ImportDirective we'd be completing its uri, for example:

    https://github.com/dart-lang/sdk/blob/a41d1b5813b4e463cff6876bb24730642ffa8405/pkg/analyzer_plugin/lib/src/utilities/completion/completion_target.dart#L487

    So I'm not sure whether the fix is to try and handle this in those places (another is UriContributor which only visits ImportDirective as a result, and not Configuration), or whether the completion target/containingNode should be more specific for Configurations?

    (I'm also aware you wanted to make some changes in this area, so if this is best left until after, that's fine - I thought this would be a two-line fix 😄)

  4. bwilkerson commented on May 9, 2023

    @bwilkerson

    It will probably be easier to fix in the design I've proposed, but they key here is to notice when we're completing in an ImportDirective, the offset is inside a configuration, and the offset is after a synthetic string and before a synthetic semicolon (or something like that, there's probably other structures produced if it's followed by another configuration).

    Unfortunately, with code completion, there's generally nothing easier than trying all of the possible inputs you can think of and figuring out what structure you're looking at, and it's sometimes the case that the structure doesn't match what the user has in mind at all.

  5. DanTup commented on May 10, 2023

    @DanTup
    MemberAuthor

    Fixed by dart-lang/sdk@dd72682 (an SDK change, so it'll show up in an SDK release rather than a Dart-Code release).

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