Skip to content

Autocompletion and diagnostics for upcoming/experimental feature syntax in Package.swift #2774

Description

@czechboy0

Description

I just learned that swiftc -print-supported-features allows tools to inspect exactly which upcoming/experimental features a version of the toolchain supports, and I think it'd be great to integrate into sourcekit-lsp to get autocompletion and diagnostics for the magic strings one puts in.

For example, here I'd like to see:

// swift-tools-version: 6.4
import PackageDescription

let package = Package(
  name: "FeatureTest",
  targets: [
    .target(
      name: "FeatureTest",
      swiftSettings: [
        .enableUpcomingFeature("InternalImportsByDefault"), // no warning, all good
        .enableUpcomingFeature("ExistentialAy"), // <<< warning: 'ExistentialAy' is not a recognized upcoming feature; did you mean 'ExistentialAny'?
        .enableUpcomingFeature("Embedded"), // <<< warning: 'Embedded' is not an upcoming feature, use 'enableExperimentalFeature' instead
        .enableUpcomingFeature("ConciseMagicFile"), // <<< warning: Upcoming feature 'ConciseMagicFile' already enabled as of the Swift 6 language mode
        .enableUpcomingFeature("ExistentialAny"), // no warning, all good
      ]
    )
  ]
)

An extra reason is that making a typo in these strings silently disables a feature you're expecting to be enabled, and presumably burns some amount of time across the ecosystem. This sort of diagnostics and autocompletion would be a nice quality-of-life improvement.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions