Kakoune-java.kak : Java SE 14; operators, keywords, module system, throwables, and static word completion

Three new files provide custom completers for import statements; javaClassHierarchy.kak, javaInterfaceHierarchy.kak, javaAnnotationEnumHierarchy.kak


Usage Completers
import<space>object<tab>
import java.lang.Object;

import<space>basicfileattributeview<tab>
import java.nio.file.attribute.BasicFileAttributeView;

References

Completers

The scaffolding for custom completions @Screwtapello and community any improvements you can see are welcome (awk was necessary due to hang/parse-time).

Small additional benefit is a list of unknown/unfamiliar or what was it again? Close match imports that can be reviewed or copied onto system clipboard and pasted into the java api search field to read the documentation. https://docs.oracle.com/en/java/javase/15/docs/api/index.html

import file

hook global WinSetOption filetype=java %{
  require-module java

  declare-option -hidden completions java_annotation_enum_hierarchy_completions

  set-option window completers option=java_annotation_enum_hierarchy_completions %opt{completers}

  hook -group java-import-statements window InsertIdle .* %{
    try %{
      execute-keys -draft 2b s \A^import<space>\z<ret>

      evaluate-commands -draft %{
        execute-keys h <a-i>w <a-semicolon>

        set-option window java_annotation_enum_hierarchy_completions \
          "%val{cursor_line}.%val{cursor_column}+%val{selection_length}@%val{timestamp}"
      }

      evaluate-commands %sh{
        exec awk -f - <<'EOF'
        BEGIN {
          split("java.beans.BeanProperty java.beans.ConstructorProperties ...", annotationTypeHierarchy);
        }
        
        function print_import_statement(imports) { for (i in imports) { printf(" %s\\;||%s", imports[i], imports[i]); } }
        
        BEGIN {
          printf("set-option -add window java_annotation_enum_hierarchy_completions ");
          print_import_statement(annotationTypeHierarchy);
          printf("\n");
        }
EOF
      }
    } catch %{
      set-option window java_annotation_enum_hierarchy_completions
    }
  }
  hook -once -always window WinSetOption filetype=.* %{ remove-hooks window java-import-statements }
}

EXPLICIT LANGUAGE WARNING on Spotify:
This Is The New Sht | Marilyn Manson or youtube.

Thanks guys. Bye :wave:.