lang/java: fix java namespace resolution #1098

Now uses slightly more sophisticated namespace resolution when
populating the *.java file template.
This commit is contained in:
Henrik Lissner 2019-01-21 03:44:21 -05:00
parent 4b8c21a34b
commit 99e916348a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 66 additions and 8 deletions

View file

@ -1,5 +1,26 @@
;;; lang/java/config.el -*- lexical-binding: t; -*-
(defvar +java-project-package-roots (list "java/" "test/" "main/" "src/" 1)
"A list of relative directories (strings) or depths (integer) used by
`+java-current-package' to delimit the namespace from the current buffer's full
file path. Each root is tried in sequence until one is found.
If a directory is encountered in the file path, everything before it (including
it) will be ignored when converting the path into a namespace.
An integer depth is how many directories to pop off the start of the relative
file path (relative to the project root). e.g.
Say the absolute path is ~/some/project/src/java/net/lissner/game/MyClass.java
The project root is ~/some/project
If the depth is 1, the first directory in src/java/net/lissner/game/MyClass.java
is removed: java.net.lissner.game.
If the depth is 2, the first two directories are removed: net.lissner.game.")
;;
;; java-mode
(add-hook 'java-mode-hook #'rainbow-delimiters-mode)
(cond ((featurep! +meghanada) (load! "+meghanada"))