Skip to content

Commit b334a94

Browse files
authored
Add makefile for GH actions (#216)
* Add makefile * Remove checkdoc * Fix byte-compile and lint warnings * ADd spinner as a development dependency * Add GH action test * Remove travis
1 parent 3924610 commit b334a94

File tree

8 files changed

+148
-101
lines changed

8 files changed

+148
-101
lines changed

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**/*.md'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
emacs-version:
14+
- 25.2
15+
- 25.3
16+
- 26.1
17+
- 26.2
18+
- 26.3
19+
- snapshot
20+
21+
steps:
22+
- uses: actions/checkout@v1
23+
24+
- uses: actions/[email protected]
25+
with:
26+
python-version: '3.6'
27+
architecture: 'x64'
28+
29+
- uses: purcell/setup-emacs@master
30+
with:
31+
version: ${{ matrix.emacs-version }}
32+
33+
- uses: conao3/setup-cask@master
34+
with:
35+
version: 0.8.4
36+
37+
- name: Run tests
38+
run: 'make test'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.cask
2+
*.elc
23
tmp/
34
/install/.mvn/wrapper/maven-wrapper.jar

.travis.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

Cask

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
(depends-on "markdown-mode")
77

88
(development
9+
(depends-on "spinner")
910
(depends-on "ecukes")
1011
(depends-on "espuds"))

Makefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
SHELL=/usr/bin/env bash
2+
3+
EMACS ?= emacs
4+
CASK ?= cask
5+
6+
INIT="(progn \
7+
(require 'package) \
8+
(push '(\"melpa\" . \"https://melpa.org/packages/\") package-archives) \
9+
(package-initialize) \
10+
(package-refresh-contents))"
11+
12+
LINT="(progn \
13+
(unless (package-installed-p 'package-lint) \
14+
(package-install 'package-lint)) \
15+
(require 'package-lint) \
16+
(package-lint-batch-and-exit))"
17+
18+
build:
19+
cask install
20+
21+
test: build compile checkdoc lint
22+
23+
compile:
24+
@echo "Compiling..."
25+
@$(CASK) $(EMACS) -Q --batch \
26+
-L . \
27+
--eval '(setq byte-compile-error-on-warn t)' \
28+
-f batch-byte-compile \
29+
*.el
30+
31+
lint:
32+
@echo "package linting..."
33+
@$(CASK) $(EMACS) -Q --batch \
34+
-L . \
35+
--eval $(INIT) \
36+
--eval $(LINT) \
37+
*.el
38+
39+
clean:
40+
rm -rf .cask
41+
42+
.PHONY: build test compile checkdoc lint

lsp-java-boot.el

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
;;; lsp-java.el --- Spring boot support for lsp-java -*- lexical-binding: t; -*-
1+
;;; lsp-java-boot.el --- Spring boot support for lsp-java -*- lexical-binding: t; -*-
22

33
;; Version: 2.0
4-
;; Keywords: java
5-
;; URL: https://github.com/emacs-lsp/lsp-java
6-
74
;; Package-Requires: ((emacs "25.1") (lsp-mode "6.0") (markdown-mode "2.3") (dash "2.14.1") (f "0.20.0") (ht "2.0") (dash-functional "1.2.0") (request "0.3.0"))
5+
;; Keywords: languague, tools
6+
;; URL: https://github.com/emacs-lsp/lsp-java
87

98
;; This program is free software: you can redistribute it and/or modify
109
;; it under the terms of the GNU General Public License as published by
@@ -19,14 +18,16 @@
1918
;; You should have received a copy of the GNU General Public License
2019
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
2120

22-
;;; Commentary: LSP Java support for Spring Boot.
21+
;;; Commentary:
22+
23+
;; LSP Java support for Spring Boot.
2324

2425
;;; Code:
2526

2627
(require 'dash)
28+
(require 'cl-lib)
2729
(require 'lsp-mode)
2830
(require 'lsp-java)
29-
(require 'cl)
3031

3132
(defcustom lsp-java-boot-enabled t
3233
"If non-nil start the boot server when opening java files."
@@ -49,14 +50,15 @@
4950
tools-jar))
5051

5152
(defun lsp-java-boot--sts-javadoc-hover-link (_workspace params)
52-
"Handler for java doc hover."
53+
"Handler with PARAMS data for java doc hover."
5354
(with-lsp-workspace (lsp-find-workspace 'jdtls nil)
5455
(lsp-request "workspace/executeCommand"
5556
(list :command "sts.java.addClasspathListener"
5657
:arguments (gethash "callbackCommandId" params))
5758
:no-wait t)))
5859

5960
(defun lsp-java-boot--sts-add-classpath-listener (_workspace params)
61+
"Add classpath listener for WORKSPACE with PARAMS data."
6062
(ignore
6163
(with-lsp-workspace (lsp-find-workspace 'jdtls nil)
6264
(lsp-request "workspace/executeCommand"
@@ -78,16 +80,19 @@ Store CALLBACK to use it `sts/highlight'."
7880
:lighter "BLens"
7981
(cond
8082
(lsp-java-boot-lens-mode
81-
(setq-local lsp-lens-backends (pushnew 'lsp-java-boot--lens-backend lsp-lens-backends))
83+
(setq-local lsp-lens-backends (cl-pushnew 'lsp-java-boot--lens-backend lsp-lens-backends))
8284
(lsp-lens-refresh t))
8385
(t (setq-local lsp-lens-backends (delete 'lsp-java-boot--lens-backend lsp-lens-backends))
8486
(setq-local lsp-java-boot--callback nil))))
8587

8688
(cl-defmethod lsp-execute-command
87-
(server (command (eql sts.open.url)) params)
89+
(_server (_command (eql sts.open.url)) params)
90+
"Execute open url command from PARAMS data."
8891
(browse-url (seq-first params)))
8992

90-
(cl-defmethod lsp-execute-command (server (command (eql sts.showHoverAtPosition)) params)
93+
(cl-defmethod lsp-execute-command
94+
(_server (_command (eql sts.showHoverAtPosition)) params)
95+
"Execute show hover at position command with PARAMS data."
9196
(goto-char (lsp--position-to-point (seq-first params)))
9297
(lsp-describe-thing-at-point))
9398

@@ -106,7 +111,7 @@ Store CALLBACK to use it `sts/highlight'."
106111
(expand-file-name)
107112
(f-join "boot-server")
108113
f-files
109-
first)
114+
cl-first)
110115
(lsp-log "Unable to find spring boot server jar.")))
111116

112117
(defun lsp-java-boot--ls-command (port)
@@ -127,9 +132,9 @@ Store CALLBACK to use it `sts/highlight'."
127132
(lsp-register-client
128133
(make-lsp-client :new-connection
129134
(lsp-tcp-server #'lsp-java-boot--ls-command)
130-
:activation-fn (lambda (filename major-mode)
135+
:activation-fn (lambda (_filename mode)
131136
(and lsp-java-boot-enabled
132-
(memq major-mode '(java-mode conf-javaprop-mode yaml-mode))
137+
(memq mode '(java-mode conf-javaprop-mode yaml-mode))
133138
(lsp-java-boot--server-jar)))
134139
:request-handlers (ht ("sts/addClasspathListener" #'lsp-java-boot--sts-add-classpath-listener)
135140
("sts/javadocHoverLink" #'lsp-java-boot--sts-javadoc-hover-link))

lsp-java.el

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
;; Version: 2.0
44
;; Package-Requires: ((emacs "25.1") (lsp-mode "6.0") (markdown-mode "2.3") (dash "2.14.1") (f "0.20.0") (ht "2.0") (dash-functional "1.2.0") (request "0.3.0") (treemacs "2.5"))
5-
;; Keywords: java
5+
;; Keywords: languague, tools
66
;; URL: https://github.com/emacs-lsp/lsp-java
77

88
;; This program is free software: you can redistribute it and/or modify
@@ -87,10 +87,6 @@ Use http://download.eclipse.org/che/che-ls-jdt/snapshots/che-jdt-language-server
8787
:type 'string
8888
:group 'lsp-java)
8989

90-
(defcustom lsp-jt-root (expand-file-name (locate-user-emacs-file "eclipse.jdt.ls/server/java-test/server"))
91-
"The `lsp-jt' root."
92-
:type 'string)
93-
9490
(defcustom lsp-java-pop-buffer-function 'lsp-java-show-buffer
9591
"The function which will be used for showing the helper windows."
9692
:type 'function
@@ -303,6 +299,11 @@ assist or quick fix proposals and when organizing imports. For
303299
example 'java.awt.*' will hide all types from the awt packages."
304300
:type 'vector)
305301

302+
(declare-function dap-debug "ext:dap-mode")
303+
(declare-function projectile-project-p "ext:projectile")
304+
(declare-function projectile-project-root "ext:projectile")
305+
(declare-function helm-make-source "ext:helm-source")
306+
306307
(lsp-register-custom-settings
307308
'(("java.codeGeneration.toString.limitElements" lsp-java-code-generation-to-string-limit-elements)
308309
("java.codeGeneration.toString.listArrayContents" lsp-java-code-generation-to-string-list-array-contents t)
@@ -369,7 +370,7 @@ example 'java.awt.*' will hide all types from the awt packages."
369370
(or (-> buf
370371
buffer-name
371372
(assoc lsp-java-buffer-configurations)
372-
rest)
373+
cl-rest)
373374
'((side . right)
374375
(slot . 1)
375376
(window-width . 0.20))))))
@@ -441,13 +442,13 @@ FULL specify whether full or incremental build will be performed."
441442
(make-directory path t)))
442443

443444
(cl-defmethod lsp-execute-command
444-
(_server (command (eql java.show.references)) params)
445+
(_server (_command (eql java.show.references)) params)
445446
(if-let (refs (seq-elt params 2))
446447
(xref--show-xrefs (lsp--locations-to-xref-items refs) nil)
447448
(user-error "No references")))
448449

449450
(cl-defmethod lsp-execute-command
450-
(_server (command (eql java.show.implementations)) params)
451+
(_server (_command (eql java.show.implementations)) params)
451452
(if-let (refs (seq-elt params 2))
452453
(xref--show-xrefs (lsp--locations-to-xref-items refs) nil)
453454
(user-error "No implementations")))
@@ -759,36 +760,22 @@ current symbol."
759760
(append lsp-java-bundles (when (file-directory-p bundles-dir)
760761
(apply 'vector (directory-files bundles-dir t "\\.jar$"))))))
761762

762-
(defun lsp-java--workspace-folders (workspace)
763+
(defun lsp-java--workspace-folders (_workspace)
763764
"Return WORKSPACE folders."
764765
(lsp-session-folders (lsp-session)))
765766

766767
(defun lsp-java--find-workspace (file-uri)
767768
"Return the workspace corresponding FILE-URI."
768769
(lsp-find-workspace 'jdtls (lsp--uri-to-path file-uri)))
769770

770-
(defun lsp-java--find-project-uri (file-uri)
771-
"Return the java project corresponding FILE-URI."
772-
(let ((workspace (lsp-java--current-workspace-or-lose))
773-
(session-folder (lsp-find-session-folder (lsp-session) (buffer-file-name))))
774-
(with-lsp-workspace workspace
775-
;; look for a maven nested project or fallback to the session folder root.
776-
(let ((project-folder (or (->> session-folder
777-
lsp--path-to-uri
778-
(lsp-send-execute-command "che.jdt.ls.extension.mavenProjects")
779-
(--filter (f-ancestor-of? (lsp--uri-to-path (file-name-as-directory it)) buffer-file-name))
780-
(--max-by (> (length it) (length other))))
781-
(lsp--path-to-uri (file-name-as-directory session-folder)))))
782-
project-folder))))
783-
784771
(cl-defmethod lsp-execute-command
785-
(_server (command (eql java.show.references)) params)
772+
(_server (_command (eql java.show.references)) params)
786773
(if-let (refs (cl-third (append params nil)))
787774
(lsp-show-xrefs (lsp--locations-to-xref-items refs) nil t)
788775
(user-error "No references")))
789776

790777
(cl-defmethod lsp-execute-command
791-
(_server (command (eql java.show.implementations)) params)
778+
(_server (_command (eql java.show.implementations)) params)
792779
(if-let (refs (cl-third (append params nil)))
793780
(lsp-show-xrefs (lsp--locations-to-xref-items refs) nil t)
794781
(user-error "No implementations")))
@@ -804,7 +791,7 @@ current symbol."
804791
(with-current-buffer (find-file (lsp--uri-to-path file-uri))
805792
(->> imports
806793
(seq-map (-lambda ((&hash "candidates" "range"))
807-
(-let (((beg . end) (lsp--range-to-region range)))
794+
(-let (((beg . _end) (lsp--range-to-region range)))
808795
(goto-char beg)
809796
(recenter nil))
810797
(lsp--completing-read "Select class to import: "
@@ -959,10 +946,7 @@ current symbol."
959946
(lsp-java-with-jdtls
960947
(let* ((context (lsp-seq-first (gethash "arguments" action)))
961948
(result (lsp-request "java/resolveUnimplementedAccessors" context))
962-
(fields-data (-map (-lambda ((field &as &hash "fieldName" name
963-
"generateGetter" getter?
964-
"generateSetter" setter?
965-
"isStatic" static?))
949+
(fields-data (-map (-lambda ((field &as &hash "fieldName" name))
966950
(cons (format "%s" name) field))
967951
result))
968952
(to-generate (lsp-java--completing-read-multiple
@@ -1090,9 +1074,7 @@ current symbol."
10901074
#'lsp-java--symbol-label))
10911075

10921076
(defun lsp-java-move-static-member (context command-info)
1093-
(-let [(&hash? "displayName" display-name
1094-
"enclosingTypeName" enclosing-type-name
1095-
"memberType" member-type
1077+
(-let [(&hash? "enclosingTypeName" enclosing-type-name
10961078
"projectName" project-name) command-info]
10971079
(lsp-java--apply-edit
10981080
(lsp-request "java/move"
@@ -1225,7 +1207,7 @@ current symbol."
12251207
(-map #'lsp--path-to-uri)
12261208
(apply #'vector))))
12271209
:library-folders-fn (lambda (_workspace) (list lsp-java-workspace-cache-dir))
1228-
:before-file-open-fn (lambda (workspace)
1210+
:before-file-open-fn (lambda (_workspace)
12291211
(let ((metadata-file-name (lsp-java--get-metadata-location buffer-file-name)))
12301212
(setq-local lsp-buffer-uri
12311213
(when (file-exists-p metadata-file-name)
@@ -1267,13 +1249,13 @@ current symbol."
12671249
(condition-case _err
12681250
(-let* ((group-id (read-string "Enter group name: " "com.example"))
12691251
(artifact-id (read-string "Enter artifactId: " "demo"))
1270-
(description (read-string "Enter description: " "Demo project for Spring Boot"))
1252+
(_description (read-string "Enter description: " "Demo project for Spring Boot"))
12711253
(boot-version (ask "Select boot-version: " 'bootVersion))
1272-
(java-version (ask "Select java-version: " 'javaVersion))
1254+
(_java-version (ask "Select java-version: " 'javaVersion))
12731255
(language (ask "Select language: " 'language))
12741256
(packaging (ask "Select packaging: " 'packaging))
12751257
(base-url "https://start.spring.io/")
1276-
(package-name (read-string "Select package name: " "com.example.demo"))
1258+
(_package-name (read-string "Select package name: " "com.example.demo"))
12771259
(type (ask "Select type: " 'type))
12781260
(target-directory (read-directory-name "Select project directory: " default-directory))
12791261
(dependenciles-list (->> data
@@ -1314,7 +1296,7 @@ current symbol."
13141296
:lighter nil
13151297
(cond
13161298
(lsp-java-lens-mode
1317-
(setq-local lsp-lens-backends (pushnew #'lsp-java-lens-backend lsp-lens-backends))
1299+
(setq-local lsp-lens-backends (cl-pushnew #'lsp-java-lens-backend lsp-lens-backends))
13181300
(lsp-lens-refresh t))
13191301
(t (setq-local lsp-lens-backends (delete #'lsp-java-lens-backend lsp-lens-backends)))))
13201302

@@ -1327,7 +1309,7 @@ current symbol."
13271309
:projectName project-name
13281310
:noDebug no-debug?))))
13291311

1330-
(defun lsp-java-lens-backend (modified? callback)
1312+
(defun lsp-java-lens-backend (_modified? callback)
13311313
(when (lsp--find-workspaces-for "workspace/executeCommand")
13321314
(lsp-request-async
13331315
"workspace/executeCommand"

0 commit comments

Comments
 (0)