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

**URL:** <https://discuss.kakoune.com/t/kakoune-java-kak-java-se-14-operators-keywords-module-system-throwables-and-static-word-completion/1253>\
**Category:** Plugins\
**Tags:** language\
**Created:** [September 5, 2020, 5:29am UTC](https://discuss.kakoune.com/t/kakoune-java-kak-java-se-14-operators-keywords-module-system-throwables-and-static-word-completion/1253 "2020-09-05T05:29:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![duncan](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/duncan/32/95_2.png) [@duncan](https://discuss.kakoune.com/u/duncan)\
**Post date:** [February 2, 2021, 3:04am UTC](https://discuss.kakoune.com/t/kakoune-java-kak-java-se-14-operators-keywords-module-system-throwables-and-static-word-completion/1253/3 "2021-02-02T03:04:06Z")

</div>

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

- [Hierarchy For All Packages](https://docs.oracle.com/en/java/javase/15/docs/api/overview-tree.html) for import statements.

* * *

##### Usage Completers

```java
import<space>object<tab>
import java.lang.Object;

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

```

* * *

##### References

- Oracle 2021, Hierarchy For All Packages, Java SE 15, viewed 29 January 2021, [Class Hierarchy (Java SE 15 & JDK 15)](https://docs.oracle.com/en/java/javase/15/docs/api/overview-tree.html)
- Screwtape 2020, Intro to Kakoune completers, Discuss Kakoune, viewed 29 January 2021, [Intro to Kakoune completers](https://discuss.kakoune.com/t/intro-to-kakoune-completers/1198)
- Screwtape 2020, Intro to Kakoune completions, Screwtape’s Notepad, viewed 29 January 2021, [https://zork.net/~st/jottings/Intro\_to\_Kakoune\_completions.html](https://zork.net/~st/jottings/Intro_to_Kakoune_completions.html)

* * *

##### 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](https://docs.oracle.com/en/java/javase/15/docs/api/index.html)

```java
import file

```

 ![kakoune-java-class-hierarchy](https://discuss.kakoune.com/uploads/default/original/1X/28b1b97c1a0248c48b41182c910d09c440044bb2.png)

```auto
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](https://open.spotify.com/track/2LlnmNGqBJqvEZJMwFiDRx?si=L1utqUtHSIaiAl9wQvFiwA) or [youtube](https://youtu.be/4kQMDSw3Aqo).

Thanks guys. Bye 👋.

---

_[View the full topic](https://discuss.kakoune.com/t/kakoune-java-kak-java-se-14-operators-keywords-module-system-throwables-and-static-word-completion/1253)._
