arrow-kt / arrow-meta

Functional companion to Kotlin's Compiler
https://meta.arrow-kt.io
Apache License 2.0
395 stars 42 forks source link

Feature Proposal for IntelliJ #31

Open pakoito opened 5 years ago

pakoito commented 5 years ago

This is a proposal issue for Ide features we might want to consider for Arrow.

Comment below for suggestions and Feedback.

raulraja commented 5 years ago

What would an Arrow plugin for IDEA provide in terms of features?

pakoito commented 5 years ago

I'm not sure. Some visualization for debugging, same as the one for Streams and Observables.

Code snippets and hints? Hoogle-like search?

i-walker commented 4 years ago

@pakoito If you have more idea's post them here !

pakoito commented 4 years ago

Ordered by complexity and implementation groups: Pithy actions:

Code Actions/ Global or Local QuickFixes:

Try-Arrow.kt integration for the IDE:

Various Debug Features:

Type-driven search engine:

references:

i-walker commented 4 years ago

The Ank idea plugin runs Ank snippets and can be executed by a RunLineMarker as we know them for Tests and Main Methods. Interestingly, enough we can simplify creating a RunLineMarker to creating an Action, which runs the Snippet and displays the output in a window.

The aforementioned plugin should facilitate these features:

Props to @nomisRev idea :)

References: org.jetbrains.kotlin.idea.highlighter.KotlinRunLineMarkerContributor com.intellij.execution.lineMarker.RunLineMarkerProvider LanguageInjectionSyntax NavigationSyntax

ahinchman1 commented 4 years ago

We're currently unable to see IR generated directly with the Kotlin compiler. The only evidence we have of what that generated IR looks like is through the Kotlin text files in Github via kotlin/compiler/testData/ir/irText, where there are sample Kotlin files written accompanied by the generated text files.

We're working with IR a little blind - it'd be nice to have an IDE plugin for generating IR text on the spot.

Example: equality.kt

fun test1(a: Int, b: Int) = a == b

equality.txt

FILE fqName:<root> fileName:/equality.kt
  FUN name:test1 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Boolean
    VALUE_PARAMETER name:a index:0 type:kotlin.Int
    VALUE_PARAMETER name:b index:1 type:kotlin.Int
    BLOCK_BODY
      RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.Int, b: kotlin.Int): kotlin.Boolean declared in <root>'
        CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
          arg0: GET_VAR 'a: kotlin.Int declared in <root>.test1' type=kotlin.Int origin=null
          arg1: GET_VAR 'b: kotlin.Int declared in <root>.test1' type=kotlin.Int origin=null
  FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Boolean
    VALUE_PARAMETER name:a index:0 type:kotlin.Int
    VALUE_PARAMETER name:b index:1 type:kotlin.Int
    BLOCK_BODY
      RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.Int, b: kotlin.Int): kotlin.Boolean declared in <root>'
        CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ
          $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ
            arg0: GET_VAR 'a: kotlin.Int declared in <root>.test2' type=kotlin.Int origin=null
            arg1: GET_VAR 'b: kotlin.Int declared in <root>.test2' type=kotlin.Int origin=null
i-walker commented 4 years ago

@ahinchman1 there is already an IR Generator within the functionality of the Decompile to Kotlin Bytecode Action.

Please, correct me if that is not what you were proposing.

Screenshot 2019-11-21 at 12 58 23
ahinchman1 commented 4 years ago

@i-walker yes, I found out mine is just not working hahah - I'm sure I can figure out what's wrong with it eventually

ahinchman1 commented 4 years ago

Some validation received on an idea I had after giving an internal talk on AST parsing:

It would be amazing to write an IDE plugin that displays an actual tree for AST parsing unlike the PSIViewer. It's better than nothing but one day it would be amazing to see trees that look closer to this:

Screen Shot 2019-11-22 at 1 18 25 PM

There is an existing AST viewer I'd like to take inspiration from as well, but it exists only on Eclipse as a plugin and only for Java: https://www.eclipse.org/jdt/ui/astview/index.php but it would still be nice to have a more visual item that at least displays a tree vertically like the drawing above.