Skip to content

IntelliJ plugin: "materialize compiler plugin DataFrame type" action #1348

@Jolanrensen

Description

@Jolanrensen

Let's say you have a function that reads a dataframe and performs some conversions on it:

fun getEnglishPenguins() /* : DataFrame<DanishPenguins_123> */ = 
    DataFrame.read("").cast<DanishPenguins>()
        .rename { arter }.into("species")
        .rename { � }.into("island")
        .rename { n�bl�ngde_mm }.into("bill_length_mm")
        .rename { n�bdybde_mm }.into("bill_depth_mm")
        .rename { luffel�ngde_mm }.into("flipper_length_mm")
        .rename { kropsmasse_g }.into("body_mass_g")
        .rename { k�n }.into("sex")
        .rename { m�ledato }.into("measurement_date")

So, imagine your inlay hint tells you you got a DataFrame<DanishPenguins_123>. However, you want to define this type somewhere as a data schema (because you want to use it as input to a new function).
With an IntelliJ plugin, you could make it so that when hovering over this type (or when your cursor is at a variable of that type or touching a function call returning that type), a quick-fix could become available to "Create data schema interface/class".

What it would do:

  • First, it would allow you to define in which scope to put it, like with the "extract to function" action.
  • Then, when it is created with the information of the compiler plugin, it has the same name, so DanishPenguins_123 and the result of the expression gets a .cast<DanishPenguins_123>()
  • Then a refactoring is started on the name of the interface, so the user can either rename it to something they want or press Enter to leave it like that.

So, for instance, the end-result could be:

@DataSchema
interface EngishPenguins {
    val species: String?
    val body_mass_g: Double?
    val sex: String?
    ...
}

fun getEnglishPenguins() /* : DataFrame<EngishPenguins> */ = 
    DataFrame.read("").cast<DanishPenguins>()
        ...
        .cast()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compiler pluginAnything related to the DataFrame Compiler PluginenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions