Skip to content

AST support : "Quick import feature" #243

@rundis

Description

@rundis

Summary:

Allow a user to quickly add an import when in the context of a defintion, so that adding the import is just a keyboard shortcut away, without loosing the current context the user is in.

Details:

  1. User is inside a function definition and writes Json.decodeString and presses magic key combo
  2. The editor is able to figure out
    1. That the only module that exposes decodeString is the Json.Decode module
    2. That this module has not been already imported
  3. With that knowledge is able to add a new import declaration node to the AST with module: "Json.Decode", alias: "Json" (and no exposing node)
  4. The user may keep on typing with the knowledge the import is in place and that the Json alias know can be safely used (and will give autocompletions etc etc upon further usage)

So you would need:

  • a way to introspect all exposeds for all modules in the project (bar the ones you have already imported for the given module, and probably default imports)
  • a way to figure out based on cursor position that you are in range of a top level definition

Discusion:

  • Might partially be out of scope as it requires knowledge of other modules exposed functions
  • For it to work, an illegal state (partially) must be supported

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions