[elpa] master ee6b97d: packages/javaimp/javaimp.el: replace kill-line with delete-region
branch: master commit ee6b97de2627641862ee69c79366ec426f4de8f1 Author: Filipp Gunbin Commit: Filipp Gunbin packages/javaimp/javaimp.el: replace kill-line with delete-region --- packages/javaimp/javaimp.el | 21 +++-- 1 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index 888f5c1..822b891 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -617,8 +617,7 @@ argument is a list of additional classes to import." (interactive) (barf-if-buffer-read-only) (save-excursion -(let ((kill-whole-line t) - import-groups static-import-groups old-imports-start) +(let (import-groups static-import-groups old-imports-start) ;; existing imports (goto-char (point-min)) (while (re-search-forward @@ -633,9 +632,9 @@ argument is a list of additional classes to import." static-import-groups))) (beginning-of-line) (unless old-imports-start (setq old-imports-start (point))) - (kill-line) - ;; delete whatever happened to be between import statements - (when (not (equal (point) old-imports-start)) + (delete-region (point) (save-excursion (forward-line 1) (point))) + ;; delete whatever was between import statements + (when (/= (point) old-imports-start) (delete-region old-imports-start (point ;; new imports (dolist (class new-classes) @@ -645,15 +644,17 @@ argument is a list of additional classes to import." (progn ;; prepare the position (cond (old-imports-start - ;; here we do not mangle with empty lines at all + ;; when there were any imports, do not touch blank lines + ;; before imports (goto-char old-imports-start)) ((re-search-forward "^\\s-*package\\s-" nil t) - ;; try to preserve all empty lines (if any) before the - ;; following text - (when (equal (forward-line) 1) (insert ?\n)) ;; last line? + ;; when there is a package statement, insert one or two + ;; blank lines after it + (when (= (forward-line) 1) (insert ?\n)) ;; last line? (insert ?\n)) (t - ;; start from the bob; add one line after the insert pos + ;; otherwise, start at the bob, insert one empty line + ;; after point (goto-char (point-min)) (insert ?\n) (backward-char)))
[elpa] master b36c4b4: packages/javaimp/javaimp.el: use line-beginning-position instead of forward-line
branch: master commit b36c4b46902807992e9971fe5b3d374d8e645154 Author: Filipp Gunbin Commit: Filipp Gunbin packages/javaimp/javaimp.el: use line-beginning-position instead of forward-line --- packages/javaimp/javaimp.el |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index 822b891..68079c0 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -632,7 +632,7 @@ argument is a list of additional classes to import." static-import-groups))) (beginning-of-line) (unless old-imports-start (setq old-imports-start (point))) - (delete-region (point) (save-excursion (forward-line 1) (point))) + (delete-region (point) (line-beginning-position 2)) ;; delete whatever was between import statements (when (/= (point) old-imports-start) (delete-region old-imports-start (point
[elpa] master c2ad2ed: packages/javaimp/javaimp.el: Support additional source directories.
branch: master commit c2ad2ed2a88338932547b7b89ede7a2c0276e211 Author: Filipp Gunbin Commit: Filipp Gunbin packages/javaimp/javaimp.el: Support additional source directories. * packages/javaimp/javaimp.el (javaimp-additional-source-dirs): New defcustom. (javaimp-make-mod): Add build-dir. (javaimp-get-mod-build-dir): New defun. (javaimp-maven-build-children): Use module build directory (javaimp-get-module-classes): Add classes in 'additional-source-dirs' to project classes. --- packages/javaimp/javaimp.el | 124 ++ 1 files changed, 88 insertions(+), 36 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index ca1a710..68ec76b 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -40,6 +40,10 @@ ;; ;; `javaimp-jdk-home' is a path for JDK. It is used to scan JDK jars. ;; Usually you will need to set this. +;; +;; `javaimp-additional-source-dirs' is a list specifying directories where +;; additional (e.g. generated) source files reside. Each directory is a +;; relative path from ${project.build.directory} project property value. ;; ;; `javaimp-mvn-program' defines path of the `mvn' program. Use if it's ;; not on `exec-path'. @@ -65,9 +69,13 @@ ;; Sample setup (put this into your .emacs): ;; ;; (require 'javaimp) -;; (add-to-list -;; 'javaimp-import-group-alist '("\\`\\(ru\\.yota\\.\\|tv\\.okko\\.\\)" . 80)) -;; (setq javaimp-jdk-home "/opt/java") +;; +;; (add-to-list 'javaimp-import-group-alist '("\\`\\(ru\\.yota\\.\\|tv\\.okko\\.\\)" . 80)) +;; +;; (setq javaimp-jdk-home (getenv "JAVA_HOME")) +;; (setq javaimp-include-current-project-classes t) +;; (setq javaimp-additional-source-dirs '("generated-sources/thrift")) +;; ;; (add-hook 'java-mode-hook ;; (lambda () ;; (local-set-key "\C-ci" 'javaimp-add-import) @@ -94,10 +102,14 @@ "Add and reorder Java import statements in Maven projects.") (defcustom javaimp-import-group-alist '(("\\`javax?\\." . 10)) - "Specifies how to group classes and how to order resulting groups in the -imports list. Each element should be of the form `(CLASSNAME-REGEXP -. ORDER)' where `CLASSNAME-REGEXP' is a regexp matching the fully qualified -class name. The order of classes which were not matched is defined by + "Specifies how to group classes and how to order resulting +groups in the imports list. + +Each element should be of the form `(CLASSNAME-REGEXP . ORDER)' +where `CLASSNAME-REGEXP' is a regexp matching the fully qualified +class name. + +The order of classes which were not matched is defined by `javaimp-import-default-order'.") (defcustom javaimp-import-default-order 50 @@ -107,6 +119,23 @@ class name. The order of classes which were not matched is defined by (defcustom javaimp-jdk-home nil "Path to the JDK") +(defcustom javaimp-additional-source-dirs nil + "List of directories where additional (e.g. generated) +source files reside. + +Each directory is a relative path from ${project.build.directory} project +property value. + +Typically you would check documentation for a Maven plugin, look +at the parameter's default value there and add it to this list. + +E.g. \"${project.build.directory}/generated-sources/\" +becomes \"generated-sources/\" (note the absence +of the leading slash. + +Custom values set in plugin configuration in pom.xml are not +supported yet.") + (defcustom javaimp-mvn-program "mvn" "Path to the `mvn' program") @@ -117,8 +146,10 @@ class name. The order of classes which were not matched is defined by "Path to the `jar' program") (defcustom javaimp-include-current-project-classes t - "If non-nil, current project's classes are included into - completion alternatives. Only top-level classes are included.") + "If non-nil, current project's classes are included into completion +alternatives. + +Only top-level classes are included.") ;;; Variables and constants @@ -152,11 +183,13 @@ class name. The order of classes which were not matched is defined by ;; A module is represented as a list of the form `(ARTIFACT POM-FILE -;; SOURCE-DIR TEST-SOURCE-DIR POM-FILE-MOD-TS PARENT PARENT-TS)'. +;; SOURCE-DIR TEST-SOURCE-DIR BUILD-DIR POM-FILE-MOD-TS PARENT PARENT-TS)'. -(defsubst javaimp-make-mod (artifact pom-file source-dir test-source-dir -pom-file-mod-ts jars-list parent parent-ts) - (list artifact pom-file source-dir test-source-dir +(defsubst javaimp-make-mod (artifact pom-file source-dir +test-source-dir build-dir +
[elpa] master 135c758: javaimp.el: Fix Maven output start regexp.
branch: master commit 135c7587f9764e0cc224c0e865b31e6c2b2cc83d Author: Filipp Gunbin Commit: Filipp Gunbin javaimp.el: Fix Maven output start regexp. --- packages/javaimp/javaimp.el |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index 68ec76b..e1152a9 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -315,7 +315,7 @@ with POM" (let (xml-start-pos xml-end-pos) ;; find where we should start parsing XML (goto-char (point-min)) - (re-search-forward "<\\?xml\\|") + (re-search-forward "<\\?xml\\|
[elpa] master 73fe889: * packages/javaimp/javaimp.el: Update javaimp to v. 0.6.
branch: master commit 73fe889322ee5343ad7b706520c69bf2dfe96694 Author: Filipp Gunbin Commit: Filipp Gunbin * packages/javaimp/javaimp.el: Update javaimp to v. 0.6. --- packages/javaimp/javaimp.el |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index e1152a9..df402ce 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -4,7 +4,7 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.5 +;; Version: 0.6 ;; Keywords: java, maven, programming ;;; Commentary:
[elpa] master a9ae80a: javaimp.el: Fill :file module slot in a separate step.
branch: master commit a9ae80a67508421c8611f40abd998201e6baba5b Author: Filipp Gunbin Commit: Filipp Gunbin javaimp.el: Fill :file module slot in a separate step. This fixes the (rare) case when actual module parent (from its tag) is not its immediate parent filesystem-wise. --- packages/javaimp/javaimp.el | 199 ++-- 1 file changed, 99 insertions(+), 100 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index e19d0da..e00c956 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -1,6 +1,6 @@ ;;; javaimp.el --- Add and reorder Java import statements in Maven projects -*- lexical-binding: t; -*- -;; Copyright (C) 2014-2017 Free Software Foundation, Inc. +;; Copyright (C) 2014-2018 Free Software Foundation, Inc. ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin @@ -173,7 +173,6 @@ to the completion alternatives list.") final-name packaging source-dir test-source-dir build-dir - modules dep-jars load-ts) @@ -265,9 +264,22 @@ module file." (projects (javaimp--maven-xml-extract-projects xml-tree)) (modules (mapcar #'javaimp--maven-xml-parse-project projects)) ;; first module is always root - (tree (javaimp--maven-build-tree (car modules) nil modules file))) - (if tree - (push tree javaimp-project-forest))) + (tree (javaimp--maven-build-tree (car modules) nil modules))) + (when tree + ;; Set files in a separate step after building the tree because "real" + ;; parent of a child (given by ) does not necessary contains the + ;; child in its . This is rare, but happens. + (javaimp--maven-fill-modules-files file tree) + ;; check that no :file slot is empty + (let ((modules-without-files + (mapcar #'javaimp-node-contents + (javaimp--select-nodes-from-tree + tree (lambda (m) + (null (javaimp-module-file m))) + (if modules-without-files + (error "Cannot find file for module(s): %s" +(mapconcat #'javaimp-module-id modules-without-files ", " + (push tree javaimp-project-forest))) (message "Loaded tree for %s" file))) @@ -307,7 +319,8 @@ of elements" (make-javaimp-module :id (javaimp--maven-xml-extract-id project) :parent-id (javaimp--maven-xml-extract-id (javaimp--xml-child 'parent project)) - ;; element does not contain pom file path (we set :file slot later) + ;; element does not contain pom file path, so we set this slot + ;; later, see javaimp--maven-fill-modules-files :file nil :final-name (javaimp--xml-first-child (javaimp--xml-child 'finalName build-elt)) @@ -324,9 +337,6 @@ of elements" :build-dir (file-name-as-directory (javaimp-cygpath-convert-maybe (javaimp--xml-first-child (javaimp--xml-child 'directory build-elt - :modules (mapcar (lambda (module-elt) - (javaimp--xml-first-child module-elt)) - (javaimp--xml-children (javaimp--xml-child 'modules project) 'module)) :dep-jars nil ; dep-jars is initialized lazily on demand :load-ts (current-time @@ -336,26 +346,6 @@ of elements" :artifact (javaimp--xml-first-child (javaimp--xml-child 'artifactId elt)) :version (javaimp--xml-first-child (javaimp--xml-child 'version elt -(defun javaimp--maven-xml-file-matches (file id parent-id) - (let* ((xml-tree (with-temp-buffer -(insert-file-contents file) -(xml-parse-region (point-min) (point-max -(project-elt (assq 'project xml-tree)) -(tested-id (javaimp--maven-xml-extract-id project-elt)) -(tested-parent-id (javaimp--maven-xml-extract-id (assq 'parent project-elt -;; seems that the only mandatory component in tested ids is artifact, while -;; group and version may be inherited and thus not presented in pom.xml -(let ((test (if (or (null (javaimp-id-group tested-id)) - (null (javaimp-id-version tested-id)) - (null (javaimp-id-group tested-parent-id)) - (null (javaimp-id-version tested-parent-id))) - (progn - (message "File %s contains incomplete id, using lax match" file) - (lambda (first second) - (equal (javaimp-id-artifact first) (javaimp-id-artifact second - #'equal))) - (and (funcall test tested-id id) - (funcall test tested-parent-id parent-id) ;; Maven routines @@ -380,54 +370,62 @@ the temporar
[elpa] javaimp_devel ed2f60f: Add 'javaimp-get-all-modules'
branch: javaimp_devel commit ed2f60f669ebb317fabef5b8b26386cdfacfcc33 Author: Filipp Gunbin Commit: Filipp Gunbin Add 'javaimp-get-all-modules' --- packages/javaimp/javaimp.el | 46 +- 1 files changed, 27 insertions(+), 19 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index f05629a..93d35f9 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -192,17 +192,16 @@ Only top-level classes are included.") (car (cddr el))) +;;; Data representation + ;; FIXME: use cl-defstruct! -;; A module is represented as a list: `(ARTIFACT POM-FILE SOURCE-DIR -;; TEST-SOURCE-DIR BUILD-DIR POM-FILE-MOD-TS PARENT PARENT-TS)'. +;; Module -(defsubst javaimp-make-mod (artifact pom-file source-dir -test-source-dir build-dir -pom-file-mod-ts jars-list -parent parent-ts) +(defsubst javaimp-make-mod (artifact pom-file source-dir test-source-dir build-dir +pom-file-mod-ts jars-list parent parent-ts final-name) (list artifact pom-file source-dir test-source-dir build-dir - pom-file-mod-ts jars-list parent parent-ts)) + pom-file-mod-ts jars-list parent parent-ts final-name)) (defsubst javaimp-get-mod-artifact (module) (nth 0 module)) @@ -241,8 +240,12 @@ Only top-level classes are included.") (defsubst javaimp-set-mod-parent-ts (module value) (setcar (nthcdr 8 module) value)) - -;; An artifact is represented as a list: (GROUP-ID ARTIFACT-ID VERSION). +(defsubst javaimp-get-mod-final-name (module) + (nth 9 module)) +(defsubst javaimp-set-mod-final-name (module value) + (setcar (nthcdr 9 module) value)) + +;; Artifact (defsubst javaimp-make-artifact (group-id artifact-id version) (list group-id artifact-id version)) @@ -266,8 +269,7 @@ Only top-level classes are included.") (apply #'javaimp-make-artifact (split-string artifact ":"))) - -;; A jar is represented as a list: `(JAR-PATH JAR-MOD-TS . CLASSES-LIST). +;; JAR (defsubst javaimp-make-jar (jar-path jar-mod-ts classes-list) (cons jar-path (cons jar-mod-ts classes-list))) @@ -392,6 +394,7 @@ with POM" (javaimp-extract-artifact-info (javaimp-xml-child 'parent project-elt)) nil ;parent-ts will be set later + (javaimp-xml-first-child javaimp-xml-child 'finalName 'build-elt) ))) project-elts)) @@ -604,6 +607,19 @@ directory" (equal (javaimp-get-mod-artifact mod) artifact +;;; Some functions for use in other programs + +(defun javaimp-get-source-directories () + (apply #'seq-concatenate 'list +(mapcar (lambda (root) + (mapcar #'javaimp-get-mod-source-dir (cdr root))) +javaimp-maven-root-modules))) + +(defun javaimp-get-all-modules () + "Returns flat list of all child modules." + (append (mapcar #'cdr roots))) + + ;;; Adding and organizing imports ;;;###autoload @@ -767,14 +783,6 @@ argument is a list of additional classes to import." (javaimp-forget-all-visited-modules) (javaimp-invalidate-jar-classes-cache)) -;; Some functions which can be used in other modules - -(defun javaimp-get-source-directories () - (apply #'seq-concatenate 'list -(mapcar (lambda (root) - (mapcar #'javaimp-get-mod-source-dir (cdr root))) -javaimp-maven-root-modules))) - (provide 'javaimp) ;;; javaimp.el ends here
[elpa] javaimp_devel 5e69ed1: javaimp: Rewrite Maven output parsing code
branch: javaimp_devel commit 5e69ed13eec3fa055e86cf91f789ca167360b6ac Author: Filipp Gunbin Commit: Filipp Gunbin javaimp: Rewrite Maven output parsing code --- packages/javaimp/javaimp.el | 350 --- 1 files changed, 193 insertions(+), 157 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index df402ce..f05629a 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -1,6 +1,6 @@ ;;; javaimp.el --- Add and reorder Java import statements in Maven projects -*- lexical-binding: t; -*- -;; Copyright (C) 2014, 2015 Free Software Foundation, Inc. +;; Copyright (C) 2014, 2015, 2016 Free Software Foundation, Inc. ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin @@ -66,11 +66,12 @@ ;; which are not matched by any regexp in that variable are assigned a ;; default order defined by `javaimp-import-default-order' (50 by default). ;; -;; Sample setup (put this into your .emacs): +;; Sample .emacs initialization: ;; ;; (require 'javaimp) ;; -;; (add-to-list 'javaimp-import-group-alist '("\\`\\(ru\\.yota\\.\\|tv\\.okko\\.\\)" . 80)) +;; (add-to-list 'javaimp-import-group-alist +;; '("\\`\\(my\\.company\\.\\|my\\.company2\\.\\)" . 80)) ;; ;; (setq javaimp-jdk-home (getenv "JAVA_HOME")) ;; (setq javaimp-include-current-project-classes t) @@ -82,19 +83,28 @@ ;; (local-set-key "\C-co" 'javaimp-organize-imports))) ;; ;; -;; TODO: +;; TODO before version 1.0: ;; -;; Support adding static imports by giving a prefix argument to +;; - correct submodule tree for each top-level project (now top-level projects +;; hold linear submodule list and this prevents modification checking for parent +;; poms). If a project doesn't have any children, then it should be in the list +;; by itself. +;; +;; - cl-defstruct for data +;; +;; Other: +;; +;; - support adding static imports by giving a prefix argument to ;; `javaimp-add-import'. ;; -;; Use functions `cygwin-convert-file-name-from-windows' and +;; - use functions `cygwin-convert-file-name-from-windows' and ;; `cygwin-convert-file-name-to-windows' when they are available instead of -;; calling `cygpath'. See -;; https://cygwin.com/ml/cygwin/2013-03/msg00228.html. - +;; calling `cygpath'. See https://cygwin.com/ml/cygwin/2013-03/msg00228.html. ;;; Code: +(require 'seq) + ;;; User options @@ -163,7 +173,7 @@ Only top-level classes are included.") (defconst javaimp-debug-buf-name "*javaimp-debug*") -;;; Dealing with XML +;;; XML routines (defun javaimp-xml-child-list (xml-tree child-name) "Returns list of children of XML-TREE filtered by CHILD-NAME" @@ -182,8 +192,10 @@ Only top-level classes are included.") (car (cddr el))) -;; A module is represented as a list of the form `(ARTIFACT POM-FILE -;; SOURCE-DIR TEST-SOURCE-DIR BUILD-DIR POM-FILE-MOD-TS PARENT PARENT-TS)'. +;; FIXME: use cl-defstruct! + +;; A module is represented as a list: `(ARTIFACT POM-FILE SOURCE-DIR +;; TEST-SOURCE-DIR BUILD-DIR POM-FILE-MOD-TS PARENT PARENT-TS)'. (defsubst javaimp-make-mod (artifact pom-file source-dir test-source-dir build-dir @@ -197,6 +209,8 @@ Only top-level classes are included.") (defsubst javaimp-get-mod-pom-file (module) (nth 1 module)) +(defsubst javaimp-set-mod-pom-file (module value) + (setcar (nthcdr 1 module) value)) (defsubst javaimp-get-mod-source-dir (module) (nth 2 module)) @@ -230,18 +244,16 @@ Only top-level classes are included.") ;; An artifact is represented as a list: (GROUP-ID ARTIFACT-ID VERSION). -;; FIXME: use cl-defstruct! - -(defun javaimp-make-artifact (group-id artifact-id version) +(defsubst javaimp-make-artifact (group-id artifact-id version) (list group-id artifact-id version)) -(defun javaimp-artifact-group-id (artifact) +(defsubst javaimp-artifact-group-id (artifact) (car artifact)) -(defun javaimp-artifact-artifact-id (artifact) +(defsubst javaimp-artifact-artifact-id (artifact) (cadr artifact)) -(defun javaimp-artifact-version (artifact) +(defsubst javaimp-artifact-version (artifact) (nth 2 artifact)) (defun javaimp-artifact-to-string (artifact) @@ -255,7 +267,7 @@ Only top-level classes are included.") -;; A jar is represented as follows: `(JAR-PATH JAR-MOD-TS . CLASSES-LIST). +;; A jar is represented as a list: `(JAR-PATH JAR-MOD-TS . CLASSES-LIST). (defsubst javaimp-make-jar (jar-path jar-mod-ts classes-list) (cons jar-path (cons jar-mod-ts classes-list))) @@ -276,150 +288,168 @@ Only top-level classes are included.") (setcdr (cdr jar) value)) -;;; Loading maven projects tree +;;; Loading Maven projects tree ;;;###autoload (defun javaimp-maven-visit-root (path) "Loads all modules startin
[elpa] branch javaimp_devel created (now 5e69ed1)
fgunbin pushed a change to branch javaimp_devel. at 5e69ed1 javaimp: Rewrite Maven output parsing code This branch includes the following new commits: new 5e69ed1 javaimp: Rewrite Maven output parsing code
[elpa] javaimp_devel edfc9ef: Fixes
branch: javaimp_devel commit edfc9ef1e7290ca3078dbd063bf3bf419ff8e620 Author: Filipp Gunbin Commit: Filipp Gunbin Fixes --- packages/javaimp/javaimp.el | 24 ++-- 1 files changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index 93d35f9..fcca837 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -100,6 +100,9 @@ ;; - use functions `cygwin-convert-file-name-from-windows' and ;; `cygwin-convert-file-name-to-windows' when they are available instead of ;; calling `cygpath'. See https://cygwin.com/ml/cygwin/2013-03/msg00228.html. +;; +;; - include into module info +;; ;;; Code: @@ -348,7 +351,7 @@ with POM" (defun javaimp-fill-pom-file-paths (modules pom) "Subroutine of `javaimp-maven-load-module-tree'" (let ((artifact-alist (javaimp-traverse-pom-tree (list pom -(dolist (module modules-alist) +(dolist (module modules) (let* ((artifact (javaimp-get-mod-artifact module)) (path (cdr (or (seq-find (lambda (el) @@ -370,8 +373,8 @@ with POM" (defun javaimp-cygpath-convert-maybe (path) (if (eq system-type 'cygwin) - (car (process-lines javaimp-cygpath-program "-u" source-dir)) -source-dir)) + (car (process-lines javaimp-cygpath-program "-u" path)) +path)) (defun javaimp-maven-process-projects (projects-elts) (mapcar @@ -394,9 +397,9 @@ with POM" (javaimp-extract-artifact-info (javaimp-xml-child 'parent project-elt)) nil ;parent-ts will be set later - (javaimp-xml-first-child javaimp-xml-child 'finalName 'build-elt) + (javaimp-xml-first-child (javaimp-xml-child 'finalName build-elt)) ))) - project-elts)) + projects-elts)) (defun javaimp-extract-submodules-paths (project-elt) (let* ((modules-elt (javaimp-xml-child 'modules project-elt)) @@ -610,14 +613,15 @@ directory" ;;; Some functions for use in other programs (defun javaimp-get-source-directories () - (apply #'seq-concatenate 'list -(mapcar (lambda (root) - (mapcar #'javaimp-get-mod-source-dir (cdr root))) -javaimp-maven-root-modules))) + (append + (mapcar (lambda (root) +(mapcar #'javaimp-get-mod-source-dir (cdr root))) + javaimp-maven-root-modules))) (defun javaimp-get-all-modules () "Returns flat list of all child modules." - (append (mapcar #'cdr roots))) + (apply #'seq-concatenate 'list +(mapcar #'cdr javaimp-maven-root-modules))) ;;; Adding and organizing imports
[elpa] javaimp_devel 4b918c0: in progress
branch: javaimp_devel commit 4b918c0bc257c6d3f608c7514051826051b0cc42 Author: Filipp Gunbin Commit: Filipp Gunbin in progress --- packages/javaimp/javaimp.el | 371 ++- 1 files changed, 152 insertions(+), 219 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index fcca837..a2ab7c4 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -12,7 +12,7 @@ ;; Allows to manage Java import statements in Maven projects. ;; ;; Quick start: customize `javaimp-import-group-alist', `javaimp-jdk-home' -;; and call `javaimp-maven-visit-root', then in a Java buffer visiting a +;; and call `javaimp-maven-visit-project', then in a Java buffer visiting a ;; file under that module or one of its submodules call ;; `javaimp-organize-imports' or `javaimp-add-import'. `javaimp-add-import' ;; will provide you a helpful completion, and the default value (the one @@ -56,7 +56,7 @@ ;; ;; Details on commands. ;; -;; `javaimp-maven-visit-root' is the first command you should issue to +;; `javaimp-maven-visit-project' is the first command you should issue to ;; use this module. It reads the pom structure recursively and records ;; which files belong to which module. Maven help:effective-pom command is ;; used to do that. @@ -74,7 +74,7 @@ ;; '("\\`\\(my\\.company\\.\\|my\\.company2\\.\\)" . 80)) ;; ;; (setq javaimp-jdk-home (getenv "JAVA_HOME")) -;; (setq javaimp-include-current-project-classes t) +;; (setq javaimp-include-current-module-classes t) ;; (setq javaimp-additional-source-dirs '("generated-sources/thrift")) ;; ;; (add-hook 'java-mode-hook @@ -85,10 +85,10 @@ ;; ;; TODO before version 1.0: ;; -;; - correct submodule tree for each top-level project (now top-level projects -;; hold linear submodule list and this prevents modification checking for parent -;; poms). If a project doesn't have any children, then it should be in the list -;; by itself. +;; - correct submodule tree for each top-level project (now top-level +;; projects hold linear submodule list and this prevents modification +;; checking for parent poms). Each project should represented as (NAME +;; OBJECT . CHILDREN). ;; ;; - cl-defstruct for data ;; @@ -102,17 +102,26 @@ ;; calling `cygpath'. See https://cygwin.com/ml/cygwin/2013-03/msg00228.html. ;; ;; - include into module info +;; +;; - each module's parent should be set according to its "parent" node +;; +;; - when a module has a parent but do not inherits, its jars are not added +;; +;; - save/restore state +;; +;; - API functions should check pom file modifications and refresh if needed ;; ;;; Code: +(require 'cl-macs) (require 'seq) ;;; User options (defgroup javaimp () - "Add and reorder Java import statements in Maven projects.") + "Add and reorder Java import statements in Maven projects") (defcustom javaimp-import-group-alist '(("\\`javax?\\." . 10)) "Specifies how to group classes and how to order resulting @@ -130,7 +139,10 @@ The order of classes which were not matched is defined by `javaimp-import-group-alist'") (defcustom javaimp-jdk-home nil - "Path to the JDK") + "Path to the JDK. If you have JAVA_HOME environment variable +set up, this variable can be set like this: + +(setq javaimp-jdk-home (getenv \"JAVA_HOME\"))") (defcustom javaimp-additional-source-dirs nil "List of directories where additional (e.g. generated) @@ -152,13 +164,14 @@ supported yet.") (defcustom javaimp-mvn-program "mvn" "Path to the `mvn' program") -(defcustom javaimp-cygpath-program "cygpath" +(defcustom javaimp-cygpath-program + (if (eq system-type 'cygwin) "cygpath") "Path to the `cygpath' program") (defcustom javaimp-jar-program "jar" "Path to the `jar' program") -(defcustom javaimp-include-current-project-classes t +(defcustom javaimp-include-current-module-classes t "If non-nil, current project's classes are included into completion alternatives. @@ -167,11 +180,11 @@ Only top-level classes are included.") ;;; Variables and constants -(defvar javaimp-maven-root-modules nil - "Loaded root Maven modules") +(defvar javaimp-project-forest nil + "Visited projects") -(defvar javaimp-jar-classes-cache nil - "Jar classes cache") +(defvar javaimp-jar-cache nil + "Cache for jar contents") (defconst javaimp-debug-buf-name "*javaimp-debug*") @@ -195,121 +208,60 @@ Only top-level classes are included.") (car (cddr el))) -;;; Data representation - -;; FIXME: use cl-defstruct! - -;; Module - -(defsubst javaimp-make-mod (
[elpa] javaimp_devel 327e1ba: in progress
branch: javaimp_devel commit 327e1bacb65b9fc9029022454f733f27a25cde4c Author: Filipp Gunbin Commit: Filipp Gunbin in progress --- packages/javaimp/javaimp.el | 240 ++ 1 files changed, 148 insertions(+), 92 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index a2ab7c4..6a50e76 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -208,13 +208,21 @@ Only top-level classes are included.") (car (cddr el))) +;; Cygwin + +(defun javaimp-cygpath-convert-maybe (path) + (if (eq system-type 'cygwin) + (car (process-lines javaimp-cygpath-program "-u" path)) +path)) + + ;; Structs (cl-defstruct javaimp-node parent children contents) (cl-defstruct javaimp-module - id file file-ts final-name + id parent-id file file-ts final-name packaging source-dir test-source-dir build-dir dep-jars) @@ -232,9 +240,9 @@ Only top-level classes are included.") file file-ts classes) -;;; Loading Maven projects +;;; Maven -;; TODO if it's already there? +;; TODO what if it's already there? ;;;###autoload (defun javaimp-maven-visit-project (path) @@ -245,28 +253,42 @@ directory containing pom.xml." (concat (file-name-as-directory path) "pom.xml" (unless (file-readable-p file) (error "Cannot read file: %s" file)) -(push (javaimp-maven-load-tree file) javaimp-project-forest) +(let ((tree (javaimp--maven-load-tree file))) + (if tree + (push tree javaimp-project-forest))) (message "Loaded tree for %s" file))) -(defun javaimp-maven-load-tree (file) - ;; TODO - "Creates a tree of Maven projects starting from FILE" - (let* ((effective-pom (javaimp-parse-effective-pom pom)) -(project-elts - (cond ((assq 'projects effective-pom) ;project contains tag(s) -(javaimp-xml-child-list (assq 'projects effective-pom) 'project)) - ((assq 'project effective-pom) ;single-module project -(list (assq 'project effective-pom))) - (t -(error "Cannot find projects in XML tree" -(modules-alist (javaimp-maven-process-projects project-elts))) -(javaimp-fill-pom-file-paths modules-alist pom) -modules-alist)) - -(defun javaimp-parse-effective-pom (pom) +(defun javaimp--maven-load-tree (file) + "Invokes `mvn help:effective-pom' on FILE and using its output +creates a tree of Maven projects starting from FILE. Children +which link to the parent via the element are inheriting +children and are also included. Subordinate modules with no +inheritance are not included." + (let ((xml-tree (javaimp--maven-read-effective-pom file))) +(cond ((assq 'project xml-tree) + ;; no real children + (let ((project-elt (assq 'project xml-tree))) +(message "Independent submodules: %s" + (mapconcat #'javaimp-xml-first-child +(javaimp--maven-get-module-elts project-elt) +", ")) +(let ((module (javaimp--maven-parse-module project-elt))) + (javaimp--build-tree (javaimp-module-id module) nil (list module) + ((assq 'projects xml-tree) + ;; we have are inheriting children - they and their children, if + ;; any, are listed in a linear list + (let* ((project-elts (javaimp-xml-child-list +(assq 'projects xml-tree) 'project)) + (all-modules (mapcar #'javaimp--maven-parse-module project-elts))) +(javaimp--build-tree (javaimp-module-id (car all-modules)) nil all-modules))) + (t + ;; neither nor - error + (error "Invalid `help:effective-pom' output") + +(defun javaimp--maven-read-effective-pom (pom) "Calls `mvn help:effective:pom and returns XML parse tree" (message "Loading root pom %s..." pom) - (javaimp-call-mvn + (javaimp--maven-call pom "help:effective-pom" (lambda () (let ((xml-start-pos @@ -285,44 +307,45 @@ directory containing pom.xml." (match-end 0) (xml-parse-region xml-start-pos xml-end-pos) +(defun javaimp--maven-call (pom-file target handler) + "Runs Maven target TARGET on POM-FILE, then calls HANDLER in +the temporary buffer and returns its result" + (message "Calling \"mvn %s\" on pom: %s" target pom-file) + (with-temp-buffer +(let* ((pom-file (javaimp-cygpath-convert-maybe pom-file)) + (status + ;; FIXME check Maven output on Gnu/Linux + (let ((coding-system-for-read + (if (eq system-type 'cygwin) '
[elpa] javaimp_devel updated (327e1ba -> 0d6cb9e)
fgunbin pushed a change to branch javaimp_devel. from 327e1ba in progress new 2f8450a in progress new 0d6cb9e in progress Summary of changes: packages/javaimp/javaimp.el | 743 ++- 1 files changed, 376 insertions(+), 367 deletions(-)
[elpa] javaimp_devel 0d6cb9e 2/2: in progress
branch: javaimp_devel commit 0d6cb9e7b7d4082408db66df8072e5aac3f4b528 Author: Filipp Gunbin Commit: Filipp Gunbin in progress --- packages/javaimp/javaimp.el | 452 +++ 1 files changed, 241 insertions(+), 211 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index 3bf11e3..233d7ae 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -4,7 +4,7 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.6 +;; Version: 0.7 ;; Keywords: java, maven, programming ;;; Commentary: @@ -46,8 +46,8 @@ ;; If you make some changes which change project hierarchy, you should ;; re-visit the parent again with `javaimp-maven-visit-project'. ;; -;; May work unreliable with inner classes, but you can always import -;; top-level class and use qualified name. +;; Currently inner classes are filtered out from completion alternatives. +;; You can always import top-level class and use qualified name. ;; ;; User options: ;; @@ -140,6 +140,7 @@ (require 'cl-macs) (require 'seq) +(require 'xml) ;; User options @@ -205,8 +206,9 @@ to the completion alternatives list.") (defvar javaimp-project-forest nil "Visited projects") -(defvar javaimp-jar-cache nil - "Cache for jar contents") +(defvar javaimp-cached-jars nil + "Alist of cached jars. Each element is of the form (FILE + . CACHED-JAR).") (defconst javaimp-debug-buf-name "*javaimp-debug*") @@ -216,10 +218,9 @@ to the completion alternatives list.") parent children contents) (cl-defstruct javaimp-module - id parent-id file file-ts final-name packaging - source-dir test-source-dir build-dir - modules - dep-jars) + id parent-id file final-name packaging + source-dir test-source-dir build-dir modules + dep-jars load-ts) (defun javaimp-print-id (id) (format "%s:%s:%s" @@ -231,12 +232,13 @@ to the completion alternatives list.") (:print-function #'javaimp-print-id)) group artifact version) -(cl-defstruct javaimp-jar - file file-ts classes) +(cl-defstruct javaimp-cached-jar + file read-ts classes) +;; Utilities -(defun javaimp-xml-child-list (xml-tree child-name) +(defun javaimp--xml-child-list (xml-tree child-name) "Returns list of children of XML-TREE filtered by CHILD-NAME" (let (result) (dolist (child (cddr xml-tree) result) @@ -244,18 +246,42 @@ to the completion alternatives list.") (eq (car child) child-name)) (push child result) -(defun javaimp-xml-child (name el) +(defun javaimp--xml-child (name el) "Returns a child of EL named by symbol NAME" (assq name (cddr el))) -(defun javaimp-xml-first-child (el) +(defun javaimp--xml-first-child (el) "Returns a first child of EL" (car (cddr el))) +(defun javaimp--get-file-ts (file) + (nth 5 (file-attributes file))) -(defun javaimp-cygpath-convert-maybe (path) - (if (eq system-type 'cygwin) - (car (process-lines javaimp-cygpath-program "-u" path)) +(defun javaimp--get-jdk-jars () + (if javaimp-jdk-home + (let ((jre-lib-dir +(concat (file-name-as-directory javaimp-jdk-home) +(file-name-as-directory "jre") +(file-name-as-directory "lib" + (directory-files jre-lib-dir t "\\.jar\\'" + +(defun javaimp-cygpath-convert-maybe (path &optional mode is-really-path) + "On Cygwin, converts PATH using cygpath according to MODE and +IS-REALLY-PATH. If MODE is `unix' (the default), adds -u switch. +If MODE is `windows', adds -m switch. If `is-really-path' is +non-nil, adds `-p' switch. On other systems, PATH is returned +unchanged." + (if (eq system-type 'cygwin) + (progn + (unless mode (setq mode 'unix)) + (let (args) + (push (cond ((eq mode 'unix) "-u") + ((eq mode 'windows) "-m") + (t (error "Invalid mode: %s" mode))) + args) + (and is-really-path (push "-p" args)) + (push path args) + (car (apply #'process-lines javaimp-cygpath-program args path)) @@ -280,6 +306,9 @@ directory containing pom.xml." ;; TODO file should start to sink down from there; at each step append directory ;; from to it + +;; Maven XML routines + (defun javaimp--maven-xml-load-tree (file) "Invokes `mvn help:effective-pom' on FILE and using its output creates a tree of Maven projects starting from FILE. Children @@ -290,18 +319,18 @@ inheritance are not included." (cond ((assq 'project xml-tree) ;; no real children (let ((project-elt (assq 'project xml-tree)) -
[elpa] javaimp_devel 2f8450a 1/2: in progress
branch: javaimp_devel commit 2f8450a2b4cdf0297b11a929aeeb90753506d7d9 Author: Filipp Gunbin Commit: Filipp Gunbin in progress --- packages/javaimp/javaimp.el | 325 --- 1 files changed, 152 insertions(+), 173 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index 6a50e76..3bf11e3 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -11,26 +11,45 @@ ;; Allows to manage Java import statements in Maven projects. ;; -;; Quick start: customize `javaimp-import-group-alist', `javaimp-jdk-home' -;; and call `javaimp-maven-visit-project', then in a Java buffer visiting a -;; file under that module or one of its submodules call -;; `javaimp-organize-imports' or `javaimp-add-import'. `javaimp-add-import' -;; will provide you a helpful completion, and the default value (the one -;; you'll get if you hit `M-n' in the minibuffer) is the symbol under point, -;; so usually it's enough to hit `M-n', then add some starting letters of a -;; package and hit `TAB'. The module does not add all needed imports -;; automatically! It only helps you to quickly add imports when stepping -;; through compilation errors. +;; Quick start: +;; +;; - customize `javaimp-import-group-alist' +;; +;; - call `javaimp-maven-visit-project', giving it the top-level project +;; directory where pom.xml resides +;; +;; Then in a Java buffer visiting a file under that project or one of its +;; submodules call `javaimp-organize-imports' or `javaimp-add-import'. +;; +;; +;; Details: +;; +;; `javaimp-add-import' will provide you a helpful completion with the list +;; of classes taken from this module's dependencies. Completion default +;; value (the one you'll get if you hit `M-n' in the minibuffer) is the +;; symbol under point, so usually it's enough to hit `M-n', then add some +;; starting letters of a package and hit `TAB'. +;; +;; This module does not add all needed imports automatically! It only helps +;; you to quickly add imports when stepping through compilation errors. ;; ;; If Maven failed, you can see its output in the buffer named by ;; `javaimp-debug-buf-name' (default is "*javaimp-debug*"). ;; ;; Contents of jar files and Maven project structures (pom.xml) are cached, ;; so usually only first command should take a considerable amount of time -;; to complete. When it is detected that a particular jar or pom.xml file's -;; timestamp changed, it is re-read and cache is updated. +;; to complete. If a modules's pom.xml or any of its parents pom.xml was +;; changed (modification timestamp is checked), `mvn +;; dependency:build-classpath' is re-run on the current module. If a jar +;; file was changed, its contents is reloaded. +;; +;; If you make some changes which change project hierarchy, you should +;; re-visit the parent again with `javaimp-maven-visit-project'. +;; +;; May work unreliable with inner classes, but you can always import +;; top-level class and use qualified name. ;; -;; Details on variables. +;; User options: ;; ;; `javaimp-import-group-alist' defines the order of import statement ;; groups. By default java.* and javax.* imports are assigned an order of @@ -38,33 +57,40 @@ ;; project's imports typically should come after, so the sample config below ;; sets 80 for them. ;; -;; `javaimp-jdk-home' is a path for JDK. It is used to scan JDK jars. -;; Usually you will need to set this. +;; `javaimp-jdk-home' is a path for JDK. It is used to scan JDK jars. By +;; default, it is set from the JAVA_HOME environment variable. ;; ;; `javaimp-additional-source-dirs' is a list specifying directories where ;; additional (e.g. generated) source files reside. Each directory is a ;; relative path from ${project.build.directory} project property value. ;; -;; `javaimp-mvn-program' defines path of the `mvn' program. Use if it's -;; not on `exec-path'. +;; `javaimp-mvn-program' defines path to the `mvn' program. Customize it +;; if `mvn' is not on `exec-path'. ;; -;; `javaimp-cygpath-program' defines path of the `cygpath' program (applies -;; to Cygwin only, of course). Use if it's not on `exec-path'. +;; `javaimp-cygpath-program' defines path to the `cygpath' program (Cygwin +;; only). Customize it if `cygpath' is not on `exec-path' ;; -;; `javaimp-jar-program' defines path of the `jar' program. Use if it's -;; not on `exec-path'. +;; `javaimp-jar-program' defines path to the `jar' program. Customize it +;; if `jar' is not on `exec-path'. ;; -;; Details on commands. +;; Commands: ;; -;; `javaimp-maven-visit-project' is the first command you should issue to -;; use this modul
[elpa] master f213965: packages/javaimp: full rewrite
branch: master commit f213965b93b982d406404529503ed3346c983dac Author: Filipp Gunbin Commit: Filipp Gunbin packages/javaimp: full rewrite * Use defstruct's from cl-lib. * Parse pom.xml structure into tree for correct updates. * Clean up docs. * Simplify code. --- packages/javaimp/javaimp.el | 1200 +-- 1 files changed, 597 insertions(+), 603 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index df402ce..a32a9a0 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -1,79 +1,56 @@ ;;; javaimp.el --- Add and reorder Java import statements in Maven projects -*- lexical-binding: t; -*- -;; Copyright (C) 2014, 2015 Free Software Foundation, Inc. +;; Copyright (C) 2014, 2015, 2016 Free Software Foundation, Inc. ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.6 +;; Version: 0.7 ;; Keywords: java, maven, programming ;;; Commentary: ;; Allows to manage Java import statements in Maven projects. ;; -;; Quick start: customize `javaimp-import-group-alist', `javaimp-jdk-home' -;; and call `javaimp-maven-visit-root', then in a Java buffer visiting a -;; file under that module or one of its submodules call -;; `javaimp-organize-imports' or `javaimp-add-import'. `javaimp-add-import' -;; will provide you a helpful completion, and the default value (the one -;; you'll get if you hit `M-n' in the minibuffer) is the symbol under point, -;; so usually it's enough to hit `M-n', then add some starting letters of a -;; package and hit `TAB'. The module does not add all needed imports -;; automatically! It only helps you to quickly add imports when stepping -;; through compilation errors. +;; Quick start: ;; +;; - customize `javaimp-import-group-alist' +;; +;; - call `javaimp-maven-visit-project', giving it the top-level project +;; directory where pom.xml resides +;; +;; Then in a Java buffer visiting a file under that project or one of its +;; submodules call `javaimp-organize-imports' or `javaimp-add-import'. +;; +;; This module does not add all needed imports automatically! It only helps +;; you to quickly add imports when stepping through compilation errors. +;; +;; +;; Some details: +;; ;; If Maven failed, you can see its output in the buffer named by ;; `javaimp-debug-buf-name' (default is "*javaimp-debug*"). ;; ;; Contents of jar files and Maven project structures (pom.xml) are cached, ;; so usually only first command should take a considerable amount of time -;; to complete. When it is detected that a particular jar or pom.xml file's -;; timestamp changed, it is re-read and cache is updated. +;; to complete. If a modules's pom.xml or any of its parents' pom.xml was +;; changed (i.e. any of them was modified after information was loaded), +;; `mvn dependency:build-classpath' is re-run on the current module. If a +;; jar file was changed, its contents are re-read. ;; -;; Details on variables. -;; -;; `javaimp-import-group-alist' defines the order of import statement -;; groups. By default java.* and javax.* imports are assigned an order of -;; 10, which is low, so it puts those imports at the beginning. Your -;; project's imports typically should come after, so the sample config below -;; sets 80 for them. -;; -;; `javaimp-jdk-home' is a path for JDK. It is used to scan JDK jars. -;; Usually you will need to set this. +;; If you make some changes which change project hierarchy, you should +;; re-visit the parent again with `javaimp-maven-visit-project'. ;; -;; `javaimp-additional-source-dirs' is a list specifying directories where -;; additional (e.g. generated) source files reside. Each directory is a -;; relative path from ${project.build.directory} project property value. +;; Currently inner classes are filtered out from completion alternatives. +;; You can always import top-level class and use qualified name. ;; -;; `javaimp-mvn-program' defines path of the `mvn' program. Use if it's -;; not on `exec-path'. -;; -;; `javaimp-cygpath-program' defines path of the `cygpath' program (applies -;; to Cygwin only, of course). Use if it's not on `exec-path'. -;; -;; `javaimp-jar-program' defines path of the `jar' program. Use if it's -;; not on `exec-path'. -;; -;; Details on commands. ;; -;; `javaimp-maven-visit-root' is the first command you should issue to -;; use this module. It reads the pom structure recursively and records -;; which files belong to which module. Maven help:effective-pom command is -;; used to do that. -;; -;; `javaimp-organize-imports' groups import statement and writes those -;; group according to the value of `javaimp-import-group-alist'. Imports -;; which are n
[elpa] master fec1140: packages/javaimp: temporary revert version
branch: master commit fec1140e0a0b2da610627ff0b8b470846bb39d7c Author: Filipp Gunbin Commit: Filipp Gunbin packages/javaimp: temporary revert version --- packages/javaimp/javaimp.el |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index a32a9a0..5f13b24 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -4,7 +4,7 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.7 +;; Version: 0.6 ;; Keywords: java, maven, programming ;;; Commentary:
[elpa] branch javaimp_devel deleted (was 0d6cb9e)
fgunbin pushed a change to branch javaimp_devel. was 0d6cb9e in progress This change permanently discards the following revisions: discards 0d6cb9e in progress discards 2f8450a in progress discards 327e1ba in progress discards 4b918c0 in progress discards edfc9ef Fixes discards ed2f60f Add 'javaimp-get-all-modules' discards 5e69ed1 javaimp: Rewrite Maven output parsing code
[elpa] master 3e02274: packages/javaimp: cosmetic fixes
branch: master commit 3e02274e5f8bfcf34f89de6ec7d2e55bce32 Author: Filipp Gunbin Commit: Filipp Gunbin packages/javaimp: cosmetic fixes --- packages/javaimp/javaimp.el | 149 +++ 1 files changed, 80 insertions(+), 69 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index 5f13b24..f44be4e 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -14,7 +14,6 @@ ;; Quick start: ;; ;; - customize `javaimp-import-group-alist' -;; ;; - call `javaimp-maven-visit-project', giving it the top-level project ;; directory where pom.xml resides ;; @@ -24,9 +23,8 @@ ;; This module does not add all needed imports automatically! It only helps ;; you to quickly add imports when stepping through compilation errors. ;; -;; ;; Some details: -;; +;; ;; If Maven failed, you can see its output in the buffer named by ;; `javaimp-debug-buf-name' (default is "*javaimp-debug*"). ;; @@ -42,34 +40,32 @@ ;; ;; Currently inner classes are filtered out from completion alternatives. ;; You can always import top-level class and use qualified name. -;; +;; ;; ;; Example of initialization: -;; +;; ;; (require 'javaimp) -;; +;; ;; (add-to-list 'javaimp-import-group-alist ;; '("\\`\\(my\\.company\\.\\|my\\.company2\\.\\)" . 80)) -;; +;; ;; (setq javaimp-additional-source-dirs '("generated-sources/thrift")) -;; +;; ;; (add-hook 'java-mode-hook ;; (lambda () ;; (local-set-key "\C-ci" 'javaimp-add-import) ;; (local-set-key "\C-co" 'javaimp-organize-imports))) -;; -;; +;; +;; ;; TODO: -;; +;; ;; - use functions `cygwin-convert-file-name-from-windows' and ;; `cygwin-convert-file-name-to-windows' when they are available instead of ;; calling `cygpath'. See https://cygwin.com/ml/cygwin/2013-03/msg00228.html. -;; ;; - save/restore state -;; ;; - `javaimp-add-import': without prefix arg narrow alternatives by local name; ;; with prefix arg include all classes in alternatives -;; +;; - types for defcustom ;;; Code: @@ -251,7 +247,7 @@ module file." (message "Loaded tree for %s" file))) -;; Maven XML routines +;; Maven XML routines (defun javaimp--maven-xml-load-tree (file) "Invokes `mvn help:effective-pom' on FILE and using its output @@ -499,7 +495,7 @@ the temporary buffer and returns its result" (message "Reading classes in file: %s" file) (with-temp-buffer (let ((coding-system-for-read (and (eq system-type 'cygwin) 'utf-8-dos))) - ;; On Cygwin, "jar" is a Windows program, so file path needs to be + ;; on cygwin, "jar" is a windows program, so file path needs to be ;; converted appropriately. (process-file javaimp-jar-program nil t nil ;; `jar' accepts commands/options as a single string @@ -514,57 +510,65 @@ the temporary buffer and returns its result" result -;; Some API functions - -(defun javaimp-get-all-modules () - (javaimp-select-nodes (lambda (module) t))) - -(defun javaimp-find-node (predicate) - (javaimp--find-in-forest javaimp-project-forest predicate)) +;; Tree search routines -(defun javaimp-select-nodes (predicate) - (javaimp--select-from-forest javaimp-project-forest predicate)) +(defun javaimp--find-node (predicate) + (javaimp--find-node-in-forest javaimp-project-forest predicate)) - -;; Tree search routines +(defun javaimp--select-nodes (predicate) + (javaimp--select-nodes-from-forest javaimp-project-forest predicate)) -(defun javaimp--find-in-forest (forest predicate) +(defun javaimp--find-node-in-forest (forest predicate) (catch 'found (dolist (tree forest) - (javaimp--find-node tree predicate + (javaimp--find-node-in-tree tree predicate -(defun javaimp--find-node (tree predicate) +(defun javaimp--find-node-in-tree (tree predicate) (if tree (progn (if (funcall predicate (javaimp-node-contents tree)) (throw 'found tree)) (dolist (child (javaimp-node-children tree)) - (javaimp--find-node child predicate) + (javaimp--find-node-in-tree child predicate) -(defun javaimp--select-from-forest (forest predicate) +(defun javaimp--select-nodes-from-forest (forest predicate) (apply #'seq-concatenate 'list (mapcar (lambda (tree) - (javaimp--select-nodes tree predicate)) + (javaimp--select-nodes-from-tree tree predicate)) forest))) -(defun javaimp--select-nodes (tree predicate) +(defun javaimp--select-nodes-from-tree (tree predicate) (if tree (append (if (funcall predicate (javaimp-node-contents tree)) (list tree)) (apply #
[elpa] master 9c6721f: packages/javaimp: whitespace/doc fixes
branch: master commit 9c6721f223b176c75bb442ccc0b953d392f7fca3 Author: Filipp Gunbin Commit: Filipp Gunbin packages/javaimp: whitespace/doc fixes --- packages/javaimp/javaimp.el | 65 +++--- 1 files changed, 36 insertions(+), 29 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index f44be4e..7cd1e3e 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -29,14 +29,11 @@ ;; `javaimp-debug-buf-name' (default is "*javaimp-debug*"). ;; ;; Contents of jar files and Maven project structures (pom.xml) are cached, -;; so usually only first command should take a considerable amount of time -;; to complete. If a modules's pom.xml or any of its parents' pom.xml was -;; changed (i.e. any of them was modified after information was loaded), -;; `mvn dependency:build-classpath' is re-run on the current module. If a -;; jar file was changed, its contents are re-read. -;; -;; If you make some changes which change project hierarchy, you should -;; re-visit the parent again with `javaimp-maven-visit-project'. +;; so usually only the first command should take a considerable amount of +;; time to complete. If a module's pom.xml or any of its parents' pom.xml +;; (within visited tree) was modified after information was loaded, `mvn +;; dependency:build-classpath' is re-run on the current module. If a jar +;; file was changed, its contents are re-read. ;; ;; Currently inner classes are filtered out from completion alternatives. ;; You can always import top-level class and use qualified name. @@ -61,11 +58,15 @@ ;; ;; - use functions `cygwin-convert-file-name-from-windows' and ;; `cygwin-convert-file-name-to-windows' when they are available instead of -;; calling `cygpath'. See https://cygwin.com/ml/cygwin/2013-03/msg00228.html. -;; - save/restore state +;; calling `cygpath'. See https://cygwin.com/ml/cygwin/2013-03/msg00228.html +;; +;; - save/restore state, on restore check if a root exists and delete it if +;; not +;; ;; - `javaimp-add-import': without prefix arg narrow alternatives by local name; ;; with prefix arg include all classes in alternatives -;; - types for defcustom +;; +;; - :type for defcustom ;;; Code: @@ -94,9 +95,10 @@ The order of classes which were not matched is defined by "Defines the order of classes which were not matched by `javaimp-import-group-alist'") -(defcustom javaimp-jdk-home (getenv "JAVA_HOME") - "Path to the JDK. It is used to find JDK jars to scan. By -default, it is set from the JAVA_HOME environment variable.") +(defcustom javaimp-java-home (getenv "JAVA_HOME") + "Path to the JDK. Directory jre/lib underneath this path is +searched for JDK libraries. By default, it is initialized from +the JAVA_HOME environment variable.") (defcustom javaimp-additional-source-dirs nil "List of directories where additional (e.g. generated) @@ -138,7 +140,7 @@ to the completion alternatives list.") ;; Variables and constants (defvar javaimp-project-forest nil - "Visited projects.") + "Visited projects") (defvar javaimp-cached-jars nil "Alist of cached jars. Each element is of the form (FILE @@ -189,12 +191,13 @@ to the completion alternatives list.") (nth 5 (file-attributes file))) (defun javaimp--get-jdk-jars () - (if javaimp-jdk-home - (let ((jre-lib-dir -(concat (file-name-as-directory javaimp-jdk-home) -(file-name-as-directory "jre") -(file-name-as-directory "lib" - (directory-files jre-lib-dir t "\\.jar\\'" + (and javaimp-java-home + (file-accessible-directory-p javaimp-java-home) + (let ((lib-dir + (concat (file-name-as-directory javaimp-java-home) + (file-name-as-directory "jre") + (file-name-as-directory "lib" +(directory-files lib-dir t "\\.jar\\'" (defun javaimp-cygpath-convert-maybe (path &optional mode is-really-path) "On Cygwin, converts PATH using cygpath according to MODE and @@ -230,7 +233,7 @@ to which modules and other module information. After being processed by this command, the module tree becomes known to javaimp and `javaimp-add-import' maybe called inside any module file." - (interactive "DVisit maven project: ") + (interactive "DVisit maven project in directory: ") (let ((file (expand-file-name (concat (file-name-as-directory path) "pom.xml" (unless (file-readable-p file) @@ -568,7 +571,7 @@ the temporary buffer and returns its result" asks for a class to import, adds import statement and calls `javaimp-organize-imports'. Import stateme
[elpa] master 24ce066: packages/javaimp: Restructure code, add some tests.
branch: master commit 24ce066b6a6a195cdb06bbf87b92df502718806f Author: Filipp Gunbin Commit: Filipp Gunbin packages/javaimp: Restructure code, add some tests. * Restructure xml parsing code for test convenience. * Add 2 simple tests. --- packages/javaimp/javaimp-tests.el | 23 + packages/javaimp/javaimp.el | 197 + 2 files changed, 113 insertions(+), 107 deletions(-) diff --git a/packages/javaimp/javaimp-tests.el b/packages/javaimp/javaimp-tests.el new file mode 100644 index 000..cd8acb2 --- /dev/null +++ b/packages/javaimp/javaimp-tests.el @@ -0,0 +1,23 @@ +;;; javaimp-tests.el --- javaimp module tests -*- lexical-binding: t; -*- + +;; Copyright (C) 2016 Free Software Foundation, Inc. + +;; Author: Filipp Gunbin +;; Maintainer: Filipp Gunbin + +(require 'ert) +(require 'javaimp) + +(ert-deftest javaimp-test--maven-xml-extract-projects--project () + (with-temp-buffer +(insert "") +(let ((projects (javaimp--maven-xml-extract-projects +(xml-parse-region (point-min) (point-max) + (should (eql (length projects) 1) + +(ert-deftest javaimp-test--maven-xml-extract-projects--projects () + (with-temp-buffer +(insert "") +(let ((projects (javaimp--maven-xml-extract-projects +(xml-parse-region (point-min) (point-max) + (should (eql (length projects) 2) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index a14d3da..52abbaa 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -245,7 +245,14 @@ module file." (equal (javaimp-module-file (javaimp-node-contents tree)) file)) javaimp-project-forest)) -(let ((tree (javaimp--maven-xml-load-tree file))) +(message "Loading file %s..." file) +(let* ((xml-tree + (javaimp--maven-call file "help:effective-pom" +#'javaimp--maven-xml-effective-pom-handler)) + (projects (javaimp--maven-xml-extract-projects xml-tree)) + (modules (mapcar #'javaimp--maven-xml-parse-project projects)) + ;; first module is always root + (tree (javaimp--maven-build-tree (car modules) nil modules file))) (if tree (push tree javaimp-project-forest))) (message "Loaded tree for %s" file))) @@ -253,72 +260,46 @@ module file." ;; Maven XML routines -(defun javaimp--maven-xml-load-tree (file) - "Invokes `mvn help:effective-pom' on FILE and using its output -creates a tree of Maven projects starting from FILE. Children -which link to the parent via the element are inheriting -children and are also included. Subordinate modules with no -inheritance are not included." - (let ((xml-tree (javaimp--maven-xml-read-effective-pom file))) -(cond ((assq 'project xml-tree) - (let* ((project-elt (assq 'project xml-tree)) - (submodules (javaimp--xml-children - (javaimp--xml-child 'modules project-elt) - 'module))) -(and submodules - ;; no real children - (message "Independent submodules: %s" - (mapconcat #'javaimp--xml-first-child submodules ", "))) -(let ((module (javaimp--maven-xml-parse-module project-elt))) - (javaimp--maven-build-tree - (javaimp-module-id module) nil (list module) file - ((assq 'projects xml-tree) - ;; we have are inheriting children - they and their children, if - ;; any, are listed in a linear list - (let* ((project-elts (javaimp--xml-children -(assq 'projects xml-tree) 'project)) - (all-modules (mapcar #'javaimp--maven-xml-parse-module project-elts))) -(message "Total modules: %d" (length all-modules)) -(javaimp--maven-build-tree - (javaimp-module-id (car all-modules)) nil all-modules file))) +(defun javaimp--maven-xml-effective-pom-handler () + (let ((start +(save-excursion + (progn +(goto-char (point-min)) +(re-search-forward "<\\?xml\\|")) +(match-end 0) +(xml-parse-region start end))) + +(defun javaimp--maven-xml-extract-projects (xml-tree) + "Analyzes result of `mvn help:effective-pom' and returns list +of elements" + (let ((project (assq 'project xml-tree)) + (projects (assq 'projects xml-tree))) +(cond (project + (list project)) + (projects + (javaimp--xml-children projects 'project)) (t - ;; neither nor - error - (error "Inval
[elpa] master c04fb31: packages/javaimp: Fix comparison of module load ts with parent files.
branch: master commit c04fb31863102dc7115bcf3ae58ecfdcdb77decf Author: Filipp Gunbin Commit: Filipp Gunbin packages/javaimp: Fix comparison of module load ts with parent files. --- packages/javaimp/javaimp.el | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index 52abbaa..c2798a7 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -420,25 +420,25 @@ the temporary buffer and returns its result" ;;; Loading dep-jars (defun javaimp--maven-update-module-maybe (node) - (let (need-update) -(let ((module (javaimp-node-contents node))) - (or (javaimp-module-dep-jars module) - (progn (message "Loading dependencies: %s" (javaimp-module-id module)) -(setq need-update t -;; check if any pom up to the top has changed + (let ((module (javaimp-node-contents node)) + need-update) +;; check if deps are initialized +(or (javaimp-module-dep-jars module) + (progn (message "Loading dependencies: %s" (javaimp-module-id module)) + (setq need-update t))) +;; check if any pom up to the top one has changed (let ((tmp node)) (while (and tmp (not need-update)) - (let ((module (javaimp-node-contents tmp))) - (if (> (float-time (javaimp--get-file-ts (javaimp-module-file module))) + (let ((checked (javaimp-node-contents tmp))) + (if (> (float-time (javaimp--get-file-ts (javaimp-module-file checked))) (float-time (javaimp-module-load-ts module))) (progn - (message "Reloading (%s pom changed)" (javaimp-module-id module)) + (message "Reloading %s (pom changed)" (javaimp-module-id checked)) (setq need-update t (setq tmp (javaimp-node-parent tmp (when need-update - (let* ((module (javaimp-node-contents node)) -(new-dep-jars (javaimp--maven-fetch-dep-jars module)) + (let* ((new-dep-jars (javaimp--maven-fetch-dep-jars module)) (new-load-ts (current-time))) (setf (javaimp-module-dep-jars module) new-dep-jars) (setf (javaimp-module-load-ts module) new-load-ts)
[elpa] master 53bcfc9: [javaimp] Bump version to 0.6.1
branch: master commit 53bcfc9e49f6306ac3e911a9de3d4a2a74c70f95 Author: Filipp Gunbin Commit: Filipp Gunbin [javaimp] Bump version to 0.6.1 --- packages/javaimp/javaimp.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index bf1c1fc..8a3f4f3 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -4,7 +4,7 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.6 +;; Version: 0.6.1 ;; Keywords: java, maven, programming ;; This program is free software; you can redistribute it and/or modify
[elpa] master 308ca02: [javaimp] Minor corrections.
branch: master commit 308ca02870d1c38ad17e3a9a047a35cbf1314e8e Author: Filipp Gunbin Commit: Filipp Gunbin [javaimp] Minor corrections. * Add javax as separate entry in javaimp-import-group-alist. * (javaimp-add-import): move (barf-if-buffer-read-only) outside interactive form. --- packages/javaimp/javaimp.el | 50 ++--- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index e00c956..bf1c1fc 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -94,7 +94,7 @@ "Add and reorder Java import statements in Maven projects" :group 'c) -(defcustom javaimp-import-group-alist '(("\\`javax?\\." . 10)) +(defcustom javaimp-import-group-alist '(("\\`java\\." . 10) ("\\`javax\\." . 15)) "Specifies how to group classes and how to order resulting groups in the imports list. @@ -568,31 +568,29 @@ duplicated. Completion alternatives are constructed based on this module's dependencies' classes, JDK classes and top-level classes in the current module." (interactive - (progn - (barf-if-buffer-read-only) - (let* ((file (expand-file-name - (or buffer-file-name - (error "Buffer is not visiting a file!" - (node (or (javaimp--find-node - (lambda (m) -(or (string-prefix-p (javaimp-module-source-dir m) file) -(string-prefix-p (javaimp-module-test-source-dir m) file - (error "Cannot find module by file: %s" file - (javaimp--maven-update-module-maybe node) - (let ((module (javaimp-node-contents node))) -(list (completing-read - "Import: " - (append -;; we're not caching full list of classes coming from module -;; dependencies because jars may change and we need to reload -;; them -(let ((jars (append (javaimp-module-dep-jars module) -(javaimp--get-jdk-jars - (apply #'seq-concatenate 'list - (mapcar #'javaimp--get-jar-classes jars))) -(and javaimp-include-current-module-classes - (javaimp--get-module-classes module))) - nil t nil nil (symbol-name (symbol-at-point + (let* ((file (expand-file-name (or buffer-file-name + (error "Buffer is not visiting a file!" + (node (or (javaimp--find-node +(lambda (m) + (or (string-prefix-p (javaimp-module-source-dir m) file) + (string-prefix-p (javaimp-module-test-source-dir m) file + (error "Cannot find module by file: %s" file + (javaimp--maven-update-module-maybe node) + (let ((module (javaimp-node-contents node))) + (list (completing-read + "Import: " + (append + ;; we're not caching full list of classes coming from module + ;; dependencies because jars may change and we need to reload + ;; them + (let ((jars (append (javaimp-module-dep-jars module) + (javaimp--get-jdk-jars +(apply #'seq-concatenate 'list + (mapcar #'javaimp--get-jar-classes jars))) + (and javaimp-include-current-module-classes + (javaimp--get-module-classes module))) + nil t nil nil (symbol-name (symbol-at-point))) + (barf-if-buffer-read-only) (javaimp-organize-imports (cons classname 'ordinary))) (defun javaimp--get-module-classes (module)
[elpa] master 740cf63: packages/csv-mode/csv-mode.el: Fix csv-align-fields doc
branch: master commit 740cf63d1e8d4c9dff48b20aff2b6f261023ac91 Author: Filipp Gunbin Commit: Filipp Gunbin packages/csv-mode/csv-mode.el: Fix csv-align-fields doc (csv-align-fields): docstring mentioned csv-align-fields instead of csv-align-padding --- packages/csv-mode/csv-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/csv-mode/csv-mode.el b/packages/csv-mode/csv-mode.el index a4d9253..9c03fc8 100644 --- a/packages/csv-mode/csv-mode.el +++ b/packages/csv-mode/csv-mode.el @@ -1013,7 +1013,7 @@ point." (defun csv-align-fields (hard beg end) "Align all the fields in the region to form columns. The alignment style is specified by `csv-align-style'. The number of -spaces specified by `csv-align-fields' appears after each separator. +spaces specified by `csv-align-padding' appears after each separator. Use soft alignment done by displaying virtual white space after the separators unless invoked with an argument, in which case insert real space characters into the buffer after the separators.
[elpa] branch scratch/javaimp-gradle created (now edc0e55)
fgunbin pushed a change to branch scratch/javaimp-gradle. at edc0e55 packages/javaimp: Support gradle (wip) This branch includes the following new commits: new edc0e55 packages/javaimp: Support gradle (wip)
[elpa] scratch/javaimp-gradle edc0e55: packages/javaimp: Support gradle (wip)
branch: scratch/javaimp-gradle commit edc0e55b4292985fa0ceaf47dc767fbb524f6e8d Author: Filipp Gunbin Commit: Filipp Gunbin packages/javaimp: Support gradle (wip) --- packages/javaimp/javaimp-gradle.el | 135 ++ packages/javaimp/javaimp-maven.el | 170 + packages/javaimp/javaimp-tests.el | 14 +- packages/javaimp/javaimp-util.el | 131 + packages/javaimp/javaimp.el| 366 +++-- 5 files changed, 505 insertions(+), 311 deletions(-) diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el new file mode 100644 index 000..2bf8e8e --- /dev/null +++ b/packages/javaimp/javaimp-gradle.el @@ -0,0 +1,135 @@ +;;; javaimp-gradle.el --- javaimp gradle support -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; Author: Filipp Gunbin +;; Maintainer: Filipp Gunbin +;; Version: 0.6.1 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +(require 'javaimp-util) + +(defcustom javaimp-gradle-program "gradle" + "Path to the `gradle' program. Customize it if the program is +not on `exec-path'.") + +(defun javaimp--gradle-visit (file) + "Calls gradle on FILE to get various project information. + +Passes specially crafted init file as -I argument to gradle and +invokes task contained in it. This task returns all needed +information." + (message "Visiting Gradle build file %s..." file) + (let* ((init-file (make-temp-file "javaimp" nil ".kts" +javaimp--gradle-init-file-contents)) + (modules + (javaimp--call-build-tool javaimp-gradle-program +#'javaimp--gradle-handler +"-q" +"-b" (javaimp-cygpath-convert-maybe file) +"-I" (javaimp-cygpath-convert-maybe init-file) +"javaimpTask"))) +(prog1 +;; first module is always root +(javaimp--build-tree (car modules) nil modules)) +(message "Loaded tree for %s" file))) + +(defun javaimp--gradle-handler () + (goto-char (point-min)) + (let (modules alist pair sym val) +(while (not (eobp)) + (setq pair (split-string (thing-at-point 'line) "=")) + (unless (= (length pair) 2) +(error "Invalid pair from gradle output: %s" pair)) + (setq sym (intern (car pair)) +val (cadr pair)) + (when (and (eq sym 'id) alist);start of next module +(push (javaimp--gradle-module-from-alist alist) modules) +(setq alist nil)) + (push (cons sym val) alist) + (forward-line 1)) +(when alist ;last module + (push (javaimp--gradle-module-from-alist alist) modules)) +modules)) + +(defun javaimp--gradle-module-from-alist (alist) + (make-javaimp-module + :id (javaimp--gradle-id-from-colon-separated (cadr (assq 'id alist))) + :parent-id (javaimp--gradle-id-from-colon-separated (cadr (assq 'parent-id alist))) + :file (cadr (assq 'file alist)) + :final-name (cadr (assq 'final-name alist)) + :packaging "jar" ;TODO + :source-dir (file-name-as-directory +(javaimp-cygpath-convert-maybe + (cadr (assq 'source-dir alist + :test-source-dir (file-name-as-directory + (javaimp-cygpath-convert-maybe + (cadr (assq 'test-source-dir alist + :build-dir (file-name-as-directory + (javaimp-cygpath-convert-maybe +(cadr (assq 'build-dir alist + :dep-jars (javaimp--split-native-path (cadr (assq 'dep-jars alist))) + :load-ts (current-time) + :dep-jars-path-fetcher #'javaimp--gradle-fetch-dep-jars-path)) + +(defun javaimp--gradle-id-from-colon-separated (str) + (when str +(let ((parts (split-string str ":"))) + (unless (= (length parts) 3) +(error "Invalid maven id: %s" str)) + (make-javaimp-id :group (nth 0 parts) :artifact (nth 1 parts) :version (nth 2 parts) + + +(defun j
[elpa] scratch/javaimp-gradle 341ceaf 2/2: Make gradle work
branch: scratch/javaimp-gradle commit 341ceaf79c0d05fa9cb336079a476da16f6638c1 Author: Filipp Gunbin Commit: Filipp Gunbin Make gradle work --- packages/javaimp/javaimp-gradle.el | 32 packages/javaimp/javaimp-util.el | 7 --- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index ddbba87..d2b8374 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -45,18 +45,18 @@ information." "javaimpTask"))) (prog1 ;; first module is always root -(javaimp--build-tree (car modules) nil modules)) -(message "Loaded tree for %s" file))) +(javaimp--build-tree (car modules) nil modules) + (message "Loaded tree for %s" file (defun javaimp--gradle-handler () (goto-char (point-min)) - (let (modules alist pair sym val) + (let (modules alist parts sym val) (while (not (eobp)) - (setq pair (split-string (thing-at-point 'line) "=")) - (unless (= (length pair) 2) -(error "Invalid pair from gradle output: %s" pair)) - (setq sym (intern (car pair)) -val (cadr pair)) + (setq parts (split-string (thing-at-point 'line) "[=\n]+")) + (setq sym (intern (or (nth 0 parts) +(error "Invalid line in gradle output: %s" + (thing-at-point 'line +val (nth 1 parts)) (when (and (eq sym 'id) alist);start of next module (push (javaimp--gradle-module-from-alist alist) modules) (setq alist nil)) @@ -68,21 +68,21 @@ information." (defun javaimp--gradle-module-from-alist (alist) (make-javaimp-module - :id (javaimp--gradle-id-from-colon-separated (cadr (assq 'id alist))) - :parent-id (javaimp--gradle-id-from-colon-separated (cadr (assq 'parent-id alist))) - :file (cadr (assq 'file alist)) - :final-name (cadr (assq 'final-name alist)) + :id (javaimp--gradle-id-from-colon-separated (cdr (assq 'id alist))) + :parent-id (javaimp--gradle-id-from-colon-separated (cdr (assq 'parent-id alist))) + :file (cdr (assq 'file alist)) + :final-name (cdr (assq 'final-name alist)) :packaging "jar" ;TODO :source-dir (file-name-as-directory (javaimp-cygpath-convert-maybe - (cadr (assq 'source-dir alist + (cdr (assq 'source-dir alist :test-source-dir (file-name-as-directory (javaimp-cygpath-convert-maybe - (cadr (assq 'test-source-dir alist + (cdr (assq 'test-source-dir alist :build-dir (file-name-as-directory (javaimp-cygpath-convert-maybe -(cadr (assq 'build-dir alist - :dep-jars (javaimp--split-native-path (cadr (assq 'dep-jars alist))) +(cdr (assq 'build-dir alist + :dep-jars (javaimp--split-native-path (cdr (assq 'dep-jars alist))) :load-ts (current-time) :dep-jars-path-fetcher #'javaimp--gradle-fetch-dep-jars-path)) diff --git a/packages/javaimp/javaimp-util.el b/packages/javaimp/javaimp-util.el index 32af0ce..dae6907 100644 --- a/packages/javaimp/javaimp-util.el +++ b/packages/javaimp/javaimp-util.el @@ -106,9 +106,10 @@ buffer and returns its result" (funcall handler (defun javaimp--split-native-path (path) - (let ((converted (javaimp-cygpath-convert-maybe path 'unix t)) - (sep-regex (concat "[" path-separator "\n" "]+"))) -(split-string converted sep-regex t))) + (when path +(let ((converted (javaimp-cygpath-convert-maybe path 'unix t)) + (sep-regex (concat "[" path-separator "\n" "]+"))) + (split-string converted sep-regex (defun javaimp--build-tree (this parent-node all) (message "Building tree for module: %s" (javaimp-module-id this))
[elpa] scratch/javaimp-gradle updated (edc0e55 -> 341ceaf)
fgunbin pushed a change to branch scratch/javaimp-gradle. from edc0e55 packages/javaimp: Support gradle (wip) new 4346648 Make javaimp-maven work again new 341ceaf Make gradle work Summary of changes: packages/javaimp/javaimp-gradle.el | 36 + packages/javaimp/javaimp-maven.el | 4 +++- packages/javaimp/javaimp-util.el | 17 +--- packages/javaimp/javaimp.el| 41 ++ 4 files changed, 60 insertions(+), 38 deletions(-)
[elpa] scratch/javaimp-gradle 426658b: Gradle fixes
branch: scratch/javaimp-gradle commit 426658b016a067791ab1150fb816e2548ecfdba8 Author: Filipp Gunbin Commit: Filipp Gunbin Gradle fixes --- packages/javaimp/javaimp-gradle.el | 10 ++ packages/javaimp/javaimp-util.el | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index d2b8374..908067a 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -21,6 +21,8 @@ (require 'javaimp-util) +;; TODO support Groovy build files (build.gradle) + (defcustom javaimp-gradle-program "gradle" "Path to the `gradle' program. Customize it if the program is not on `exec-path'." @@ -52,7 +54,7 @@ information." (goto-char (point-min)) (let (modules alist parts sym val) (while (not (eobp)) - (setq parts (split-string (thing-at-point 'line) "[=\n]+")) + (setq parts (split-string (thing-at-point 'line) "[=\n]+" t)) (setq sym (intern (or (nth 0 parts) (error "Invalid line in gradle output: %s" (thing-at-point 'line @@ -64,7 +66,7 @@ information." (forward-line 1)) (when alist ;last module (push (javaimp--gradle-module-from-alist alist) modules)) -modules)) +(nreverse modules))) (defun javaimp--gradle-module-from-alist (alist) (make-javaimp-module @@ -88,7 +90,7 @@ information." (defun javaimp--gradle-id-from-colon-separated (str) (when str -(let ((parts (split-string str ":"))) +(let ((parts (split-string str ":" t))) (unless (= (length parts) 3) (error "Invalid maven id: %s" str)) (make-javaimp-id :group (nth 0 parts) :artifact (nth 1 parts) :version (nth 2 parts) @@ -102,7 +104,7 @@ information." ;; expect just a single line (thing-at-point 'line)) "-q" - "-p" (javaimp-cygpath-convert-maybe file) + "-b" (javaimp-cygpath-convert-maybe file) "-I" (javaimp-cygpath-convert-maybe init-file) "javaimpTask"))) diff --git a/packages/javaimp/javaimp-util.el b/packages/javaimp/javaimp-util.el index dae6907..cd5d58e 100644 --- a/packages/javaimp/javaimp-util.el +++ b/packages/javaimp/javaimp-util.el @@ -109,7 +109,7 @@ buffer and returns its result" (when path (let ((converted (javaimp-cygpath-convert-maybe path 'unix t)) (sep-regex (concat "[" path-separator "\n" "]+"))) - (split-string converted sep-regex + (split-string converted sep-regex t (defun javaimp--build-tree (this parent-node all) (message "Building tree for module: %s" (javaimp-module-id this))
[elpa] scratch/javaimp-gradle 4346648 1/2: Make javaimp-maven work again
branch: scratch/javaimp-gradle commit 4346648f77ead6a80381688bcfde85c82d7715cf Author: Filipp Gunbin Commit: Filipp Gunbin Make javaimp-maven work again --- packages/javaimp/javaimp-gradle.el | 4 +++- packages/javaimp/javaimp-maven.el | 4 +++- packages/javaimp/javaimp-util.el | 10 ++ packages/javaimp/javaimp.el| 41 ++ 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index 2bf8e8e..ddbba87 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -23,7 +23,9 @@ (defcustom javaimp-gradle-program "gradle" "Path to the `gradle' program. Customize it if the program is -not on `exec-path'.") +not on `exec-path'." + :group 'javaimp + :type 'string) (defun javaimp--gradle-visit (file) "Calls gradle on FILE to get various project information. diff --git a/packages/javaimp/javaimp-maven.el b/packages/javaimp/javaimp-maven.el index ee63acb..9ceb1a9 100644 --- a/packages/javaimp/javaimp-maven.el +++ b/packages/javaimp/javaimp-maven.el @@ -26,7 +26,9 @@ (defcustom javaimp-mvn-program "mvn" "Path to the `mvn' program. Customize it if the program is not -on `exec-path'.") +on `exec-path'." + :group 'javaimp + :type 'string) (defun javaimp--maven-visit (file) diff --git a/packages/javaimp/javaimp-util.el b/packages/javaimp/javaimp-util.el index 67e9786..32af0ce 100644 --- a/packages/javaimp/javaimp-util.el +++ b/packages/javaimp/javaimp-util.el @@ -27,7 +27,9 @@ (defcustom javaimp-cygpath-program (if (eq system-type 'cygwin) "cygpath") "Path to the `cygpath' program (Cygwin only). Customize it if -the program is not on `exec-path'.") +the program is not on `exec-path'." + :group 'javaimp + :type 'string) (defun javaimp--xml-children (xml-tree child-name) @@ -88,18 +90,18 @@ unchanged." (defun javaimp--call-build-tool (program handler &rest args) "Runs PROGRAM with ARGS, then calls HANDLER in the temporary buffer and returns its result" - (message "Calling \"%s %s\" on args: %s" program target args) + (message "Calling %s on args: %s" program args) (with-temp-buffer (let ((status (let ((coding-system-for-read (if (eq system-type 'cygwin) 'utf-8-dos))) ;; TODO check in output on Gnu/Linux - `(process-file ,program nil t nil ,@args))) +(apply #'process-file program nil t nil args))) (buf (current-buffer))) (with-current-buffer (get-buffer-create javaimp-debug-buf-name) (erase-buffer) (insert-buffer-substring buf)) (or (and (numberp status) (= status 0)) - (error "Build tool target \"%s\" failed with status \"%s\"" target status)) + (error "\"%s\" failed with status \"%s\"" program status)) (goto-char (point-min)) (funcall handler diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index 29e3f2a..4f87c05 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -56,16 +56,14 @@ ;; Example: ;; ;; (require 'javaimp) -;; ;; (add-to-list 'javaimp-import-group-alist ;; '("\\`\\(my\\.company\\.\\|my\\.company2\\.\\)" . 80)) -;; ;; (setq javaimp-additional-source-dirs '("generated-sources/thrift")) -;; ;; (add-hook 'java-mode-hook ;; (lambda () ;; (local-set-key "\C-ci" 'javaimp-add-import) ;; (local-set-key "\C-co" 'javaimp-organize-imports))) +;; (global-set-key (kbd "C-c j v") 'javaimp-visit-project) ;; @@ -81,8 +79,6 @@ ;; User options -;; TODO add :type for defcustoms - (defgroup javaimp () "Add and reorder Java import statements in Maven/Gradle projects" @@ -97,16 +93,22 @@ where CLASSNAME-REGEXP is a regexp matching the fully qualified class name. Lowest-order groups are placed earlier. The order of classes which were not matched is defined by -`javaimp-import-default-order'.") +`javaimp-import-default-order'." + :group 'javaimp + :type '(alist :key-type string :value-type integer)) (defcustom javaimp-import-default-order 50 "Defines the order of classes which were not matched by -`javaimp-import-group-alist'") +`javaimp-import-group-alist'" + :group 'javaimp + :type 'integer) (defcustom javaimp-java-home (getenv "JAVA_HOME") "Path to the JDK. Directory jre/lib underneath this path is searched for JDK libraries. By default, it is initialized from
[elpa] scratch/javaimp-gradle d9913c9: More fixes for gradle
branch: scratch/javaimp-gradle commit d9913c908adb152410e7885d9ec71a7ab7a0c8be Author: Filipp Gunbin Commit: Filipp Gunbin More fixes for gradle --- packages/javaimp/javaimp-gradle.el | 102 ++--- packages/javaimp/javaimp-maven.el | 13 +++-- packages/javaimp/javaimp.el| 47 + 3 files changed, 107 insertions(+), 55 deletions(-) diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index 908067a..d0ff6b3 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -21,8 +21,6 @@ (require 'javaimp-util) -;; TODO support Groovy build files (build.gradle) - (defcustom javaimp-gradle-program "gradle" "Path to the `gradle' program. Customize it if the program is not on `exec-path'." @@ -36,15 +34,14 @@ Passes specially crafted init file as -I argument to gradle and invokes task contained in it. This task returns all needed information." (message "Visiting Gradle build file %s..." file) - (let* ((init-file (make-temp-file "javaimp" nil ".kts" -javaimp--gradle-init-file-contents)) - (modules - (javaimp--call-build-tool javaimp-gradle-program -#'javaimp--gradle-handler -"-q" -"-b" (javaimp-cygpath-convert-maybe file) -"-I" (javaimp-cygpath-convert-maybe init-file) -"javaimpTask"))) + (let* ((alists (javaimp--gradle-call file + javaimp--gradle-init-script + javaimp--gradle-init-script-kotlin + #'javaimp--gradle-handler + "javaimpTask")) + (modules (mapcar (lambda (alist) +(javaimp--gradle-module-from-alist alist file)) + alists))) (prog1 ;; first module is always root (javaimp--build-tree (car modules) nil modules) @@ -52,7 +49,7 @@ information." (defun javaimp--gradle-handler () (goto-char (point-min)) - (let (modules alist parts sym val) + (let (alist res parts sym val) (while (not (eobp)) (setq parts (split-string (thing-at-point 'line) "[=\n]+" t)) (setq sym (intern (or (nth 0 parts) @@ -60,19 +57,20 @@ information." (thing-at-point 'line val (nth 1 parts)) (when (and (eq sym 'id) alist);start of next module -(push (javaimp--gradle-module-from-alist alist) modules) +(push alist res) (setq alist nil)) (push (cons sym val) alist) (forward-line 1)) (when alist ;last module - (push (javaimp--gradle-module-from-alist alist) modules)) -(nreverse modules))) + (push alist res)) +(nreverse res))) -(defun javaimp--gradle-module-from-alist (alist) +(defun javaimp--gradle-module-from-alist (alist file-orig) (make-javaimp-module :id (javaimp--gradle-id-from-colon-separated (cdr (assq 'id alist))) :parent-id (javaimp--gradle-id-from-colon-separated (cdr (assq 'parent-id alist))) :file (cdr (assq 'file alist)) + :file-orig file-orig :final-name (cdr (assq 'final-name alist)) :packaging "jar" ;TODO :source-dir (file-name-as-directory @@ -95,25 +93,69 @@ information." (error "Invalid maven id: %s" str)) (make-javaimp-id :group (nth 0 parts) :artifact (nth 1 parts) :version (nth 2 parts) - -(defun javaimp--gradle-fetch-dep-jars-path (file) - (let ((init-file (make-temp-file "javaimp" nil ".kts" - javaimp--gradle-init-file-contents-dep-jars-only))) -(javaimp--call-build-tool javaimp-gradle-program - (lambda () -;; expect just a single line -(thing-at-point 'line)) +(defun javaimp--gradle-fetch-dep-jars-path (module) + ;; always invoke on originating file becase module's file may not + ;; exist (even if reported as project.buildFile property); also, + ;; local gradlew which needs to be invoked will usually reside + ;; alongside top-level build file + (javaimp--gradle-call (javaimp-module-file-orig module) +javaimp--gradle-init-script-dep-jars-only +javaimp--gradle-init-script-dep-jars-only-kotlin +(lambda () + ;; expect just a single line + (thing-at-point 'line)) +
[elpa] scratch/javaimp-gradle 480d172 1/2: More fixes for gradle
branch: scratch/javaimp-gradle commit 480d17280e713cd32b5a01109b1b51b5e1cfb989 Author: Filipp Gunbin Commit: Filipp Gunbin More fixes for gradle --- packages/javaimp/javaimp-gradle.el | 120 - packages/javaimp/javaimp-maven.el | 18 +++--- packages/javaimp/javaimp.el| 36 +-- 3 files changed, 77 insertions(+), 97 deletions(-) diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index d0ff6b3..300bd9a 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -23,10 +23,37 @@ (defcustom javaimp-gradle-program "gradle" "Path to the `gradle' program. Customize it if the program is -not on `exec-path'." +not on `exec-path'. If the visited project's directory contains +gradlew program, it is used in preference." :group 'javaimp :type 'string) +(defconst javaimp--gradle-get-info-action + "doLast { + println(\"id=${project.group}:${project.name}:${project.version}\") + if (project.parent != null) { + println(\"parent-id=${project.parent.group}:${project.parent.name}:${project.parent.version}\") + } + println(\"file=${project.buildFile}\") + println(\"final-name=${project.archivesBaseName}\") + println(\"source-dirs=\" + sourceSets.stream() + .flatMap { it.java.srcDirs.stream().map { it.path } } + .collect(Collectors.joining(File.pathSeparator))) + println(\"build-dir=${project.buildDir}\") + println(\"dep-jars=\" + sourceSets.stream() + .flatMap { it.compileClasspath.files.stream().filter { it.name.endsWith(\"jar\") }.map { it.path } } + .collect(Collectors.joining(File.pathSeparator))) +}" + "Task body, uses Java syntax to be reused in both Groovy and Kotlin") + +(defconst javaimp--gradle-get-jars-action + "doLast { + println(sourceSets.stream() + .flatMap { it.compileClasspath.files.stream().filter { it.name.endsWith(\"jar\") }.map { it.path } } + .collect(Collectors.joining(File.pathSeparator))) +}" + "Task body, uses Java syntax to be reused in both Groovy and Kotlin") + (defun javaimp--gradle-visit (file) "Calls gradle on FILE to get various project information. @@ -35,8 +62,7 @@ invokes task contained in it. This task returns all needed information." (message "Visiting Gradle build file %s..." file) (let* ((alists (javaimp--gradle-call file - javaimp--gradle-init-script - javaimp--gradle-init-script-kotlin + javaimp--gradle-get-info-action #'javaimp--gradle-handler "javaimpTask")) (modules (mapcar (lambda (alist) @@ -72,13 +98,8 @@ information." :file (cdr (assq 'file alist)) :file-orig file-orig :final-name (cdr (assq 'final-name alist)) - :packaging "jar" ;TODO - :source-dir (file-name-as-directory -(javaimp-cygpath-convert-maybe - (cdr (assq 'source-dir alist - :test-source-dir (file-name-as-directory - (javaimp-cygpath-convert-maybe - (cdr (assq 'test-source-dir alist + :source-dirs (javaimp--split-native-path + (cdr (assq 'source-dirs alist))) :build-dir (file-name-as-directory (javaimp-cygpath-convert-maybe (cdr (assq 'build-dir alist @@ -99,8 +120,7 @@ information." ;; local gradlew which needs to be invoked will usually reside ;; alongside top-level build file (javaimp--gradle-call (javaimp-module-file-orig module) -javaimp--gradle-init-script-dep-jars-only -javaimp--gradle-init-script-dep-jars-only-kotlin +javaimp--gradle-get-jars-action (lambda () ;; expect just a single line (thing-at-point 'line)) @@ -108,11 +128,13 @@ information." (javaimp-id-artifact (javaimp-module-id module) -(defun javaimp--gradle-call (file init-script init-script-kotlin handler task) +(defun javaimp--gradle-call (file init-script-body handler task) (let* ((is-kotlin (equal (file-name-extension file) "kts")) (init-file (make-temp-file "javaimp" nil (if is-kotlin ".kts") -(if is-kotlin init-script-kotlin init-script))) +(if is-kotlin +
[elpa] scratch/javaimp-gradle updated (d9913c9 -> cae295d)
fgunbin pushed a change to branch scratch/javaimp-gradle. from d9913c9 More fixes for gradle new 480d172 More fixes for gradle new cae295d More fixes for gradle Summary of changes: packages/javaimp/javaimp-gradle.el | 121 + packages/javaimp/javaimp-maven.el | 18 +++--- packages/javaimp/javaimp.el| 36 +-- 3 files changed, 78 insertions(+), 97 deletions(-)
[elpa] scratch/javaimp-gradle cae295d 2/2: More fixes for gradle
branch: scratch/javaimp-gradle commit cae295d5bc845f61116bcfe8523f523a1d3d86bf Author: Filipp Gunbin Commit: Filipp Gunbin More fixes for gradle --- packages/javaimp/javaimp-gradle.el | 5 +++-- packages/javaimp/javaimp.el| 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index 300bd9a..62be517 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -98,8 +98,9 @@ information." :file (cdr (assq 'file alist)) :file-orig file-orig :final-name (cdr (assq 'final-name alist)) - :source-dirs (javaimp--split-native-path - (cdr (assq 'source-dirs alist))) + :source-dirs (mapcar #'file-name-as-directory +(javaimp--split-native-path + (cdr (assq 'source-dirs alist :build-dir (file-name-as-directory (javaimp-cygpath-convert-maybe (cdr (assq 'build-dir alist diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index aa2a107..30cf087 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -165,7 +165,7 @@ to the completion alternatives list." file file-orig final-name - source-dirs + source-dirs build-dir dep-jars load-ts dep-jars-path-fetcher)
[elpa] scratch/javaimp-gradle 66c8204: Fixes for gradle
branch: scratch/javaimp-gradle commit 66c8204255ed5fb5a2fc447b948a453eb901ff04 Author: Filipp Gunbin Commit: Filipp Gunbin Fixes for gradle --- packages/javaimp/getInfo.inc.kts | 21 ++ packages/javaimp/getJarsOnly.inc.kts | 8 ++ packages/javaimp/javaimp-gradle.el | 54 +--- 3 files changed, 48 insertions(+), 35 deletions(-) diff --git a/packages/javaimp/getInfo.inc.kts b/packages/javaimp/getInfo.inc.kts new file mode 100644 index 000..3aceb9b --- /dev/null +++ b/packages/javaimp/getInfo.inc.kts @@ -0,0 +1,21 @@ +// use syntax which is valid both in Groovy and in Kotlin +doLast { + println("id=${project.group}:${project.name}:${project.version}") + if (project.parent != null) { + println("parent-id=${project.parent.group}:${project.parent.name}:${project.parent.version}") + } + println("file=${project.buildFile}") + println("final-name=${project.archivesBaseName}") + println("build-dir=${project.buildDir}") + if (project.hasProperty("sourceSets")) { + println("source-dirs=" + project.sourceSets.stream() + .flatMap { it.java.srcDirs.stream().map { it.path } } + .collect(Collectors.joining(File.pathSeparator))) + println("dep-jars=" + project.sourceSets.stream() + .flatMap { it.compileClasspath.files.stream().filter { it.name.endsWith("jar") }.map { it.path } } + .collect(Collectors.joining(File.pathSeparator))) + } else { + println("source-dirs=") + println("dep-jars=") + } +} diff --git a/packages/javaimp/getJarsOnly.inc.kts b/packages/javaimp/getJarsOnly.inc.kts new file mode 100644 index 000..4951255 --- /dev/null +++ b/packages/javaimp/getJarsOnly.inc.kts @@ -0,0 +1,8 @@ +// use syntax which is valid both in Groovy and in Kotlin +doLast { + if (project.hasProperty("sourceSets")) { + println(project.sourceSets.stream() + .flatMap { it.compileClasspath.files.stream().filter { it.name.endsWith("jar") }.map { it.path } } + .collect(Collectors.joining(File.pathSeparator))) + } +} diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index 62be517..9dc74fd 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -28,30 +28,16 @@ gradlew program, it is used in preference." :group 'javaimp :type 'string) -(defconst javaimp--gradle-get-info-action - "doLast { - println(\"id=${project.group}:${project.name}:${project.version}\") - if (project.parent != null) { - println(\"parent-id=${project.parent.group}:${project.parent.name}:${project.parent.version}\") - } - println(\"file=${project.buildFile}\") - println(\"final-name=${project.archivesBaseName}\") - println(\"source-dirs=\" + sourceSets.stream() - .flatMap { it.java.srcDirs.stream().map { it.path } } - .collect(Collectors.joining(File.pathSeparator))) - println(\"build-dir=${project.buildDir}\") - println(\"dep-jars=\" + sourceSets.stream() - .flatMap { it.compileClasspath.files.stream().filter { it.name.endsWith(\"jar\") }.map { it.path } } - .collect(Collectors.joining(File.pathSeparator))) -}" - "Task body, uses Java syntax to be reused in both Groovy and Kotlin") - -(defconst javaimp--gradle-get-jars-action - "doLast { - println(sourceSets.stream() - .flatMap { it.compileClasspath.files.stream().filter { it.name.endsWith(\"jar\") }.map { it.path } } - .collect(Collectors.joining(File.pathSeparator))) -}" +(defconst javaimp--gradle-get-info-script + (with-temp-buffer +(insert-file-contents "getInfo.inc.kts") +(buffer-string)) + "Task body, uses Java syntax to be reused in both Groovy and Kotlin") + +(defconst javaimp--gradle-get-jars-script + (with-temp-buffer +(insert-file-contents "getJarsOnly.inc.kts") +(buffer-string)) "Task body, uses Java syntax to be reused in both Groovy and Kotlin") (defun javaimp--gradle-visit (file) @@ -62,7 +48,7 @@ invokes task contained in it. This task returns all needed information." (message "Visiting Gradle build file %s..." file) (let* ((alists (javaimp--gradle-call file - javaimp--gradle-get-info-action + javaimp--gradle-get-info-script #'javaimp--gradle-handler "javaimpTask")) (modules (mapcar (lambda (alist) @@ -75,18 +61,16 @@ information." (defun javaimp--gradle-handler () (goto-char (point-min)) - (let (alist res
[elpa] scratch/javaimp-gradle ff2013c 2/2: Fixes for gradle
branch: scratch/javaimp-gradle commit ff2013cfd9e351eadd76bcc85711a3fa30356d7b Author: Filipp Gunbin Commit: Filipp Gunbin Fixes for gradle --- packages/javaimp/getJarsOnlyTaskBody.inc.kts | 8 -- ...InfoTaskBody.inc.kts => gradleTaskBody.inc.kts} | 2 +- packages/javaimp/javaimp-gradle.el | 32 -- 3 files changed, 13 insertions(+), 29 deletions(-) diff --git a/packages/javaimp/getJarsOnlyTaskBody.inc.kts b/packages/javaimp/getJarsOnlyTaskBody.inc.kts deleted file mode 100644 index 4951255..000 --- a/packages/javaimp/getJarsOnlyTaskBody.inc.kts +++ /dev/null @@ -1,8 +0,0 @@ -// use syntax which is valid both in Groovy and in Kotlin -doLast { - if (project.hasProperty("sourceSets")) { - println(project.sourceSets.stream() - .flatMap { it.compileClasspath.files.stream().filter { it.name.endsWith("jar") }.map { it.path } } - .collect(Collectors.joining(File.pathSeparator))) - } -} diff --git a/packages/javaimp/getInfoTaskBody.inc.kts b/packages/javaimp/gradleTaskBody.inc.kts similarity index 91% rename from packages/javaimp/getInfoTaskBody.inc.kts rename to packages/javaimp/gradleTaskBody.inc.kts index 3aceb9b..10b778c 100644 --- a/packages/javaimp/getInfoTaskBody.inc.kts +++ b/packages/javaimp/gradleTaskBody.inc.kts @@ -7,7 +7,7 @@ doLast { println("file=${project.buildFile}") println("final-name=${project.archivesBaseName}") println("build-dir=${project.buildDir}") - if (project.hasProperty("sourceSets")) { + if (project.hasProperty("sourceSets")) { //sourceSets are defined by java plugin println("source-dirs=" + project.sourceSets.stream() .flatMap { it.java.srcDirs.stream().map { it.path } } .collect(Collectors.joining(File.pathSeparator))) diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index 5728501..285794e 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -28,17 +28,11 @@ gradlew program, it is used in preference." :group 'javaimp :type 'string) -(defconst javaimp--gradle-get-info-script +(defconst javaimp--gradle-task-body (with-temp-buffer -(insert-file-contents "getInfoTaskBody.inc.kts") +(insert-file-contents "gradleTaskBody.inc.kts") (buffer-string)) - "Task body, uses Java syntax to be reused in both Groovy and Kotlin") - -(defconst javaimp--gradle-get-jars-script - (with-temp-buffer -(insert-file-contents "getJarsOnlyTaskBody.inc.kts") -(buffer-string)) - "Task body, uses Java syntax to be reused in both Groovy and Kotlin") + "Task body, uses syntax which can be used both in Groovy and Kotlin") (defun javaimp--gradle-visit (file) "Calls gradle on FILE to get various project information. @@ -48,7 +42,7 @@ invokes task contained in it. This task returns all needed information." (message "Visiting Gradle build file %s..." file) (let* ((alists (javaimp--gradle-call file - javaimp--gradle-get-info-script + javaimp--gradle-task-body #'javaimp--gradle-handler "javaimpTask")) (modules (mapcar (lambda (alist) @@ -100,18 +94,16 @@ information." (make-javaimp-id :group (nth 0 parts) :artifact (nth 1 parts) :version (nth 2 parts) (defun javaimp--gradle-fetch-dep-jars-path (module) - ;; always invoke on originating file becase module's file may not - ;; exist (even if reported as project.buildFile property); also, - ;; local gradlew which needs to be invoked will usually reside - ;; alongside top-level build file + ;; always invoke on root file becase module's file may not exist + ;; (even if reported as project.buildFile property) (javaimp--gradle-call (javaimp-module-file-orig module) -javaimp--gradle-get-jars-script +javaimp--gradle-task-body (lambda () - ;; expect just a single line - (thing-at-point 'line)) -(format ":%s:javaimpTask" ;TODO what if root? -(javaimp-id-artifact (javaimp-module-id module) - + (re-search-forward "^dep-jars=\\(.*\\)$") + (match-string 1)) +(concat (if (javaimp-module-parent-id module) +(concat ":" (javaimp-id-artifact (javaimp-module-id module +":javaimpTask"))) (defun javaimp--gradle-call (file init-script-body handler task) (let* ((is-kotlin (equal (file-name-extension file) "kts"))
[elpa] scratch/javaimp-gradle updated (66c8204 -> ff2013c)
fgunbin pushed a change to branch scratch/javaimp-gradle. from 66c8204 Fixes for gradle new c39e8cf Rename snippets new ff2013c Fixes for gradle Summary of changes: packages/javaimp/getJarsOnly.inc.kts | 8 -- .../{getInfo.inc.kts => gradleTaskBody.inc.kts}| 2 +- packages/javaimp/javaimp-gradle.el | 32 -- 3 files changed, 13 insertions(+), 29 deletions(-) delete mode 100644 packages/javaimp/getJarsOnly.inc.kts rename packages/javaimp/{getInfo.inc.kts => gradleTaskBody.inc.kts} (91%)
[elpa] scratch/javaimp-gradle c39e8cf 1/2: Rename snippets
branch: scratch/javaimp-gradle commit c39e8cf850088d4892bd775ee591f66c2f7b4244 Author: Filipp Gunbin Commit: Filipp Gunbin Rename snippets --- packages/javaimp/{getInfo.inc.kts => getInfoTaskBody.inc.kts} | 0 packages/javaimp/{getJarsOnly.inc.kts => getJarsOnlyTaskBody.inc.kts} | 0 packages/javaimp/javaimp-gradle.el| 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/javaimp/getInfo.inc.kts b/packages/javaimp/getInfoTaskBody.inc.kts similarity index 100% rename from packages/javaimp/getInfo.inc.kts rename to packages/javaimp/getInfoTaskBody.inc.kts diff --git a/packages/javaimp/getJarsOnly.inc.kts b/packages/javaimp/getJarsOnlyTaskBody.inc.kts similarity index 100% rename from packages/javaimp/getJarsOnly.inc.kts rename to packages/javaimp/getJarsOnlyTaskBody.inc.kts diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index 9dc74fd..5728501 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -30,13 +30,13 @@ gradlew program, it is used in preference." (defconst javaimp--gradle-get-info-script (with-temp-buffer -(insert-file-contents "getInfo.inc.kts") +(insert-file-contents "getInfoTaskBody.inc.kts") (buffer-string)) "Task body, uses Java syntax to be reused in both Groovy and Kotlin") (defconst javaimp--gradle-get-jars-script (with-temp-buffer -(insert-file-contents "getJarsOnly.inc.kts") +(insert-file-contents "getJarsOnlyTaskBody.inc.kts") (buffer-string)) "Task body, uses Java syntax to be reused in both Groovy and Kotlin")
[elpa] scratch/javaimp-gradle fe6f096: Prefix arg in javaimp-reset
branch: scratch/javaimp-gradle commit fe6f0960f8c5159e6f060cda84b85c020d29c8c8 Author: Filipp Gunbin Commit: Filipp Gunbin Prefix arg in javaimp-reset --- packages/javaimp/javaimp.el | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index 30cf087..c900321 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -515,11 +515,13 @@ is `ordinary' or `static'. Interactively, NEW-IMPORTS is nil." (insert (format pattern (caar import)) ?\n) (setq last-order order) -(defun javaimp-reset() - "Forget all state" - (interactive) +(defun javaimp-reset (arg) + "Forget loaded trees state. With prefix arg, also reset jars +cache." + (interactive "P") (setq javaimp-project-forest nil) - (setq javaimp-cached-jars nil)) + (when arg +(setq javaimp-cached-jars nil))) (provide 'javaimp)
[elpa] scratch/javaimp-gradle 7a0f56a: Fixes
branch: scratch/javaimp-gradle commit 7a0f56a2ba5508a41613bb881c3e8cf903395d82 Author: Filipp Gunbin Commit: Filipp Gunbin Fixes --- packages/javaimp/javaimp-gradle.el | 2 +- packages/javaimp/javaimp-util.el | 27 +++ packages/javaimp/javaimp.el| 28 +--- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index 285794e..2596465 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -30,7 +30,7 @@ gradlew program, it is used in preference." (defconst javaimp--gradle-task-body (with-temp-buffer -(insert-file-contents "gradleTaskBody.inc.kts") +(insert-file-contents (expand-file-name "gradleTaskBody.inc.kts" javaimp--basedir)) (buffer-string)) "Task body, uses syntax which can be used both in Groovy and Kotlin") diff --git a/packages/javaimp/javaimp-util.el b/packages/javaimp/javaimp-util.el index cd5d58e..c60e9e3 100644 --- a/packages/javaimp/javaimp-util.el +++ b/packages/javaimp/javaimp-util.el @@ -23,6 +23,8 @@ ;;; Code: (require 'xml) +(require 'cl-lib) +(require 'seq) (defcustom javaimp-cygpath-program (if (eq system-type 'cygwin) "cygpath") @@ -31,6 +33,31 @@ the program is not on `exec-path'." :group 'javaimp :type 'string) +(defconst javaimp-debug-buf-name "*javaimp-debug*") + +(defconst javaimp--basedir (file-name-directory load-file-name)) + +;; Structs + +(cl-defstruct javaimp-node + parent children contents) + +(cl-defstruct javaimp-module + id parent-id + file + file-orig + final-name + source-dirs build-dir + dep-jars + load-ts + dep-jars-path-fetcher) + +(cl-defstruct javaimp-id + group artifact version) + +(cl-defstruct javaimp-cached-jar + file read-ts classes) + (defun javaimp--xml-children (xml-tree child-name) "Returns list of children of XML-TREE filtered by CHILD-NAME" diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index c900321..b24b243 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -69,9 +69,6 @@ ;;; Code: -(require 'cl-lib) -(require 'seq) -(require 'javaimp-util) (require 'javaimp-maven) (require 'javaimp-gradle) @@ -144,7 +141,7 @@ to the completion alternatives list." :type 'boolean) -;; Variables and constants +;; Variables (defvar javaimp-project-forest nil "Visited projects") @@ -153,29 +150,6 @@ to the completion alternatives list." "Alist of cached jars. Each element is of the form (FILE . CACHED-JAR).") -(defconst javaimp-debug-buf-name "*javaimp-debug*") - -;; Structs - -(cl-defstruct javaimp-node - parent children contents) - -(cl-defstruct javaimp-module - id parent-id - file - file-orig - final-name - source-dirs build-dir - dep-jars - load-ts - dep-jars-path-fetcher) - -(cl-defstruct javaimp-id - group artifact version) - -(cl-defstruct javaimp-cached-jar - file read-ts classes) - ;;;###autoload
[elpa] scratch/javaimp-gradle ecccf68 1/2: Conditionally set archivesBaseName
branch: scratch/javaimp-gradle commit ecccf68dd5198c3349a8df6ecb32f88a11efeec1 Author: Filipp Gunbin Commit: Filipp Gunbin Conditionally set archivesBaseName --- packages/javaimp/gradleTaskBody.inc.kts | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/javaimp/gradleTaskBody.inc.kts b/packages/javaimp/gradleTaskBody.inc.kts index 10b778c..6629cd7 100644 --- a/packages/javaimp/gradleTaskBody.inc.kts +++ b/packages/javaimp/gradleTaskBody.inc.kts @@ -5,9 +5,13 @@ doLast { println("parent-id=${project.parent.group}:${project.parent.name}:${project.parent.version}") } println("file=${project.buildFile}") - println("final-name=${project.archivesBaseName}") + if (project.hasProperty("archivesBaseName")) { // defined by java plugin + println("final-name=${project.archivesBaseName}") + } else { + println("final-name=") + } println("build-dir=${project.buildDir}") - if (project.hasProperty("sourceSets")) { //sourceSets are defined by java plugin + if (project.hasProperty("sourceSets")) { // defined by java plugin println("source-dirs=" + project.sourceSets.stream() .flatMap { it.java.srcDirs.stream().map { it.path } } .collect(Collectors.joining(File.pathSeparator)))
[elpa] scratch/javaimp-gradle 63d6d13 2/2: Gradle fixes
branch: scratch/javaimp-gradle commit 63d6d13fd30d5830f6c9e1324d2a9f0f010c0604 Author: Filipp Gunbin Commit: Filipp Gunbin Gradle fixes --- packages/javaimp/gradleTaskBody.inc.kts | 8 ++-- packages/javaimp/javaimp-gradle.el | 3 ++- packages/javaimp/javaimp-util.el| 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/javaimp/gradleTaskBody.inc.kts b/packages/javaimp/gradleTaskBody.inc.kts index 6629cd7..7c5770f 100644 --- a/packages/javaimp/gradleTaskBody.inc.kts +++ b/packages/javaimp/gradleTaskBody.inc.kts @@ -6,14 +6,18 @@ doLast { } println("file=${project.buildFile}") if (project.hasProperty("archivesBaseName")) { // defined by java plugin - println("final-name=${project.archivesBaseName}") + println("final-name=" + project.configurations.getByName("archives").artifacts.stream() + .filter { it.type.equals("war") } + .map { it.file.path } + .findFirst() + .orElse("")) } else { println("final-name=") } println("build-dir=${project.buildDir}") if (project.hasProperty("sourceSets")) { // defined by java plugin println("source-dirs=" + project.sourceSets.stream() - .flatMap { it.java.srcDirs.stream().map { it.path } } + .flatMap { it.allJava.srcDirs.stream().map { it.path } } .collect(Collectors.joining(File.pathSeparator))) println("dep-jars=" + project.sourceSets.stream() .flatMap { it.compileClasspath.files.stream().filter { it.name.endsWith("jar") }.map { it.path } } diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index 2596465..0f91f6d 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -75,7 +75,8 @@ information." :parent-id (javaimp--gradle-id-from-colon-separated (cdr (assq 'parent-id alist))) :file (cdr (assq 'file alist)) :file-orig file-orig - :final-name (cdr (assq 'final-name alist)) + :final-name (javaimp-cygpath-convert-maybe +(cdr (assq 'final-name alist))) :source-dirs (mapcar #'file-name-as-directory (javaimp--split-native-path (cdr (assq 'source-dirs alist diff --git a/packages/javaimp/javaimp-util.el b/packages/javaimp/javaimp-util.el index c60e9e3..d5050ec 100644 --- a/packages/javaimp/javaimp-util.el +++ b/packages/javaimp/javaimp-util.el @@ -100,7 +100,7 @@ IS-REALLY-PATH. If MODE is `unix' (the default), adds -u switch. If MODE is `windows', adds -m switch. If `is-really-path' is non-nil, adds `-p' switch. On other systems, PATH is returned unchanged." - (if (eq system-type 'cygwin) + (if (and path (eq system-type 'cygwin)) (progn (unless mode (setq mode 'unix)) (let (args)
[elpa] scratch/javaimp-gradle updated (7a0f56a -> 63d6d13)
fgunbin pushed a change to branch scratch/javaimp-gradle. from 7a0f56a Fixes new ecccf68 Conditionally set archivesBaseName new 63d6d13 Gradle fixes Summary of changes: packages/javaimp/gradleTaskBody.inc.kts | 14 +++--- packages/javaimp/javaimp-gradle.el | 3 ++- packages/javaimp/javaimp-util.el| 2 +- 3 files changed, 14 insertions(+), 5 deletions(-)
[elpa] branch scratch/javaimp-gradle deleted (was 63d6d13)
fgunbin pushed a change to branch scratch/javaimp-gradle. was 63d6d13 Gradle fixes This change permanently discards the following revisions: discards 63d6d13 Gradle fixes discards ecccf68 Conditionally set archivesBaseName discards 7a0f56a Fixes discards fe6f096 Prefix arg in javaimp-reset discards ff2013c Fixes for gradle discards c39e8cf Rename snippets discards 66c8204 Fixes for gradle discards cae295d More fixes for gradle discards 480d172 More fixes for gradle discards d9913c9 More fixes for gradle discards 426658b Gradle fixes discards 341ceaf Make gradle work discards 4346648 Make javaimp-maven work again discards edc0e55 packages/javaimp: Support gradle (wip)
[elpa] master 1bc7436: [javaimp]: Support gradle, split into multiple files
branch: master commit 1bc7436e9c525c7ee8fcbe5d953241d338f6d1e0 Author: Filipp Gunbin Commit: Filipp Gunbin [javaimp]: Support gradle, split into multiple files * packages/javaimp/javaimp.el: Move maven-specific functions to javaimp-maven.el. Move common functions to javaimp-util.el * packages/javaimp/javaimp-maven.el: New file. * packages/javaimp/javaimp-gradle.el: New file. * packages/javaimp/javaimp-util.el: New file. * packages/javaimp/gradleTaskBody.inc.kts: New file. --- packages/javaimp/gradleTaskBody.inc.kts | 29 ++ packages/javaimp/javaimp-gradle.el | 149 ++ packages/javaimp/javaimp-maven.el | 181 packages/javaimp/javaimp-tests.el | 14 +- packages/javaimp/javaimp-util.el| 166 +++ packages/javaimp/javaimp.el | 480 6 files changed, 647 insertions(+), 372 deletions(-) diff --git a/packages/javaimp/gradleTaskBody.inc.kts b/packages/javaimp/gradleTaskBody.inc.kts new file mode 100644 index 000..697e743 --- /dev/null +++ b/packages/javaimp/gradleTaskBody.inc.kts @@ -0,0 +1,29 @@ +// use syntax which is valid both in Groovy and in Kotlin +doLast { + println("id=${project.group}:${project.name}:${project.version}") + if (project.parent != null) { + println("parent-id=${project.parent.group}:${project.parent.name}:${project.parent.version}") + } + println("file=${project.buildFile}") + if (project.hasProperty("archivesBaseName")) { // defined by java plugin + println("final-name=" + project.configurations.getByName("archives").artifacts.stream() + .filter { it.type.equals("jar") || it.type.equals("war") } + .map { it.file.path } + .findFirst() + .orElse("")) + } else { + println("final-name=") + } + println("build-dir=${project.buildDir}") + if (project.hasProperty("sourceSets")) { // defined by java plugin + println("source-dirs=" + project.sourceSets.stream() + .flatMap { it.allJava.srcDirs.stream().map { it.path } } + .collect(Collectors.joining(File.pathSeparator))) + println("dep-jars=" + project.sourceSets.stream() + .flatMap { it.compileClasspath.files.stream().filter { it.name.endsWith("jar") }.map { it.path } } + .collect(Collectors.joining(File.pathSeparator))) + } else { + println("source-dirs=") + println("dep-jars=") + } +} diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el new file mode 100644 index 000..77c7dae --- /dev/null +++ b/packages/javaimp/javaimp-gradle.el @@ -0,0 +1,149 @@ +;;; javaimp-gradle.el --- javaimp gradle support -*- lexical-binding: t; -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; Author: Filipp Gunbin +;; Maintainer: Filipp Gunbin +;; Version: 0.6.1 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +(require 'javaimp-util) + +(defcustom javaimp-gradle-program "gradle" + "Path to the `gradle' program. Customize it if the program is +not on `exec-path'. If the visited project's directory contains +gradlew program, it is used in preference." + :group 'javaimp + :type 'string) + +(defconst javaimp--gradle-task-body + (with-temp-buffer +(insert-file-contents (expand-file-name "gradleTaskBody.inc.kts" javaimp--basedir)) +(buffer-string)) + "Task body, uses syntax which can be used both in Groovy and Kotlin") + +(defun javaimp--gradle-visit (file) + "Calls gradle on FILE to get various project information. + +Passes specially crafted init file as -I argument to gradle and +invokes task contained in it. This task returns all needed +information." + (message "Visiting Gradle build file %s..." file) + (let* ((alists (javaimp--gradle-call file + javaimp--gradle-task-body + #'javaimp--gradle-handler + "javaimpTask")) + (modules (mapcar (lambda (alist) +(javaimp--gradle
[elpa] master 022b983: packages/javaimp/javaimp.el: Add News section, bump version to 0.7
branch: master commit 022b9835b524568447f1caeade81ca17b6e8b07b Author: Filipp Gunbin Commit: Filipp Gunbin packages/javaimp/javaimp.el: Add News section, bump version to 0.7 --- packages/javaimp/javaimp.el | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index b24b243..6980994 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -4,7 +4,7 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.6.1 +;; Version: 0.7 ;; Keywords: java, maven, gradle, programming ;; This program is free software; you can redistribute it and/or modify @@ -66,6 +66,15 @@ ;; (global-set-key (kbd "C-c j v") 'javaimp-visit-project) ;; +;;; News: + +;; v0.7: +;; - Added Gradle support. +;; +;; - Removed javaimp-maven-visit-project in favor of javaimp-visit-project. +;; +;; - Split into multiple files. + ;;; Code:
[elpa] master dee73ff: [javaimp] Fix gradle project id output & parsing.
branch: master commit dee73ff2a96883c7c911967772ede4a453796aec Author: Filipp Gunbin Commit: Filipp Gunbin [javaimp] Fix gradle project id output & parsing. * packages/javaimp/gradleTaskBody.inc.kts: Output project's path which is unique instead of name. Check for java plugin instead of archivesBaseName. * packages/javaimp/javaimp-gradle.el (javaimp--gradle-module-from-alist, javaimp--gradle-id-from-semi-separated): Parse path as id. --- packages/javaimp/gradleTaskBody.inc.kts | 22 ++ packages/javaimp/javaimp-gradle.el | 25 +++-- packages/javaimp/javaimp-util.el| 2 +- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/packages/javaimp/gradleTaskBody.inc.kts b/packages/javaimp/gradleTaskBody.inc.kts index 697e743..942814f 100644 --- a/packages/javaimp/gradleTaskBody.inc.kts +++ b/packages/javaimp/gradleTaskBody.inc.kts @@ -1,21 +1,18 @@ // use syntax which is valid both in Groovy and in Kotlin doLast { - println("id=${project.group}:${project.name}:${project.version}") + println("id=${project.group};${project.path};${project.version}") if (project.parent != null) { - println("parent-id=${project.parent.group}:${project.parent.name}:${project.parent.version}") + println("parent-id=${project.parent.group};${project.parent.path};${project.parent.version}") } println("file=${project.buildFile}") - if (project.hasProperty("archivesBaseName")) { // defined by java plugin - println("final-name=" + project.configurations.getByName("archives").artifacts.stream() - .filter { it.type.equals("jar") || it.type.equals("war") } - .map { it.file.path } - .findFirst() - .orElse("")) - } else { - println("final-name=") - } println("build-dir=${project.buildDir}") - if (project.hasProperty("sourceSets")) { // defined by java plugin + if (project.pluginManager.hasPlugin("java")) { + // "archives" configuration and "sourceSets" property defined by java plugin + println("final-name=" + project.configurations.getByName("archives").artifacts.stream() + .filter { it.type.equals("jar") || it.type.equals("war") } + .map { it.file.path } + .findFirst() + .orElse("")) println("source-dirs=" + project.sourceSets.stream() .flatMap { it.allJava.srcDirs.stream().map { it.path } } .collect(Collectors.joining(File.pathSeparator))) @@ -23,6 +20,7 @@ doLast { .flatMap { it.compileClasspath.files.stream().filter { it.name.endsWith("jar") }.map { it.path } } .collect(Collectors.joining(File.pathSeparator))) } else { + println("final-name=") println("source-dirs=") println("dep-jars=") } diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index 77c7dae..74a956a 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -48,10 +48,8 @@ information." (modules (mapcar (lambda (alist) (javaimp--gradle-module-from-alist alist file)) alists))) -(prog1 -;; first module is always root -(javaimp--build-tree (car modules) nil modules) - (message "Loaded tree for %s" file +;; first module is always root +(javaimp--build-tree (car modules) nil modules))) (defun javaimp--gradle-handler () (goto-char (point-min)) @@ -71,8 +69,8 @@ information." (defun javaimp--gradle-module-from-alist (alist file-orig) (make-javaimp-module - :id (javaimp--gradle-id-from-colon-separated (cdr (assq 'id alist))) - :parent-id (javaimp--gradle-id-from-colon-separated (cdr (assq 'parent-id alist))) + :id (javaimp--gradle-id-from-semi-separated (cdr (assq 'id alist))) + :parent-id (javaimp--gradle-id-from-semi-separated (cdr (assq 'parent-id alist))) :file (cdr (assq 'file alist)) :file-orig file-orig ;; jar/war supported @@ -91,12 +89,19 @@ information." :load-ts (current-time) :dep-jars-path-fetcher #'javaimp--gradle-fetch-dep-jars-path)) -(defun javaimp--gradle-id-from-colon-separated (str) +(defun javaimp--gradle-id-from-semi-separated (str) (when str -(let ((parts (split-string str ":" t))) +(let ((parts (split-string str ";" t)) artifact) (unless (= (length parts) 3) -(error "Invalid maven id: %s" str)) - (make-javaimp-id :group (nth 0 parts) :artifact (nth 1 parts) :version (nth 2 parts) +(error "I
[elpa] master a61f860: [javaimp] bump version to 0.7.1
branch: master commit a61f860b319c062154aea63640fcd0bfe5b516fc Author: Filipp Gunbin Commit: Filipp Gunbin [javaimp] bump version to 0.7.1 * packages/javaimp/javaimp.el: Bump version to 0.7.1. * Remove version tags in other files. --- packages/javaimp/javaimp-gradle.el | 1 - packages/javaimp/javaimp-maven.el | 1 - packages/javaimp/javaimp-util.el | 1 - packages/javaimp/javaimp.el| 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/javaimp/javaimp-gradle.el b/packages/javaimp/javaimp-gradle.el index 74a956a..2241da5 100644 --- a/packages/javaimp/javaimp-gradle.el +++ b/packages/javaimp/javaimp-gradle.el @@ -4,7 +4,6 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.6.1 ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by diff --git a/packages/javaimp/javaimp-maven.el b/packages/javaimp/javaimp-maven.el index b523381..524aa77 100644 --- a/packages/javaimp/javaimp-maven.el +++ b/packages/javaimp/javaimp-maven.el @@ -4,7 +4,6 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.6.1 ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by diff --git a/packages/javaimp/javaimp-util.el b/packages/javaimp/javaimp-util.el index 8e1a06c..c03414d 100644 --- a/packages/javaimp/javaimp-util.el +++ b/packages/javaimp/javaimp-util.el @@ -4,7 +4,6 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.6.1 ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by diff --git a/packages/javaimp/javaimp.el b/packages/javaimp/javaimp.el index 6980994..cd340f4 100644 --- a/packages/javaimp/javaimp.el +++ b/packages/javaimp/javaimp.el @@ -4,7 +4,7 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.7 +;; Version: 0.7.1 ;; Keywords: java, maven, gradle, programming ;; This program is free software; you can redistribute it and/or modify
[elpa] master c3eafa9: packages/sql-beeline/sql-beeline.el: Initial commit
branch: master commit c3eafa9b2370e0d0af8cb3053073095dfd74fec0 Author: Filipp Gunbin Commit: Filipp Gunbin packages/sql-beeline/sql-beeline.el: Initial commit --- packages/sql-beeline/sql-beeline.el | 93 + 1 file changed, 93 insertions(+) diff --git a/packages/sql-beeline/sql-beeline.el b/packages/sql-beeline/sql-beeline.el new file mode 100644 index 000..6693bf1 --- /dev/null +++ b/packages/sql-beeline/sql-beeline.el @@ -0,0 +1,93 @@ +;;; sql-beeline.el --- Beeline support for sql.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2020-2020 Free Software Foundation, Inc. + +;; Author: Filipp Gunbin +;; Maintainer: Filipp Gunbin +;; Version: 0.1 +;; Keywords: sql, hive, beeline, hiveserver2 + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +;; TODO +;; +;; - Recognize prompt for a user when !connect is given only url +;; - Turn off echo +;; + +;;; Code: + +(require 'sql) + + +(defcustom sql-beeline-program "beeline" + "Command to start the Beeline (HiveServer2 client)." + :type 'file + :group 'SQL) + +(defcustom sql-beeline-options + '("--silent" "--incremental=false" "--headerInterval=1") + "List of additional options for `sql-beeline-program'." + :type '(repeat string) + :group 'SQL) + +(defcustom sql-beeline-login-params + `((user :default ,(user-login-name)) +(database :default "default") +(server :default "localhost") +(port :default 1)) + "List of login parameters needed to connect to HiveServer2." + :type 'sql-login-params + :group 'SQL) + + +(defun sql-comint-beeline (product options &optional buf-name) + "Create comint buffer and connect to HiveServer2." + (let ((params (append + (list "-u" (format "jdbc:hive2://%s:%d/%s" +sql-server sql-port sql-database)) + (unless (string-empty-p sql-user) + (list "-n" sql-user)) + (unless (string-empty-p sql-password) + (list "-p" sql-password)) + options)) +;; TERM=dumb makes jline library (version 2.12 used in Hive +;; 1.1.0, for example) to fallback to "unsupported" terminal, +;; and in that mode its ConsoleReader emulates password char +;; hiding by emitting prompt together with carriage returns +;; every few milliseconds - we don't want it because it +;; just makes garbage. +(comint-terminfo-terminal "")) +(sql-comint product params buf-name))) + +;;;###autoload +(defun sql-beeline (&optional buffer) + "Run beeline as an inferior process." + (interactive "P") + (sql-product-interactive 'beeline buffer)) + +(eval-after-load "sql" + '(sql-add-product +'beeline "Beeline" +:font-lock 'sql-mode-ansi-font-lock-keywords +:sqli-program 'sql-beeline-program +:sqli-options 'sql-beeline-options +:sqli-login 'sql-beeline-login-params +:sqli-comint-func #'sql-comint-beeline +:list-all '("show tables;" . "!tables") +:list-table '("describe %s;" . "!describe %s") +:prompt-regexp "^[^ .][^>\n]*> " +:prompt-cont-regexp "^[ .]*> ")) + +(provide 'sql-beeline)
[elpa] master c0e9d56: packages/sql-beeline/sql-beeline.el: Remove redundant eval-after-load
branch: master commit c0e9d56b9f27239c6a3082360101920ccb9c85e0 Author: Filipp Gunbin Commit: Filipp Gunbin packages/sql-beeline/sql-beeline.el: Remove redundant eval-after-load --- packages/sql-beeline/sql-beeline.el | 24 +++- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/sql-beeline/sql-beeline.el b/packages/sql-beeline/sql-beeline.el index 069774e..4b6fbf9 100644 --- a/packages/sql-beeline/sql-beeline.el +++ b/packages/sql-beeline/sql-beeline.el @@ -77,19 +77,17 @@ (interactive "P") (sql-product-interactive 'beeline buffer)) -;; FIXME: We required `sql' above, so why use eval-after-load? -(eval-after-load "sql" - '(sql-add-product -'beeline "Beeline" -:font-lock 'sql-mode-ansi-font-lock-keywords -:sqli-program 'sql-beeline-program -:sqli-options 'sql-beeline-options -:sqli-login 'sql-beeline-login-params -:sqli-comint-func #'sql-comint-beeline -:list-all '("show tables;" . "!tables") -:list-table '("describe %s;" . "!describe %s") -:prompt-regexp "^[^ .][^>\n]*> " -:prompt-cont-regexp "^[ .]*> ")) +(sql-add-product + 'beeline "Beeline" + :font-lock 'sql-mode-ansi-font-lock-keywords + :sqli-program 'sql-beeline-program + :sqli-options 'sql-beeline-options + :sqli-login 'sql-beeline-login-params + :sqli-comint-func #'sql-comint-beeline + :list-all '("show tables;" . "!tables") + :list-table '("describe %s;" . "!describe %s") + :prompt-regexp "^[^ .][^>\n]*> " + :prompt-cont-regexp "^[ .]*> ") (provide 'sql-beeline) ;;; sql-beeline.el ends here
[elpa] externals/javaimp 9614e75da5: Avoid with-syntax-table in current buffer in javaimp-parse--decl-suffix
branch: externals/javaimp commit 9614e75da5c347266e3f51cc0fb380d6f082f101 Author: Filipp Gunbin Commit: Filipp Gunbin Avoid with-syntax-table in current buffer in javaimp-parse--decl-suffix --- javaimp-gradle.el | 2 ++ javaimp-parse.el | 95 --- javaimp-util.el | 2 ++ javaimp.el| 2 ++ 4 files changed, 55 insertions(+), 46 deletions(-) diff --git a/javaimp-gradle.el b/javaimp-gradle.el index 608beebb26..076b17deab 100644 --- a/javaimp-gradle.el +++ b/javaimp-gradle.el @@ -20,6 +20,8 @@ (require 'javaimp-util) +(eval-when-compile (require 'subr-x)) + (defcustom javaimp-gradle-program "gradle" "Path to the `gradle' program. If the visited project has local gradlew (Gradle wrapper), it is used in preference." diff --git a/javaimp-parse.el b/javaimp-parse.el index 1178bc5606..af20f35cd1 100644 --- a/javaimp-parse.el +++ b/javaimp-parse.el @@ -146,7 +146,8 @@ Assumes point is outside of any context initially." (defun javaimp-parse--arglist (beg end &optional only-type) "Parse arg list between BEG and END, of the form 'TYPE NAME, ...'. Return list of conses (TYPE . NAME). If ONLY-TYPE is -non-nil, then name parsing is skipped." +non-nil, then name parsing is skipped. This function does not +move point." (let ((substr (buffer-substring-no-properties beg end))) (with-temp-buffer (insert substr) @@ -260,31 +261,30 @@ set, as for `re-search-backward'." (= (scan-lists pos 1 -1) (1+ open-brace))) -(defun javaimp-parse--decl-suffix (regexp brace-pos &optional bound) - "Attempts to parse declaration suffix backwards from point (but -not farther than BOUND), returning non-nil on success. More -precisely, the value is the end of the match for REGEXP. Point -is left before the match. Otherwise, the result is nil and point -is unchanged." - (let ((pos (point))) -(catch 'found - (while (javaimp-parse--rsb-keyword regexp bound t) -(let ((scan-pos (match-end 0))) +(defun javaimp-parse--decl-suffix (regexp brace-pos bound) + "Attempt to parse declaration suffix matching REGEXP backwards +from BRACE-POS, but not farther than BOUND. Return its start on +success, nil otherwise." + (goto-char brace-pos) + (catch 'found +(while (javaimp-parse--rsb-keyword regexp bound t) + (let ((curr-beg (match-beginning 0)) +(substr (buffer-substring-no-properties + (match-end 0) (1+ brace-pos +(with-temp-buffer + (insert substr) (with-syntax-table javaimp--parse-syntax-table -;; Skip over any number of lists, which may be exceptions -;; in "throws", or something like that -(while (and scan-pos (<= scan-pos brace-pos)) - (if (ignore-errors -(= (scan-lists scan-pos 1 -1) ;As in javaimp-parse--preceding - (1+ brace-pos))) - (progn -(goto-char (match-beginning 0)) -(throw 'found (match-end 0))) -(setq scan-pos (ignore-errors - (scan-lists scan-pos 1 0 - ;; just return to start - (goto-char pos) - nil))) +;; Skip over any number of "lists", which may be +;; exceptions in "throws", or something alike +(let ((scan-pos (point-min))) + (while (and scan-pos (< scan-pos (point-max))) +(if (ignore-errors + ;; We're done when we enter the brace block + ;; started by brace-pos + (= (scan-lists scan-pos 1 -1) (point-max))) +(throw 'found curr-beg) + (setq scan-pos (ignore-errors + (scan-lists scan-pos 1 0 (defun javaimp-parse--decl-prefix (&optional bound) "Attempt to parse defun declaration prefix backwards from @@ -432,21 +432,23 @@ brace.") (1+ (point) (let* ((keyword-start (match-beginning 1)) (keyword-end (match-end 1)) - arglist) - (goto-char brace-pos) - ;; "extends" comes before "implements" etc., thus try in this - ;; order - (or (javaimp-parse--decl-suffix "\\_" brace-pos keyword-end) - (javaimp-parse--decl-suffix "\\_" brace-pos keyword-end) - (javaimp-parse--decl-suffix "\\_" brace-pos keyword-end)) - ;; We either skipped back over the valid declaration suffixes, - ;; or there weren't any of them. - (setq arglist (javaimp-parse--arglist keyword-end (point) t)) + (arglist-end +;; "extends" comes befo
[elpa] externals/javaimp 74eefcdee7: Use narrowing instead of temp buffers in low-level parsing
branch: externals/javaimp commit 74eefcdee728fafd3cb5a2b4a7f5a8ad666d1a47 Author: Filipp Gunbin Commit: Filipp Gunbin Use narrowing instead of temp buffers in low-level parsing --- javaimp-parse.el | 153 ++- javaimp.el | 5 +- tests/parse.el | 2 +- 3 files changed, 87 insertions(+), 73 deletions(-) diff --git a/javaimp-parse.el b/javaimp-parse.el index af20f35cd1..513900245f 100644 --- a/javaimp-parse.el +++ b/javaimp-parse.el @@ -148,17 +148,18 @@ Assumes point is outside of any context initially." ...'. Return list of conses (TYPE . NAME). If ONLY-TYPE is non-nil, then name parsing is skipped. This function does not move point." - (let ((substr (buffer-substring-no-properties beg end))) -(with-temp-buffer - (insert substr) + (save-excursion +(save-restriction + (narrow-to-region beg end) (with-syntax-table javaimp--parse-syntax-table (ignore-errors (let (res) +(goto-char (point-max)) (while (progn (javaimp-parse--skip-back-until) (not (bobp))) (push (javaimp-parse--arglist-one-arg only-type) res) - ;; move back to the previous argument, if any + ;; Move back to the previous argument, if any (when (javaimp-parse--skip-back-until (lambda (_last-what _last-pos) (and (not (bobp)) @@ -262,62 +263,73 @@ set, as for `re-search-backward'." (1+ open-brace))) (defun javaimp-parse--decl-suffix (regexp brace-pos bound) - "Attempt to parse declaration suffix matching REGEXP backwards -from BRACE-POS, but not farther than BOUND. Return its start on -success, nil otherwise." + "Attempt to parse defun declaration suffix (like \"extends\" +clause of a class definition) matched by REGEXP. Matches inside +comments/strings are skipped. + +Find match of REGEXP backwards from BRACE-POS (but not farther +than BOUND) and skip complete lists forwards from there, until we +enter the list started by brace at BRACE-POS. If successful, +repeat those steps starting from the last match. The result is +the start of the last successful match, or nil." (goto-char brace-pos) (catch 'found (while (javaimp-parse--rsb-keyword regexp bound t) - (let ((curr-beg (match-beginning 0)) -(substr (buffer-substring-no-properties - (match-end 0) (1+ brace-pos -(with-temp-buffer - (insert substr) - (with-syntax-table javaimp--parse-syntax-table -;; Skip over any number of "lists", which may be -;; exceptions in "throws", or something alike -(let ((scan-pos (point-min))) - (while (and scan-pos (< scan-pos (point-max))) -(if (ignore-errors - ;; We're done when we enter the brace block - ;; started by brace-pos - (= (scan-lists scan-pos 1 -1) (point-max))) -(throw 'found curr-beg) - (setq scan-pos (ignore-errors - (scan-lists scan-pos 1 0 - -(defun javaimp-parse--decl-prefix (&optional bound) + (let ((curr-beg (match-beginning 0))) +(save-excursion + (save-restriction +(narrow-to-region (match-end 0) (1+ brace-pos)) +(with-syntax-table javaimp--parse-syntax-table + ;; Skip over any number of "lists", which may be + ;; exceptions in "throws" clause, or something alike + (let ((scan-pos (point-min))) +(while (and scan-pos (< scan-pos (point-max))) + (if (ignore-errors +;; We're done when we enter the brace block +;; started by brace-pos +(= (scan-lists scan-pos 1 -1) (point-max))) + (throw 'found curr-beg) +(setq scan-pos (ignore-errors + (scan-lists scan-pos 1 0) + +(defun javaimp-parse--decl-prefix (start-pos &optional bound) "Attempt to parse defun declaration prefix backwards from -point (but not farther than BOUND). Matches inside comments / -strings are skipped. Return the beginning of the match (then the -point is also at that position) or nil." +START-POS, but not farther than BOUND. START-POS should be +somewhere inside the defun declaration, but not inside nested +lists like argument list. Return the beginning of the +declaration or nil." + (goto-char start-pos) (javaimp-parse--skip-back-until) - ;; A semicolon, which delimits statements, will just be skipped by - ;; scan-sexps, so find it and use as
[elpa] externals/javaimp aae4d63bd9: Improve doc and tests of low-level parsing functions
branch: externals/javaimp commit aae4d63bd9678cc3997b6f5c85e6aaba3dd42e37 Author: Filipp Gunbin Commit: Filipp Gunbin Improve doc and tests of low-level parsing functions --- javaimp-parse.el | 12 tests/parse.el | 19 +-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/javaimp-parse.el b/javaimp-parse.el index 513900245f..bab4249823 100644 --- a/javaimp-parse.el +++ b/javaimp-parse.el @@ -294,10 +294,14 @@ the start of the last successful match, or nil." (defun javaimp-parse--decl-prefix (start-pos &optional bound) "Attempt to parse defun declaration prefix backwards from -START-POS, but not farther than BOUND. START-POS should be -somewhere inside the defun declaration, but not inside nested -lists like argument list. Return the beginning of the -declaration or nil." +START-POS, but not farther than BOUND or previous semicolon, +whichever comes first. START-POS should be somewhere inside the +defun declaration, but outside any nested lists like argument +list. Return the beginning of the declaration or nil. + +Go back by sexps until we either reach BOUND or a semicolon, or +arrive at something which doesn't look like a part of defun +declaration." (goto-char start-pos) (javaimp-parse--skip-back-until) (let* ((fence (save-excursion diff --git a/tests/parse.el b/tests/parse.el index d586d4ccaf..b9c8f64d26 100644 --- a/tests/parse.el +++ b/tests/parse.el @@ -61,14 +61,29 @@ Exception4>") (should (equal (javaimp-parse--arglist (point-min) (point-max) t) (cdr data)) +(ert-deftest javaimp-parse-decl-suffix () + (dolist (data '(;; ok + (" extends C1 {" "extends" . 2) + (" extends C1 implements I1, I2 {" "extends\\|implements" . 13) + + ;; fail + (" extends C1 ({" "extends") + ("{" "extends"))) +(javaimp-with-temp-buffer nil + (insert (car data)) + (should (equal (cddr data) + (javaimp-parse--decl-suffix + (cadr data) (1- (point)) (point-min))) + (ert-deftest javaimp-parse-decl-prefix () (dolist (data '(;; simple (" void " . 2) (" public static void " . 2) - ;; no sexps + ;; fail - no sexps + ("") (" ") - ;; incomplete sexps + ;; fail - incomplete sexps ("var)") (") ")
[elpa] externals/javaimp updated (aae4d63bd9 -> 784e5f0527)
fgunbin pushed a change to branch externals/javaimp. from aae4d63bd9 Improve doc and tests of low-level parsing functions new 3ea7aebb96 *** empty log message *** new 784e5f0527 Fix javaimp-beginning-of-defun when inside arg list in declaration Summary of changes: javaimp-parse.el | 9 ++-- javaimp.el | 127 +++ 2 files changed, 76 insertions(+), 60 deletions(-)
[elpa] externals/javaimp 784e5f0527 2/2: Fix javaimp-beginning-of-defun when inside arg list in declaration
branch: externals/javaimp commit 784e5f052751eac1c609878de09f1c1ce6fe9bbf Author: Filipp Gunbin Commit: Filipp Gunbin Fix javaimp-beginning-of-defun when inside arg list in declaration --- javaimp.el | 74 ++ 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/javaimp.el b/javaimp.el index 94737cf47b..8c2a4460e5 100644 --- a/javaimp.el +++ b/javaimp.el @@ -877,12 +877,10 @@ nested in methods are not included, see scopes (defun javaimp-imenu--function (_index-name index-position _scope) - ;; TODO use scope open-brace as arg? - (let ((decl-beg (javaimp--beg-of-defun-decl index-position))) -(if decl-beg -(goto-char decl-beg) - (goto-char index-position) - (back-to-indentation + (if-let ((decl-beg (javaimp--beg-of-defun-decl index-position))) + (goto-char decl-beg) +(goto-char index-position) +(back-to-indentation))) @@ -1168,33 +1166,7 @@ PREV-INDEX gives the index of the method itself." (lambda (s) (and (funcall defun-pred s) (funcall sibling-pred s) - ;; Note: when looking for prev/next sibling, it might be - ;; tempting to directly look at prev/next property - ;; change, but this would be correct only by accident - - ;; there might be any scopes in different nests in - ;; between. - (prev - (if (and enc (eq (javaimp-scope-type enc) 'method)) - enc -(if-let* ((next (seq-find - (lambda (s) - (>= (javaimp-scope-open-brace s) pos)) - siblings)) - (next-beg-decl - (javaimp--beg-of-defun-decl -(javaimp-scope-start next) parent-beg)) - (beg-decl - ;; TODO move out of possible arglist - (javaimp--beg-of-defun-decl pos parent-beg)) - ((= next-beg-decl beg-decl))) -;; If we're inside next's declaration - behave as -;; if we were inside its body, so it becomes our -;; prev -next - ;; Just find previous defun - (seq-find (lambda (s) - (< (javaimp-scope-open-brace s) pos)) -(reverse siblings)) + (prev (javaimp--get-prev-scope pos enc parent-beg siblings))) (nconc (list (and parent (javaimp-scope-open-brace parent)) @@ -1206,6 +1178,42 @@ PREV-INDEX gives the index of the method itself." -1)) siblings) +(defun javaimp--get-prev-scope (pos enc parent-beg siblings) + "Subroutine of `javaimp--get-sibling-context'." + ;; Note: when looking for prev/next sibling, it might be tempting to + ;; directly look at prev/next property change, but this would be + ;; correct only by accident - there might be any scopes in different + ;; nests in between. + (if (and enc (eq (javaimp-scope-type enc) 'method)) + enc +(if-let* ((next (seq-find + (lambda (s) + (>= (javaimp-scope-open-brace s) pos)) + siblings)) + (next-beg-decl + (javaimp--beg-of-defun-decl +(javaimp-scope-start next) parent-beg)) + (beg-decl + (let ((tmp pos)) + ;; pos may be inside arg list or some other nested + ;; construct, move out + (while (and tmp + ;; Note that case when both are nil is + ;; also correct: there's no parent and + ;; we're outside of any scope. + (not (eql parent-beg (nth 1 (syntax-ppss tmp) + (setq tmp (nth 1 (syntax-ppss tmp + (when tmp + (javaimp--beg-of-defun-decl tmp parent-beg + ((= next-beg-decl beg-decl))) +;; If we're inside next's declaration - behave as if we were +;; inside its body, so it becomes our prev +next + ;; Just find previous defun + (seq-find (lambda (s) + (< (javaimp-scope-open-brace s) pos)) +(reverse siblings) + (defun javaimp-jump-to-enclosing-scope () "Jump to enclosing scope at point." (interactive)
[elpa] externals/javaimp 3ea7aebb96 1/2: *** empty log message ***
branch: externals/javaimp commit 3ea7aebb96c1f964057f6b1e3e2b3bb9d4c5e3fd Author: Filipp Gunbin Commit: Filipp Gunbin *** empty log message *** --- javaimp-parse.el | 9 - javaimp.el | 57 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/javaimp-parse.el b/javaimp-parse.el index bab4249823..ce51f1ad38 100644 --- a/javaimp-parse.el +++ b/javaimp-parse.el @@ -515,12 +515,11 @@ lambdas are also recognized as such." (defun javaimp-parse--scope-method-or-stmt (brace-pos) "Attempt to parse `method' or `statement' scope." - ;; Take the closest preceding closing paren as the bound - (let ((throws-search-bound (when (javaimp-parse--rsb-keyword ")" nil t 1) - (1+ (point) -(when throws-search-bound + (let ((arglist-end (when (javaimp-parse--rsb-keyword ")" nil t 1) + (1+ (point) +(when arglist-end (let* ((throws-start (javaimp-parse--decl-suffix -"\\_" brace-pos throws-search-bound)) +"\\_" brace-pos arglist-end)) (throws-args (when throws-start (or (javaimp-parse--arglist (+ throws-start (length "throws")) brace-pos t) diff --git a/javaimp.el b/javaimp.el index ea2a79af30..94737cf47b 100644 --- a/javaimp.el +++ b/javaimp.el @@ -877,6 +877,7 @@ nested in methods are not included, see scopes (defun javaimp-imenu--function (_index-name index-position _scope) + ;; TODO use scope open-brace as arg? (let ((decl-beg (javaimp--beg-of-defun-decl index-position))) (if decl-beg (goto-char decl-beg) @@ -1077,33 +1078,41 @@ buffer." (let* ((ctx (javaimp--get-sibling-context)) (parent-start (nth 0 ctx)) (offset-from-prev (if (> arg 0) - (1- arg) + (1- arg) ;prev counts for 1 arg)) (target-idx (- (nth 1 ctx) offset-from-prev)) (siblings (nthcdr 2 ctx))) - (if (or (not siblings) - (< target-idx 0) - (>= target-idx (length siblings))) - (if parent-start - ;; It's not very clear what to do when we need to move - ;; out of current scope. Currently we just move up to - ;; parent, trying to also skip its decl prefix. This - ;; gives acceptable results. - (goto-char (or (javaimp--beg-of-defun-decl parent-start) - parent-start)) -(goto-char (if (> arg 0) - (point-min) - (point-max))) -nil) -(let ((scope (nth target-idx siblings))) - (goto-char (or (javaimp--beg-of-defun-decl - (javaimp-scope-start scope) parent-start) - (javaimp-scope-open-brace scope + (cond ((and (>= target-idx 0) + (< target-idx (length siblings))) + ;; Move to target sibling + (let ((scope (nth target-idx siblings))) + (goto-char (or (javaimp--beg-of-defun-decl + (javaimp-scope-start scope) parent-start) + (javaimp-scope-open-brace scope) +(siblings + ;; Move to start of first/last sibling + (goto-char (javaimp-scope-open-brace + (car (if (< target-idx 0) + siblings +(last siblings)) +(parent-start + (goto-char parent-start) + ;; Move forward one line unless closing brace is on the + ;; same line + (let ((parent-end (ignore-errors + (scan-lists parent-start 1 0 + (unless (and parent-end +(= (line-number-at-pos parent-start) + (line-number-at-pos parent-end))) + (forward-line +(t + (goto-char (if (< target-idx 0) +(point-min) (point-max (defun javaimp--beg-of-defun-decl (pos &optional bound) "Assuming POS is somewhere inside the defun declaration, return the beginning of that declaration. Don't go farther backwards -than BOUND." +than BOUND. POS should not be in arglist or similar list." (save-excursion (save-restriction (widen) @@ -1125,7 +1134,8 @@ than BOUND." SIBLINGS), where SIBLINGS is a list of all sibling defun scopes. PREV-INDEX is the index of the \"previous\" (relative to point) scope in this list, or -1. PARENT-STAR
[elpa] externals/javaimp ae115d66ed: Use scope open-brace as argument to javaimp--beg-of-defun-decl
branch: externals/javaimp commit ae115d66ed90b4a6768e3bf90c5b851f9532aa69 Author: Filipp Gunbin Commit: Filipp Gunbin Use scope open-brace as argument to javaimp--beg-of-defun-decl --- javaimp.el | 23 --- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/javaimp.el b/javaimp.el index 8c2a4460e5..a1daeeafed 100644 --- a/javaimp.el +++ b/javaimp.el @@ -789,8 +789,8 @@ form as CLASS-ALIST in return value of (defsubst javaimp-imenu--make-entry (scope) (list (javaimp-scope-name scope) (if imenu-use-markers -(copy-marker (javaimp-scope-start scope)) - (javaimp-scope-start scope)) +(copy-marker (javaimp-scope-open-brace scope)) + (javaimp-scope-open-brace scope)) #'javaimp-imenu--function scope)) @@ -876,10 +876,10 @@ nested in methods are not included, see (not (javaimp-scope-parent s))) scopes -(defun javaimp-imenu--function (_index-name index-position _scope) +(defun javaimp-imenu--function (_index-name index-position scope) (if-let ((decl-beg (javaimp--beg-of-defun-decl index-position))) (goto-char decl-beg) -(goto-char index-position) +(goto-char (javaimp-scope-start scope)) (back-to-indentation))) @@ -1085,14 +1085,15 @@ buffer." ;; Move to target sibling (let ((scope (nth target-idx siblings))) (goto-char (or (javaimp--beg-of-defun-decl - (javaimp-scope-start scope) parent-start) + (javaimp-scope-open-brace scope) parent-start) (javaimp-scope-open-brace scope) (siblings ;; Move to start of first/last sibling - (goto-char (javaimp-scope-open-brace - (car (if (< target-idx 0) - siblings -(last siblings)) + (let* ((scope (car (if (< target-idx 0) +siblings + (last siblings +(pos (javaimp-scope-open-brace scope))) + (goto-char (or (javaimp--beg-of-defun-decl pos) pos (parent-start (goto-char parent-start) ;; Move forward one line unless closing brace is on the @@ -1192,7 +1193,7 @@ PREV-INDEX gives the index of the method itself." siblings)) (next-beg-decl (javaimp--beg-of-defun-decl -(javaimp-scope-start next) parent-beg)) +(javaimp-scope-open-brace next) parent-beg)) (beg-decl (let ((tmp pos)) ;; pos may be inside arg list or some other nested @@ -1226,7 +1227,7 @@ PREV-INDEX gives the index of the method itself." (not (memq (javaimp-scope-type scope) '(array-init simple-statement statement))) (javaimp--beg-of-defun-decl - (javaimp-scope-start scope))) + (javaimp-scope-open-brace scope))) (javaimp-scope-start scope))) (message "%s %s at position %d" (javaimp-scope-type scope) (javaimp-scope-name scope)
[elpa] externals/javaimp 48fe748fc2: Fix javaimp-end-of-defun to stay inside parent
branch: externals/javaimp commit 48fe748fc287ce01bbb522e43cf3d520e3eccd52 Author: Filipp Gunbin Commit: Filipp Gunbin Fix javaimp-end-of-defun to stay inside parent --- javaimp.el | 32 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/javaimp.el b/javaimp.el index a1daeeafed..fb02dcfdfe 100644 --- a/javaimp.el +++ b/javaimp.el @@ -1083,10 +1083,10 @@ buffer." (cond ((and (>= target-idx 0) (< target-idx (length siblings))) ;; Move to target sibling - (let ((scope (nth target-idx siblings))) - (goto-char (or (javaimp--beg-of-defun-decl - (javaimp-scope-open-brace scope) parent-start) - (javaimp-scope-open-brace scope) + (let* ((scope (nth target-idx siblings)) +(pos (javaimp-scope-open-brace scope))) + (goto-char (or (javaimp--beg-of-defun-decl pos parent-start) + pos (siblings ;; Move to start of first/last sibling (let* ((scope (car (if (< target-idx 0) @@ -1096,15 +1096,16 @@ buffer." (goto-char (or (javaimp--beg-of-defun-decl pos) pos (parent-start (goto-char parent-start) - ;; Move forward one line unless closing brace is on the - ;; same line (let ((parent-end (ignore-errors (scan-lists parent-start 1 0 - (unless (and parent-end -(= (line-number-at-pos parent-start) - (line-number-at-pos parent-end))) + (if (and parent-end +(= (line-number-at-pos parent-start) + (line-number-at-pos parent-end))) + ;; open / close braces are on the same line + (forward-char) (forward-line (t + ;; There're no siblings and no parent (goto-char (if (< target-idx 0) (point-min) (point-max @@ -1119,11 +1120,18 @@ than BOUND. POS should not be in arglist or similar list." (defun javaimp-end-of-defun () "Function to be used as `end-of-defun-function'." - ;; Called after beginning-of-defun-raw, so we can safely inspect - ;; properties + ;; This function is called after javaimp-beginning-of-defun, which + ;; in the normal course will position the point before the + ;; open-brace, so we can inspect property. (when-let* ((brace-pos (next-single-property-change (point) 'javaimp-parse-scope)) - ((get-text-property brace-pos 'javaimp-parse-scope))) + ((get-text-property brace-pos 'javaimp-parse-scope)) + ;; When there're no siblings, javaimp-beginning-of-defun + ;; moves to the parent start. In this case we should + ;; stay inside the parent. + ((eql (nth 1 (syntax-ppss)) +(save-excursion + (nth 1 (syntax-ppss brace-pos)) (ignore-errors (goto-char (scan-lists brace-pos 1 0)
[elpa] externals/javaimp 65599a7954: Version 0.9
branch: externals/javaimp commit 65599a7954821c38e38949b5ec42891b41e75e13 Author: Filipp Gunbin Commit: Filipp Gunbin Version 0.9 --- javaimp.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javaimp.el b/javaimp.el index fb02dcfdfe..500bf6f108 100644 --- a/javaimp.el +++ b/javaimp.el @@ -4,7 +4,7 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.8 +;; Version: 0.9 ;; Keywords: java, maven, gradle, programming ;; This program is free software; you can redistribute it and/or modify
[elpa] externals/javaimp 2ac7afce3c: Use end-of-defun-moves-to-eol, version 0.9.1
branch: externals/javaimp commit 2ac7afce3c6f0b390c4b62c065a898883940d65a Author: Filipp Gunbin Commit: Filipp Gunbin Use end-of-defun-moves-to-eol, version 0.9.1 --- javaimp.el | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/javaimp.el b/javaimp.el index 500bf6f108..7d878b2bfc 100644 --- a/javaimp.el +++ b/javaimp.el @@ -4,7 +4,7 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.9 +;; Version: 0.9.1 ;; Keywords: java, maven, gradle, programming ;; This program is free software; you can redistribute it and/or modify @@ -100,7 +100,7 @@ ;; / module, it parses dependency archives, as well as JDK ones, and ;; it may take quite a while. ;; -;; `javaimp-organize-import': command to organize imports in the +;; `javaimp-organize-imports': command to organize imports in the ;; current buffer, sorting and deleting duplicates. ;; ;; If you don't visit a project, then Javaimp tries to determine @@ -1308,6 +1308,7 @@ defun javadoc to be included in the narrowed region when using (add-hook 'xref-backend-functions #'javaimp-xref--backend nil t) (setq-local parse-sexp-ignore-comments t) (setq-local multibyte-syntax-as-symbol t) +(setq-local end-of-defun-moves-to-eol nil) ;; Discard parse state, if any (setq javaimp-parse--dirty-pos nil) (setq syntax-ppss-table java-mode-syntax-table) @@ -1325,6 +1326,7 @@ defun javadoc to be included in the narrowed region when using (remove-hook 'xref-backend-functions #'javaimp-xref--backend t) (kill-local-variable 'parse-sexp-ignore-comments) (kill-local-variable 'multibyte-syntax-as-symbol) +(kill-local-variable 'end-of-defun-moves-to-eol) (kill-local-variable 'imenu-space-replacement)))
[elpa] externals/csv-mode 56ed871dc2: Fix skipping of empty fields when transposing rows with quotes
branch: externals/csv-mode commit 56ed871dc2feb9a12dce84a590ef9f049cc0405a Author: Filipp Gunbin Commit: Filipp Gunbin Fix skipping of empty fields when transposing rows with quotes * csv-mode.el (csv--collect-fields): Don't do csv-forward-field if on separator, otherwise empty fields are missed. --- csv-mode.el | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/csv-mode.el b/csv-mode.el index 24ed55b7fb..c78c44222e 100644 --- a/csv-mode.el +++ b/csv-mode.el @@ -1321,7 +1321,10 @@ point is assumed to be at the beginning of the line." (split-string row-text csv-separator-regexp) (save-excursion (while (< (setq field-start (point)) row-end-position) - (csv-forward-field 1) + ;; csv-forward-field will skip a separator if point is on + ;; it, and we'll miss an empty field + (unless (memq (following-char) csv-separator-chars) + (csv-forward-field 1)) (push (buffer-substring-no-properties field-start (point)) fields)
[elpa] externals/javaimp 9efdf954d5: Implement next-error support in javaimp-show-scopes-mode
branch: externals/javaimp commit 9efdf954d5d63ebb41c07fea91c3e70cd5ca9b71 Author: Filipp Gunbin Commit: Filipp Gunbin Implement next-error support in javaimp-show-scopes-mode --- javaimp-util.el | 2 +- javaimp.el | 136 2 files changed, 89 insertions(+), 49 deletions(-) diff --git a/javaimp-util.el b/javaimp-util.el index 639474a673..0379a9e308 100644 --- a/javaimp-util.el +++ b/javaimp-util.el @@ -40,7 +40,7 @@ array) javaimp--classlike-scope-types)) -(defconst javaimp--help-scope-type-abbrevs +(defconst javaimp--show-scopes-scope-type-abbrevs '((anonymous-class . "ac") (statement . "st") (simple-statement . "ss") diff --git a/javaimp.el b/javaimp.el index 3ce295a518..fe2d7d9510 100644 --- a/javaimp.el +++ b/javaimp.el @@ -92,9 +92,9 @@ ;; "scopes") parses in ~1.5 seconds, which is not that bad... ;; ;; Parsing is also used for Imenu support. A simple debug command, -;; `javaimp-help-show-scopes', lists all parsed "scopes" (blocks of -;; code in braces). As there's no minor/major mode (yet), you have to -;; set `imenu-create-index-function' in major mode hook yourself. See +;; `javaimp-show-scopes', lists all parsed "scopes" (blocks of code in +;; braces). As there's no minor/major mode (yet), you have to set +;; `imenu-create-index-function' in major mode hook yourself. See ;; example below. ;; ;; - `javaimp-imenu-use-sub-alists' - if non-nil then Imenu items are @@ -116,7 +116,7 @@ ;; ;; (local-set-key (kbd "C-c i") #'javaimp-add-import) ;; (local-set-key (kbd "C-c o") #'javaimp-organize-imports) -;; (local-set-key (kbd "C-c s") #'javaimp-help-show-scopes) +;; (local-set-key (kbd "C-c s") #'javaimp-show-scopes) ;; ;; To enable Imenu (overriding Imenu support from cc-mode): ;; @@ -769,44 +769,54 @@ in a major mode hook." (back-to-indentation)) -;; Help +;; Show scopes -(defvar javaimp-help-keymap +(put 'javaimp-show-scopes-mode 'mode-class 'special) +(define-derived-mode javaimp-show-scopes-mode special-mode "Javaimp Show Scopes" + (setq next-error-function #'javaimp-show-scopes-next-error)) + +(defvar javaimp-show-scopes-mode-map (let ((map (make-sparse-keymap))) -(define-key map "\C-m" #'javaimp-help-goto-scope) -(define-key map [mouse-2] #'javaimp-help-goto-scope-mouse) +(set-keymap-parent map text-mode-map) +(define-key map "\C-m" #'javaimp-show-scopes-goto-scope) +(define-key map [mouse-2] #'javaimp-show-scopes-goto-scope-mouse) +(define-key map "n" #'next-error-no-select) +(define-key map "p" #'previous-error-no-select) +(define-key map "l" #'recenter-current-error) map) - "Keymap for Javaimp help buffers.") + "Javaimp Show Scopes keymap.") -(defun javaimp-help-goto-scope (pos) +(defun javaimp-show-scopes-goto-scope (pos) "Go to scope at point in another window." (interactive "d") - (javaimp-help--goto-scope-1 pos)) + (javaimp-show-scopes--goto-scope-1 pos current-prefix-arg)) ;; TODO handle mouse-1 -(defun javaimp-help-goto-scope-mouse (event) +(defun javaimp-show-scopes-goto-scope-mouse (event) "Go to scope you click on in another window." (interactive "e") (let ((window (posn-window (event-end event))) (pos (posn-point (event-end event (with-current-buffer (window-buffer window) - (javaimp-help--goto-scope-1 pos + (javaimp-show-scopes--goto-scope-1 pos current-prefix-arg -(defun javaimp-help--goto-scope-1 (pos) +(defun javaimp-show-scopes--goto-scope-1 (pos &optional to-start) "Go to the opening brace (`javaimp-scope-open-brace') of the -scope at POS. With prefix arg, go to scope +scope at POS. When TO-START is non-nil, go to scope start (`javaimp-scope-start') instead." - (let ((scope (get-text-property pos 'javaimp-help-scope)) -(file (get-text-property (point-min) 'javaimp-help-file))) -(when (and scope file) - (with-current-buffer (find-file-other-window file) -(goto-char (if current-prefix-arg - (javaimp-scope-start scope) - (javaimp-scope-open-brace scope))) - -(defun javaimp-help-show-scopes (&optional show-all) - "Show scopes in *javaimp-scopes* buffer, with clickable -text. By default, the scopes are only those which appear in + (when-let ((scope (get-text-property pos 'javaimp-show-scopes-scope)) + (file (get-text-property (point-min) 'javaimp-show-scopes-file)) + (buf (find-file-noselect file))) +(with-current-buffer buf + (goto-char (if to-start +
[elpa] externals/javaimp 5294630f6c: Fix show scopes
branch: externals/javaimp commit 5294630f6c456d8a4e87a708bf4dccf6a21e Author: Filipp Gunbin Commit: Filipp Gunbin Fix show scopes --- javaimp.el | 75 -- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/javaimp.el b/javaimp.el index fe2d7d9510..b71bafb7fd 100644 --- a/javaimp.el +++ b/javaimp.el @@ -771,48 +771,50 @@ in a major mode hook." ;; Show scopes -(put 'javaimp-show-scopes-mode 'mode-class 'special) -(define-derived-mode javaimp-show-scopes-mode special-mode "Javaimp Show Scopes" - (setq next-error-function #'javaimp-show-scopes-next-error)) - (defvar javaimp-show-scopes-mode-map (let ((map (make-sparse-keymap))) (set-keymap-parent map text-mode-map) (define-key map "\C-m" #'javaimp-show-scopes-goto-scope) -(define-key map [mouse-2] #'javaimp-show-scopes-goto-scope-mouse) +(define-key map [mouse-2] #'javaimp-show-scopes-goto-scope) (define-key map "n" #'next-error-no-select) (define-key map "p" #'previous-error-no-select) (define-key map "l" #'recenter-current-error) map) "Javaimp Show Scopes keymap.") -(defun javaimp-show-scopes-goto-scope (pos) - "Go to scope at point in another window." - (interactive "d") - (javaimp-show-scopes--goto-scope-1 pos current-prefix-arg)) - ;; TODO handle mouse-1 -(defun javaimp-show-scopes-goto-scope-mouse (event) - "Go to scope you click on in another window." - (interactive "e") - (let ((window (posn-window (event-end event))) -(pos (posn-point (event-end event -(with-current-buffer (window-buffer window) - (javaimp-show-scopes--goto-scope-1 pos current-prefix-arg - -(defun javaimp-show-scopes--goto-scope-1 (pos &optional to-start) - "Go to the opening brace (`javaimp-scope-open-brace') of the -scope at POS. When TO-START is non-nil, go to scope -start (`javaimp-scope-start') instead." - (when-let ((scope (get-text-property pos 'javaimp-show-scopes-scope)) - (file (get-text-property (point-min) 'javaimp-show-scopes-file)) - (buf (find-file-noselect file))) -(with-current-buffer buf - (goto-char (if to-start - (javaimp-scope-start scope) - (javaimp-scope-open-brace scope -(pop-to-buffer buf))) +(defun javaimp-show-scopes-goto-scope (event &optional to-start) + "Go to the opening brace (`javaimp-scope-open-brace') of the scope. +Target scope is determined by location of mouse EVENT, if it's +non-nil. Else, take the scope at current line. When TO-START is +non-nil, go to scope start (`javaimp-scope-start') instead of the +opening brace." + (interactive (list last-nonmenu-event current-prefix-arg)) + (let ((buf (current-buffer)) +(scopes-buf-pos + (if event + (cons (window-buffer (posn-window (event-end event))) + (posn-point (event-end event))) + (cons (current-buffer) + (point +source-file scope) +(with-current-buffer (car scopes-buf-pos) + (setq source-file +(get-text-property (point-min) 'javaimp-show-scopes-file) +scope +(get-text-property (cdr scopes-buf-pos) 'javaimp-show-scopes-scope))) +(unless (and source-file scope) + (user-error "No target scope")) +(pop-to-buffer (find-file-noselect source-file)) +(goto-char (if to-start + (javaimp-scope-start scope) + (javaimp-scope-open-brace scope))) +(next-error-found buf (current-buffer + +(put 'javaimp-show-scopes-mode 'mode-class 'special) +(define-derived-mode javaimp-show-scopes-mode special-mode "Javaimp Show Scopes" + (setq next-error-function #'javaimp-show-scopes-next-error)) (defun javaimp-show-scopes (&optional show-all) "Show scopes in *javaimp-scopes* buffer, with clickable text. @@ -847,18 +849,19 @@ with prefix arg, show all scopes." (while (setq tmp (javaimp-scope-parent tmp)) (setq depth (1+ depth))) (insert (propertize - (format "%5d %2d %s: %s%s\n" + (format "%5d %2d %s: %s%s" (with-current-buffer source-buf (line-number-at-pos (javaimp-scope-start scope))) depth (cdr (assq (javaimp-scope-type scope) javaimp--show-scopes-scope-type-abbrevs)) - (make-string depth ? ) + (make-string (* 2 depth) ? ) (javaimp-scope-name scope))
[elpa] externals/javaimp updated (5294630f6c -> c3d0bfa8d8)
fgunbin pushed a change to branch externals/javaimp. from 5294630f6c Fix show scopes new 4036f52695 javaimp-parse.el: Remove save-excursion from parsers new c3d0bfa8d8 Minor fixes Summary of changes: javaimp-parse.el | 208 +++ javaimp.el | 8 +-- 2 files changed, 108 insertions(+), 108 deletions(-)
[elpa] externals/javaimp 4036f52695 1/2: javaimp-parse.el: Remove save-excursion from parsers
branch: externals/javaimp commit 4036f526952307d71c9eac18ae4f9414cf62ff92 Author: Filipp Gunbin Commit: Filipp Gunbin javaimp-parse.el: Remove save-excursion from parsers --- javaimp-parse.el | 208 +++ 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/javaimp-parse.el b/javaimp-parse.el index a779c68a39..65a31cb422 100644 --- a/javaimp-parse.el +++ b/javaimp-parse.el @@ -210,68 +210,70 @@ is unchanged." ;;; Scopes (defvar javaimp--parse-scope-hook - '(javaimp--parse-scope-array -;; anonymous-class should be before method/stmt because it looks -;; similar, but with "new" in front -javaimp--parse-scope-anonymous-class -javaimp--parse-scope-class -javaimp--parse-scope-simple-stmt -javaimp--parse-scope-method-or-stmt -) - "List of parser functions, each of which is called with BRACE-POS, -the position of opening brace.") + (mapcar (lambda (parser) +(lambda (arg) + (save-excursion +(funcall parser arg + '(javaimp--parse-scope-array +;; anonymous-class should be before method/stmt because it +;; looks similar, but with "new" in front +javaimp--parse-scope-anonymous-class +javaimp--parse-scope-class +javaimp--parse-scope-simple-stmt +javaimp--parse-scope-method-or-stmt +)) + "List of parser functions, each of which is called in +`save-excursion' and with one argument, the position of opening +brace.") (defun javaimp--parse-scope-class (brace-pos) "Attempts to parse 'class' / 'interface' / 'enum' scope." - (save-excursion -(when (javaimp--parse-preceding - (regexp-opt javaimp--parse-classlike-keywords 'symbols) - brace-pos - ;; closest preceding closing paren is a good bound - ;; because there _will be_ such char in frequent case - ;; of method/stmt - (save-excursion - (when (javaimp--parse-rsb-keyword ")" nil t 1) - (1+ (point) - (let* ((keyword-start (match-beginning 1)) - (keyword-end (match-end 1)) - arglist) -(goto-char brace-pos) -(or (javaimp--parse-decl-suffix "\\_" brace-pos keyword-end) -(javaimp--parse-decl-suffix "\\_" brace-pos keyword-end) -(javaimp--parse-decl-suffix "\\_" brace-pos keyword-end)) -;; we either skipped back over the valid declaration -;; suffix(-es), or there wasn't any -(setq arglist (javaimp--parse-arglist keyword-end (point) t)) -(when (= (length arglist) 1) - (make-javaimp-scope :type (intern - (buffer-substring-no-properties - keyword-start keyword-end)) - :name (javaimp--parse-substr-before-< (caar arglist)) - :start keyword-start - :open-brace brace-pos)) + (when (javaimp--parse-preceding + (regexp-opt javaimp--parse-classlike-keywords 'symbols) + brace-pos + ;; closest preceding closing paren is a good bound + ;; because there _will be_ such char in frequent case + ;; of method/stmt + (save-excursion + (when (javaimp--parse-rsb-keyword ")" nil t 1) + (1+ (point) +(let* ((keyword-start (match-beginning 1)) + (keyword-end (match-end 1)) + arglist) + (goto-char brace-pos) + (or (javaimp--parse-decl-suffix "\\_" brace-pos keyword-end) + (javaimp--parse-decl-suffix "\\_" brace-pos keyword-end) + (javaimp--parse-decl-suffix "\\_" brace-pos keyword-end)) + ;; we either skipped back over the valid declaration + ;; suffix(-es), or there wasn't any + (setq arglist (javaimp--parse-arglist keyword-end (point) t)) + (when (= (length arglist) 1) +(make-javaimp-scope :type (intern + (buffer-substring-no-properties +keyword-start keyword-end)) +:name (javaimp--parse-substr-before-< (caar arglist)) +:start keyword-start +:open-brace brace-pos) (defun javaimp--parse-scope-simple-stmt (brace-pos) "Attempts to parse 'simple-statement' scope." - (save-excursion -(and (javaimp--parse-skip-back-until) - (or (and (= (char-before (1- (point))) ?-) ; -> - (= (char-before) ?>)) - (looking-back (regexp-opt javaimp--parse-stmt-keywords 'words) - (- (point) javaimp--parse-
[elpa] externals/javaimp c3d0bfa8d8 2/2: Minor fixes
branch: externals/javaimp commit c3d0bfa8d8bebc15eba622302bf38d236e5fe103 Author: Filipp Gunbin Commit: Filipp Gunbin Minor fixes --- javaimp.el | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/javaimp.el b/javaimp.el index b71bafb7fd..43b9cbd38b 100644 --- a/javaimp.el +++ b/javaimp.el @@ -695,8 +695,8 @@ in a major mode hook." ;; sub-alist (cons t (javaimp-scope-name scope (lambda (res) - (or (functionp (nth 2 res)) ;entry - (cdr res))) ;non-empty sub-alist + (or (functionp (nth 2 res)) ; imenu entry + (cdr res))) ; non-empty sub-alist forest) (let ((entries (mapcar #'javaimp-imenu--make-entry @@ -724,7 +724,7 @@ in a major mode hook." (let* ((scopes (javaimp--parse-get-all-scopes (lambda (scope) (javaimp-test-scope-type scope - '(class interface enum method) + `(,@ javaimp--classlike-scope-types method) javaimp--classlike-scope-types (methods (seq-filter (lambda (scope) @@ -830,7 +830,7 @@ with prefix arg, show all scopes." (unless show-all (lambda (scope) (javaimp-test-scope-type scope -'(class interface enum method) +`(,@ javaimp--classlike-scope-types method) javaimp--classlike-scope-types))) (source-buf (current-buffer)) (source-default-dir default-directory)
[elpa] scratch/javaimp-wip 52c6c71b93: *** empty log message ***
branch: scratch/javaimp-wip commit 52c6c71b93ee165b757aa7b22c6044621377d68f Author: Filipp Gunbin Commit: Filipp Gunbin *** empty log message *** --- javaimp-parse.el | 45 +--- javaimp.el | 69 +--- 2 files changed, 88 insertions(+), 26 deletions(-) diff --git a/javaimp-parse.el b/javaimp-parse.el index 65a31cb422..a07c059267 100644 --- a/javaimp-parse.el +++ b/javaimp-parse.el @@ -374,6 +374,7 @@ it's set to 'unknown' too." (javaimp-scope-start scope)) (goto-char (javaimp-scope-start scope) (setq state (syntax-ppss +;; FIXME don't do this every time (let (parent reset-tail) (while res (if reset-tail @@ -391,9 +392,9 @@ it's set to 'unknown' too." parent))) (defun javaimp--parse-all-scopes () - "Entry point to the scope parsing. Parses scopes in this buffer -which are after `javaimp--parse-dirty-pos', if it points -anywhere. Makes it point nowhere when done." + "Parses all scopes in this buffer which are after +`javaimp--parse-dirty-pos', if it points anywhere. Makes it +point nowhere when done." (unless javaimp--parse-dirty-pos (setq javaimp--parse-dirty-pos (point-min-marker)) (javaimp--parse-setup-buffer)) @@ -419,6 +420,33 @@ anywhere. Makes it point nowhere when done." (setq-local multibyte-syntax-as-symbol t) (add-hook 'after-change-functions #'javaimp--parse-update-dirty-pos)) +(defun javaimp--parse-enclosing-scope (&optional pred) + "Return innermost enclosing scope matching PRED. This function +is intended to use already set properties." + (when (or (not javaimp--parse-dirty-pos) +(marker-position javaimp--parse-dirty-pos)) +(error "Call javaimp--parse-all-scopes first")) + (with-syntax-table javaimp-syntax-table +(let ((state (syntax-ppss))) + ;; Move out of any comment/string + (when (nth 8 ppss) + (goto-char (nth 8 ppss)) + (setq state (syntax-ppss))) + ;; Go up until we get something + (catch 'found +(while t + (let ((res (save-excursion + (javaimp--parse-scopes nil +(when (and (javaimp-scope-p res) + (or (null pred) + (funcall pred res))) + (throw 'found res)) +(if (nth 1 state) +(progn + (goto-char (nth 1 state)) + (setq state (syntax-ppss))) + (throw 'found nil + (defun javaimp--parse-class-abstract-methods () (goto-char (point-max)) (let (res) @@ -518,6 +546,17 @@ them should move point." (push scope res))) res)) +(defun javaimp--parse-get-enclosing-scope (&optional pred parent-pred) + "Return innermost enclosing scope at point which satisfies PRED, +with parents filtered by PARENT-PRED." + (save-excursion +(javaimp--parse-all-scopes)) + (when-let ((scope (javaimp--parse-enclosing-scope pred))) +(setq scope (javaimp--copy-scope scope)) +(when parent-pred + (javaimp--filter-scope-parents scope parent-pred)) +scope)) + (defun javaimp--parse-get-class-abstract-methods () (javaimp--parse-all-scopes) (javaimp--parse-class-abstract-methods)) diff --git a/javaimp.el b/javaimp.el index 43b9cbd38b..81d9d6d11d 100644 --- a/javaimp.el +++ b/javaimp.el @@ -573,11 +573,7 @@ If there's no such directive, then the last resort is just "Return fully-qualified names of all class-like scopes in the current buffer." (let ((package (javaimp--parse-get-package)) -(scopes (javaimp--parse-get-all-scopes - (lambda (scope) - (javaimp-test-scope-type scope - javaimp--classlike-scope-types - javaimp--classlike-scope-types) +(scopes (javaimp--get-defun-scopes t))) (mapcar (lambda (class) (if package (concat package "." class) @@ -721,19 +717,15 @@ in a major mode hook." entries) (defun javaimp-imenu--get-forest () - (let* ((scopes (javaimp--parse-get-all-scopes - (lambda (scope) -(javaimp-test-scope-type scope - `(,@ javaimp--classlike-scope-types method) - javaimp--classlike-scope-types + (let* ((defun-scopes (javaimp--get-defun-scopes)) (methods (seq-filter (lambda (scope) (eq (javaimp-scope-type scope) 'method)) - scopes)) + defun-scopes)) (classes (seq-filter (lambda (scope) (not (eq (javaimp-scope-type scope) '
[elpa] branch scratch/javaimp-wip created (now 52c6c71b93)
fgunbin pushed a change to branch scratch/javaimp-wip. at 52c6c71b93 *** empty log message *** This branch includes the following new commits: new 52c6c71b93 *** empty log message ***
[elpa] scratch/javaimp-wip 606cb3f08a: *** empty log message ***
branch: scratch/javaimp-wip commit 606cb3f08a10bf5e6571657fbec6b13f019a5ead Author: Filipp Gunbin Commit: Filipp Gunbin *** empty log message *** --- javaimp-parse.el | 4 +-- javaimp-util.el | 7 + javaimp.el | 86 3 files changed, 65 insertions(+), 32 deletions(-) diff --git a/javaimp-parse.el b/javaimp-parse.el index a07c059267..89b296b2b5 100644 --- a/javaimp-parse.el +++ b/javaimp-parse.el @@ -547,8 +547,8 @@ them should move point." res)) (defun javaimp--parse-get-enclosing-scope (&optional pred parent-pred) - "Return innermost enclosing scope at point which satisfies PRED, -with parents filtered by PARENT-PRED." + "Return innermost enclosing scope at point, optionally checking +it with PRED, and its parents with PARENT-PRED." (save-excursion (javaimp--parse-all-scopes)) (when-let ((scope (javaimp--parse-enclosing-scope pred))) diff --git a/javaimp-util.el b/javaimp-util.el index 0379a9e308..df9913a9ef 100644 --- a/javaimp-util.el +++ b/javaimp-util.el @@ -153,6 +153,13 @@ left." (setq res (memq (javaimp-scope-type scope) parent-types))) res)) +(defun javaimp--defun-scope-pred (&optional only-classes) + (let ((leaf-types (append javaimp--classlike-scope-types +(unless only-classes '(method) +(lambda (s) + (javaimp-test-scope-type s +leaf-types javaimp--classlike-scope-types + ;; Tree diff --git a/javaimp.el b/javaimp.el index 81d9d6d11d..082773d7b4 100644 --- a/javaimp.el +++ b/javaimp.el @@ -573,7 +573,7 @@ If there's no such directive, then the last resort is just "Return fully-qualified names of all class-like scopes in the current buffer." (let ((package (javaimp--parse-get-package)) -(scopes (javaimp--get-defun-scopes t))) +(scopes (javaimp--parse-get-all-scopes (javaimp--defun-scope-pred t))) (mapcar (lambda (class) (if package (concat package "." class) @@ -717,7 +717,8 @@ in a major mode hook." entries) (defun javaimp-imenu--get-forest () - (let* ((defun-scopes (javaimp--get-defun-scopes)) + (let* ((defun-scopes + (javaimp--parse-get-all-scopes (javaimp--defun-scope-pred))) (methods (seq-filter (lambda (scope) (eq (javaimp-scope-type scope) 'method)) @@ -815,7 +816,7 @@ opening brace." (save-excursion (save-restriction (widen) - (javaimp--get-defun-scopes + (javaimp--parse-get-all-scopes (javaimp--defun-scope-pred) (source-buf (current-buffer)) (source-default-dir default-directory) (buf (get-buffer-create "*javaimp-scopes*"))) @@ -878,29 +879,64 @@ opening brace." (defun javaimp-beginning-of-defun (arg) "Function to be used as `beginning-of-defun-function'." - (unless (zerop arg) -(let (enclosing scopes) - (save-excursion -(save-restriction - (widen) - ;; TODO pass pred - (setq enclosing (javaimp--parse-get-enclosing-scope) -;; TODO leave only enclosing's siblings -scopes (javaimp--get-defun-scopes - ;; TODO leave siblings from enclosing in scopes; take ARGth - ;; relative sibling; - - ;; ? if not found - (goto-char (if (< 0 arg) - (point-min) - (point-max))) -(zerop arg + (if (zerop arg) + t +(when (> arg 0) (setq arg (1- arg))) +(let (found) + (when-let* ((tmp (javaimp--get-sibling-defuns)) + (enc-idx (car tmp)) + (siblings (cdr tmp)) + (target-idx + (let ((val (- enc-idx arg))) + (cond ((< val 0) +0) + ((>= val (length siblings)) +(1- (length siblings))) + (t +(setq found t) +val) +(goto-char (javaimp-scope-open-brace +(nth target-idx siblings + found))) (defun javaimp-end-of-defun () "Function to be used as `end-of-defun-function'." ;; TODO where we start? ) +(defun javaimp--get-sibling-defuns () + "Return list of the form (ENCLOSING-INDEX . SIBLINGS), where +SIBLINGS is a list of all sibling defun scopes. ENCLOSING-INDEX, +if non-nil, is an index of the enclosing scope in this list. If +it's nil then we're between top-level defuns." + (save-excursion +(save-restriction + (widen) + (let* ((defun-pred (javaimp--defun-scope-pred)) + (enc (javaimp--parse-get-enclosing-scope defun-pred)) + (sibling-pred +
[elpa] scratch/javaimp-wip 544e9d428c: *** empty log message ***
branch: scratch/javaimp-wip commit 544e9d428c9283cfb0649e8a3894b9760655dd9d Author: Filipp Gunbin Commit: Filipp Gunbin *** empty log message *** --- javaimp-parse.el | 4 ++-- javaimp-util.el | 9 + javaimp.el | 56 +++- 3 files changed, 42 insertions(+), 27 deletions(-) diff --git a/javaimp-parse.el b/javaimp-parse.el index 89b296b2b5..fb1d6bc6b7 100644 --- a/javaimp-parse.el +++ b/javaimp-parse.el @@ -429,8 +429,8 @@ is intended to use already set properties." (with-syntax-table javaimp-syntax-table (let ((state (syntax-ppss))) ;; Move out of any comment/string - (when (nth 8 ppss) - (goto-char (nth 8 ppss)) + (when (nth 8 state) + (goto-char (nth 8 state)) (setq state (syntax-ppss))) ;; Go up until we get something (catch 'found diff --git a/javaimp-util.el b/javaimp-util.el index df9913a9ef..3faa8fad57 100644 --- a/javaimp-util.el +++ b/javaimp-util.el @@ -160,6 +160,15 @@ left." (javaimp-test-scope-type s leaf-types javaimp--classlike-scope-types +(defun javaimp--scope-same-parent-pred (parent) + (if parent + (lambda (s) +(and (javaimp-scope-parent s) + (= (javaimp-scope-open-brace (javaimp-scope-parent s)) +(javaimp-scope-open-brace parent +(lambda (s) + (not (javaimp-scope-parent s) + ;; Tree diff --git a/javaimp.el b/javaimp.el index 082773d7b4..5ccc37f847 100644 --- a/javaimp.el +++ b/javaimp.el @@ -573,7 +573,7 @@ If there's no such directive, then the last resort is just "Return fully-qualified names of all class-like scopes in the current buffer." (let ((package (javaimp--parse-get-package)) -(scopes (javaimp--parse-get-all-scopes (javaimp--defun-scope-pred t))) +(scopes (javaimp--parse-get-all-scopes (javaimp--defun-scope-pred t (mapcar (lambda (class) (if package (concat package "." class) @@ -884,10 +884,10 @@ opening brace." (when (> arg 0) (setq arg (1- arg))) (let (found) (when-let* ((tmp (javaimp--get-sibling-defuns)) - (enc-idx (car tmp)) + (prev-idx (or (car tmp) -1)) (siblings (cdr tmp)) (target-idx - (let ((val (- enc-idx arg))) + (let ((val (- prev-idx arg))) (cond ((< val 0) 0) ((>= val (length siblings)) @@ -905,36 +905,42 @@ opening brace." ) (defun javaimp--get-sibling-defuns () - "Return list of the form (ENCLOSING-INDEX . SIBLINGS), where -SIBLINGS is a list of all sibling defun scopes. ENCLOSING-INDEX, -if non-nil, is an index of the enclosing scope in this list. If -it's nil then we're between top-level defuns." + "Return list of the form (PREV-INDEX . SIBLINGS), where SIBLINGS +is a list of all sibling defun scopes. PREV-INDEX is the index +of the \"previous\" (relative to point) scope in this list, or +nil." (save-excursion (save-restriction (widen) - (let* ((defun-pred (javaimp--defun-scope-pred)) + (let* ((pos (point)) + (defun-pred (javaimp--defun-scope-pred)) (enc (javaimp--parse-get-enclosing-scope defun-pred)) (sibling-pred - (if (and enc (javaimp-scope-parent enc)) - ;; scopes with same parent - (lambda (s) -(and (javaimp-scope-parent s) - (= (javaimp-scope-open-brace (javaimp-scope-parent s)) -(javaimp-scope-open-brace (javaimp-scope-parent enc) -;; we're in a top-level scope or outside it, and -;; need other top-level scopes -(lambda (s) - (not (javaimp-scope-parent s) + (if (and enc (eq (javaimp-scope-type enc) 'method)) + ;; We're inside a method, and need to look at + ;; sibling methods within same parent (it's ok for + ;; parent to be nil) + (javaimp--scope-same-parent-pred (javaimp-scope-parent enc)) +;; We're either inside a type (but not within its +;; methods), or just at top-level. Look at defuns +;; whose parent is enc. +(javaimp--scope-same-parent-pred enc))) (siblings (javaimp--parse-get-all-scopes (lambda (s) (and (funcall defun-pred s) - (funcall sibling-pred s)) -(cons (and enc - (seq-position -siblings enc -(lambda (s1 s2) - (= (javaimp-scope-open-b
[elpa] scratch/javaimp-wip af69f40efc: *** empty log message ***
branch: scratch/javaimp-wip commit af69f40efc73d7c8dbe5739786e085bf161228e1 Author: Filipp Gunbin Commit: Filipp Gunbin *** empty log message *** --- javaimp-parse.el | 74 +--- javaimp-tests.el | 13 +- javaimp-util.el | 19 ++- javaimp.el | 16 +++- 4 files changed, 74 insertions(+), 48 deletions(-) diff --git a/javaimp-parse.el b/javaimp-parse.el index fb1d6bc6b7..4ac9df2aaf 100644 --- a/javaimp-parse.el +++ b/javaimp-parse.el @@ -215,9 +215,9 @@ is unchanged." (save-excursion (funcall parser arg '(javaimp--parse-scope-array -;; anonymous-class should be before method/stmt because it +;; anon-class should be before method/stmt because it ;; looks similar, but with "new" in front -javaimp--parse-scope-anonymous-class +javaimp--parse-scope-anon-class javaimp--parse-scope-class javaimp--parse-scope-simple-stmt javaimp--parse-scope-method-or-stmt @@ -270,8 +270,8 @@ brace.") (- (point) 2)) :open-brace brace-pos))) -(defun javaimp--parse-scope-anonymous-class (brace-pos) - "Attempts to parse 'anonymous-class' scope." +(defun javaimp--parse-scope-anon-class (brace-pos) + "Attempts to parse 'anon-class' scope." ;; skip arg-list and ws (when (and (progn (javaimp--parse-skip-back-until) @@ -285,8 +285,10 @@ brace.") (setq start (match-beginning 0) arglist (javaimp--parse-arglist (match-end 0) end t)) (when (= (length arglist) 1) -(make-javaimp-scope :type 'anonymous-class -:name (javaimp--parse-substr-before-< (caar arglist)) +(make-javaimp-scope :type 'anon-class +:name +(concat "" +(javaimp--parse-substr-before-< (caar arglist))) :start start :open-brace brace-pos)) @@ -345,14 +347,19 @@ brace.") :open-brace brace-pos))) (defun javaimp--parse-scopes (count) - "Attempts to parse COUNT enclosing scopes at point. Returns most -nested one, with its parents sets accordingly. If COUNT is nil -then goes all the way up. Examines and sets property -'javaimp-parse-scope' at each scope's open brace. If neither of -functions in `javaimp--parse-scope-hook' return non-nil then the -property value is set to the symbol `unknown'. Additionally, if -a scope is recognized, but any of its parents is 'unknown', then -it's set to 'unknown' too." + "Attempts to parse COUNT enclosing scopes at point. +Returns most nested one, with its parents sets accordingly. If +COUNT is nil then goes all the way up. + +Examines and sets property 'javaimp-parse-scope' at each scope's +open brace. If neither of functions in +`javaimp--parse-scope-hook' return non-nil then the property +value is set to the symbol `unknown'. Additionally, if a scope +is recognized, but any of its parents is 'unknown', then it's set +to 'unknown' too. + +If point is inside of any comment/string then this function does +nothing." (let ((state (syntax-ppss)) res) (unless (syntax-ppss-context state) @@ -364,6 +371,8 @@ it's set to 'unknown' too." (when (= (char-after) ?{) (let ((scope (get-text-property (point) 'javaimp-parse-scope))) (unless scope + + ;; TODO (setq scope (or (run-hook-with-args-until-success 'javaimp--parse-scope-hook (point)) 'unknown)) @@ -374,10 +383,10 @@ it's set to 'unknown' too." (javaimp-scope-start scope)) (goto-char (javaimp-scope-start scope) (setq state (syntax-ppss -;; FIXME don't do this every time (let (parent reset-tail) (while res (if reset-tail +;; overwrite property value with `unknown' (when (javaimp-scope-p (car res)) (let ((pos (javaimp-scope-open-brace (car res (put-text-property pos (1+ pos) 'javaimp-parse-scope 'unknown))) @@ -395,7 +404,7 @@ it's set to 'unknown' too." "Parses all scopes in this buffer which are after `javaimp--parse-dirty-pos', if it points anywhere. Makes it point nowhere when done." - (unless javaimp--parse-dirty-pos + (unless javaimp--parse-dirty-pos ;init on first use (setq j
[elpa] externals/javaimp 9bdcbda0f3: Add javaimp-beginning-of-defun / javaimp-end-of-defun
branch: externals/javaimp commit 9bdcbda0f3f4dd799d7bfed5c5b8ce4a722c8d73 Author: Filipp Gunbin Commit: Filipp Gunbin Add javaimp-beginning-of-defun / javaimp-end-of-defun --- javaimp-parse.el | 130 +-- javaimp-tests.el | 13 +++--- javaimp-util.el | 27 +++- javaimp.el | 113 +-- 4 files changed, 210 insertions(+), 73 deletions(-) diff --git a/javaimp-parse.el b/javaimp-parse.el index 65a31cb422..bf705b0ed7 100644 --- a/javaimp-parse.el +++ b/javaimp-parse.el @@ -215,9 +215,9 @@ is unchanged." (save-excursion (funcall parser arg '(javaimp--parse-scope-array -;; anonymous-class should be before method/stmt because it +;; anon-class should be before method/stmt because it ;; looks similar, but with "new" in front -javaimp--parse-scope-anonymous-class +javaimp--parse-scope-anon-class javaimp--parse-scope-class javaimp--parse-scope-simple-stmt javaimp--parse-scope-method-or-stmt @@ -252,10 +252,9 @@ brace.") (buffer-substring-no-properties keyword-start keyword-end)) :name (javaimp--parse-substr-before-< (caar arglist)) -:start keyword-start -:open-brace brace-pos) +:start keyword-start) -(defun javaimp--parse-scope-simple-stmt (brace-pos) +(defun javaimp--parse-scope-simple-stmt (_brace-pos) "Attempts to parse 'simple-statement' scope." (and (javaimp--parse-skip-back-until) (or (and (= (char-before (1- (point))) ?-) ; -> @@ -267,11 +266,10 @@ brace.") :name (or (match-string 1) "lambda") :start (or (match-beginning 1) - (- (point) 2)) -:open-brace brace-pos))) + (- (point) 2) -(defun javaimp--parse-scope-anonymous-class (brace-pos) - "Attempts to parse 'anonymous-class' scope." +(defun javaimp--parse-scope-anon-class (brace-pos) + "Attempts to parse 'anon-class' scope." ;; skip arg-list and ws (when (and (progn (javaimp--parse-skip-back-until) @@ -285,10 +283,11 @@ brace.") (setq start (match-beginning 0) arglist (javaimp--parse-arglist (match-end 0) end t)) (when (= (length arglist) 1) -(make-javaimp-scope :type 'anonymous-class -:name (javaimp--parse-substr-before-< (caar arglist)) -:start start -:open-brace brace-pos)) +(make-javaimp-scope :type 'anon-class +:name +(concat "" +(javaimp--parse-substr-before-< (caar arglist))) +:start start)) (defun javaimp--parse-scope-method-or-stmt (brace-pos) "Attempts to parse 'method' or 'statement' scope." @@ -332,27 +331,30 @@ brace.") (cdr arglist-region (concat name "(" (mapconcat #'car args ",") ")")) name) - :start (point) - :open-brace brace-pos + :start (point) -(defun javaimp--parse-scope-array (brace-pos) +(defun javaimp--parse-scope-array (_brace-pos) "Attempts to parse 'array' scope." (and (javaimp--parse-skip-back-until) (member (char-before) '(?, ?\])) (make-javaimp-scope :type 'array :name "" - :start nil - :open-brace brace-pos))) + :start nil))) (defun javaimp--parse-scopes (count) - "Attempts to parse COUNT enclosing scopes at point. Returns most -nested one, with its parents sets accordingly. If COUNT is nil -then goes all the way up. Examines and sets property -'javaimp-parse-scope' at each scope's open brace. If neither of -functions in `javaimp--parse-scope-hook' return non-nil then the -property value is set to the symbol `unknown'. Additionally, if -a scope is recognized, but any of its parents is 'unknown', then -it's set to 'unknown' too." + "Attempts to parse COUNT enclosing scopes at point. +Returns most nested one, with its parents sets accordingly. If +COUNT is nil then goes all the way up. + +Examines and sets property 'javaimp-parse-scope' a
[elpa] branch scratch/javaimp-wip deleted (was af69f40efc)
fgunbin pushed a change to branch scratch/javaimp-wip. was af69f40efc *** empty log message *** This change permanently discards the following revisions: discards af69f40efc *** empty log message *** discards 544e9d428c *** empty log message *** discards 606cb3f08a *** empty log message *** discards 52c6c71b93 *** empty log message ***
[elpa] externals/javaimp c1cee724fb: Fix javaimp-test--parse-scope-anon-class
branch: externals/javaimp commit c1cee724fb8ff93a1a3cafb283017504e2e4efd1 Author: Filipp Gunbin Commit: Filipp Gunbin Fix javaimp-test--parse-scope-anon-class --- javaimp-tests.el | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/javaimp-tests.el b/javaimp-tests.el index e7dc31314b..a895fc6658 100644 --- a/javaimp-tests.el +++ b/javaimp-tests.el @@ -105,15 +105,15 @@ extends Bar> {" (ert-deftest javaimp-test--parse-scope-anon-class () (javaimp-test--single-parser #'javaimp--parse-scope-anon-class '(" = new Object < Class1 , Class2 > ( 1 + 1 , baz ) {" - anon-class "Object") + anon-class "Object") `(,(subst-char-in-string ? ?\n " = new Object < Class1 , Class2 > ( 1 + 1 , baz ) {") - anon-class "Object") + anon-class "Object") '(" = (obj.getField()).new Object(1, baz) {" - anon-class "Object") + anon-class "Object") '(" = obj.new Object<>(1, baz) {" - anon-class "Object") + anon-class "Object") )) (ert-deftest javaimp-test--parse-scope-method-or-stmt ()
[elpa] externals/javaimp ba57d3ce4f: Fix javaimp-beginning-of-defun, javaimp-end-of-defun
branch: externals/javaimp commit ba57d3ce4f4a0bceed57a13d3d7d797424cbbc92 Author: Filipp Gunbin Commit: Filipp Gunbin Fix javaimp-beginning-of-defun, javaimp-end-of-defun --- javaimp-parse.el | 4 +-- javaimp.el | 87 ++-- 2 files changed, 55 insertions(+), 36 deletions(-) diff --git a/javaimp-parse.el b/javaimp-parse.el index bf705b0ed7..fd3b2ae305 100644 --- a/javaimp-parse.el +++ b/javaimp-parse.el @@ -534,8 +534,8 @@ and END, both exclusive, optionally filtering them with PRED, and their parents with PARENT-PRED. Neither of PRED or PARENT-PRED should move point. Note that parents may be outside of region given by BEG and END. BEG is the LIMIT argument to -`previous-single-property-change', END defaults to end of -accessible portion of the buffer." +`previous-single-property-change', and so may be nil. END +defaults to end of accessible portion of the buffer." (javaimp--parse-all-scopes) (let ((pos (or end (point-max))) scope res) diff --git a/javaimp.el b/javaimp.el index 2729ccd278..4d42e4adb7 100644 --- a/javaimp.el +++ b/javaimp.el @@ -27,7 +27,8 @@ ;; helps you to quickly add imports when stepping through compilation ;; errors. In addition, this module provides good Imenu support for ;; Java source files - with nesting and abstract methods in interfaces -;; and abstract classes. +;; and abstract classes. It provides suitable functions to use as +;; beginning-of-defun-function / end-of-defun-function as well. ;; ;; ;; Quick start: @@ -91,11 +92,11 @@ ;; java.util.Collections from JDK 11 (~ 5600 lines and > 1000 ;; "scopes") parses in ~1.5 seconds, which is not that bad... ;; -;; Parsing is also used for Imenu support. A simple debug command, -;; `javaimp-show-scopes', lists all parsed "scopes" (blocks of code in -;; braces). As there's no minor/major mode (yet), you have to set -;; `imenu-create-index-function' in major mode hook yourself. See -;; example below. +;; Parsing is also used for Imenu support and for navigation commands. +;; As there's no minor/major mode (yet), you have to set +;; `imenu-create-index-function' and `beginning-of-defun-function' / +;; `end-of-defun-function' in major mode hook yourself. See example +;; below. ;; ;; - `javaimp-imenu-use-sub-alists' - if non-nil then Imenu items are ;; presented in a nested fashion, instead of a flat list (the @@ -104,6 +105,10 @@ ;; See other defcustoms via 'M-x customize-group javaimp'. ;; ;; +;; `javaimp-show-scopes' lists all parsed "scopes" (blocks of code in +;; braces), with support for `next-error'. +;; +;; ;; Configuration example: ;; ;; (require 'javaimp) @@ -118,7 +123,7 @@ ;; (local-set-key (kbd "C-c o") #'javaimp-organize-imports) ;; (local-set-key (kbd "C-c s") #'javaimp-show-scopes) ;; -;; To override other functions from cc-mode: +;; To set imenu and navigation functions use: ;; ;; (setq imenu-create-index-function #'javaimp-imenu-create-index) ;; @@ -891,26 +896,34 @@ opening brace." (if (zerop arg) t (when (> arg 0) (setq arg (1- arg))) -(when-let* ((tmp (javaimp--get-sibling-defuns)) -(prev-idx (or (car tmp) -1)) -(siblings (cdr tmp)) -(target-idx (- prev-idx arg))) - (when (and (>= target-idx 0) - (< target-idx (length siblings))) -(goto-char (javaimp-scope-open-brace -(nth target-idx siblings))) +(let* ((ctx (javaimp--get-sibling-context)) + (prev-idx (or (nth 2 ctx) -1)) + (siblings (nthcdr 3 ctx)) + (target-idx (- prev-idx arg))) + (cond ((or (not siblings) (< target-idx 0)) + (goto-char (nth 0 ctx)) + nil) +((>= target-idx (length siblings)) + (goto-char (nth 1 ctx)) + nil) +(t + (goto-char (javaimp-scope-open-brace + (nth target-idx siblings (defun javaimp-end-of-defun () "Function to be used as `end-of-defun-function'." - (ignore-errors -(goto-char - (scan-lists (point) 1 0 - -(defun javaimp--get-sibling-defuns () - "Return list of the form (PREV-INDEX . SIBLINGS), where SIBLINGS -is a list of all sibling defun scopes. PREV-INDEX is the index -of the \"previous\" (relative to point) scope in this list, or -nil." + (when (javaimp-scope-p + (get-text-property (point) 'javaimp-parse-scope)) +(ignore-errors + (goto-char + (scan-lists (point) 1 0) + +(defun javaimp--get-sibling-context () + "Return list of the form (FLOOR CEILING PREV-INDEX . SIBLINGS), +where SIBLINGS is a list of all sibling defun scopes. PREV-INDEX +is the index of the
[elpa] externals/javaimp 74f101433b: Fix tests
branch: externals/javaimp commit 74f101433b1821ed4827b4ac2a1ddcad6542630a Author: Filipp Gunbin Commit: Filipp Gunbin Fix tests --- javaimp-tests.el | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/javaimp-tests.el b/javaimp-tests.el index a895fc6658..42b5daa069 100644 --- a/javaimp-tests.el +++ b/javaimp-tests.el @@ -165,7 +165,10 @@ throws E1 {" (dolist (item test-items) (with-temp-buffer (insert (nth 0 item)) - (let* ((javaimp--parse-scope-hook parser) + (let* ((javaimp--parse-scope-hook + (lambda (arg) +(save-excursion + (funcall parser arg (scopes (javaimp--parse-get-all-scopes))) (should (= 1 (length scopes))) (should (eq (javaimp-scope-type (car scopes)) (nth 1 item)))
[elpa] externals/javaimp a434ee9660: Reorganize project structure
branch: externals/javaimp commit a434ee966015752c65dc503de5159046c1edac42 Author: Filipp Gunbin Commit: Filipp Gunbin Reorganize project structure --- .elpaignore | 4 + Makefile | 25 ++ javaimp-gradle.el| 49 +-- javaimp-maven.el | 79 +++-- javaimp-parse.el | 343 +++--- javaimp-tests.el | 424 +-- javaimp-util.el | 155 ++--- javaimp.el | 150 {testdata => tests/data}/gradle-multi.tar.gz | Bin {testdata => tests/data}/maven-multi.tar.gz | Bin {testdata => tests/data}/maven-single.tar.gz | Bin {testdata => tests/data}/test1-misc-classes.java | 0 javaimp-tests-gradle.el => tests/gradle.el | 46 ++- tests/imenu.el | 85 + javaimp-tests-maven.el => tests/maven.el | 51 ++- javaimp-tests.el => tests/parse.el | 293 +--- tests/tests.el | 24 ++ 17 files changed, 672 insertions(+), 1056 deletions(-) diff --git a/.elpaignore b/.elpaignore new file mode 100644 index 00..c7946ef938 --- /dev/null +++ b/.elpaignore @@ -0,0 +1,4 @@ +.gitignore +Makefile +tests +javaimp-tests.el diff --git a/Makefile b/Makefile new file mode 100644 index 00..6c8f3ec3e9 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +# -*- Makefile -*- + +# "make check" by default runs non-expensive tests. To run all tests, +# use "make check SELECTOR=t". + +EMACS = emacs -Q -batch -L . +SRCS = javaimp-util.el javaimp-gradle.el javaimp-maven.el javaimp-parse.el javaimp.el +TESTS = $(wildcard tests/*.el) +OBJS = $(SRCS:.el=.elc) $(TESTS:.el=.elc) +SELECTOR ?= (not (tag :expensive)) + +.PHONY: all check test clean + +%.elc: %.el + ${EMACS} -f batch-byte-compile $^ + +all: $(OBJS) + +check test: all + ${EMACS} \ + $(addprefix -l ,$(OBJS)) \ + -eval '(ert-run-tests-batch-and-exit (quote ${SELECTOR}))' + +clean: + $(RM) -f $(OBJS) diff --git a/javaimp-gradle.el b/javaimp-gradle.el index e3b801a5be..bed838d712 100644 --- a/javaimp-gradle.el +++ b/javaimp-gradle.el @@ -20,30 +20,37 @@ (require 'javaimp-util) -(defun javaimp--gradle-visit (file) +(defcustom javaimp-gradle-program "gradle" + "Path to the `gradle' program. If the visited project has local +gradlew (Gradle wrapper), it is used in preference." + :type 'string + :group 'javaimp) + + +(defun javaimp-gradle-visit (file) "Calls gradle on FILE to get various project information. Passes specially crafted init file as -I argument to gradle and invokes task contained in it. This task outputs all needed information." (message "Visiting Gradle build file %s..." file) - (let* ((alists (javaimp--gradle-call file #'javaimp--gradle-handler)) + (let* ((alists (javaimp-gradle--call file #'javaimp-gradle--handler)) (modules (mapcar (lambda (alist) -(javaimp--gradle-module-from-alist alist file)) +(javaimp-gradle--module-from-alist alist file)) alists))) ;; first module is always root (message "Building tree for root: %s" (javaimp-print-id (javaimp-module-id (car modules (list - (javaimp--build-tree (car modules) modules - ;; more or less reliable way to find children - ;; is to look for modules with "this" as the - ;; parent - (lambda (el tested) -(equal (javaimp-module-parent-id tested) - (javaimp-module-id el))) - -(defun javaimp--gradle-handler () + (javaimp-tree-build (car modules) modules +;; more or less reliable way to find children +;; is to look for modules with "this" as the +;; parent + (lambda (el tested) + (equal (javaimp-module-parent-id tested) + (javaimp-module-id el))) + +(defun javaimp-gradle--handler () "Parse current buffer into list of project descriptors, each of which is an alist of attributes (NAME . VALUE). Each attribute occupies one line, and is of the form 'NAME=VALUE'. See file @@ -65,12 +72,12 @@ descriptor." (push alist res)) (nreverse res))) -(defun javaimp--gradle-module-from-alist (alist file-orig) +(defun javaimp-gradle--module-from-alist (alist file-orig) "Make `javaimp-module' structure
[elpa] externals/javaimp 032d3a8639: Cleanup and rename javaimp-cygpath-convert-maybe
branch: externals/javaimp commit 032d3a86395953237e0f7f6d178cd965b62ad560 Author: Filipp Gunbin Commit: Filipp Gunbin Cleanup and rename javaimp-cygpath-convert-maybe --- javaimp-gradle.el | 6 +++--- javaimp-maven.el | 8 javaimp-util.el | 25 + javaimp.el| 2 +- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/javaimp-gradle.el b/javaimp-gradle.el index bed838d712..4a159fab89 100644 --- a/javaimp-gradle.el +++ b/javaimp-gradle.el @@ -82,7 +82,7 @@ descriptor." :file (cdr (assq 'file alist)) :file-orig file-orig ;; jar/war supported - :final-name (when-let ((final-name (javaimp-cygpath-convert-maybe + :final-name (when-let ((final-name (javaimp-cygpath-convert-file-name (cdr (assq 'final-name alist) (and (member (file-name-extension final-name) '("jar" "war")) final-name)) @@ -90,7 +90,7 @@ descriptor." (javaimp--split-native-path (cdr (assq 'source-dirs alist :build-dir (file-name-as-directory - (javaimp-cygpath-convert-maybe + (javaimp-cygpath-convert-file-name (cdr (assq 'build-dir alist :dep-jars (javaimp--split-native-path (cdr (assq 'dep-jars alist))) :load-ts (current-time) @@ -147,7 +147,7 @@ descriptor." ;; java-library projects. See ;; https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_classes_usage "-Dorg.gradle.java.compile-classpath-packaging=true" - "-I" (javaimp-cygpath-convert-maybe + "-I" (javaimp-cygpath-convert-file-name (expand-file-name "javaimp-init-script.gradle" (concat javaimp-basedir (file-name-as-directory "support" diff --git a/javaimp-maven.el b/javaimp-maven.el index fafaad3d00..f29ff5030b 100644 --- a/javaimp-maven.el +++ b/javaimp-maven.el @@ -122,15 +122,15 @@ resulting module trees." (javaimp-xml-child 'finalName build-elt)) "." packaging))) :source-dirs (list (file-name-as-directory -(javaimp-cygpath-convert-maybe +(javaimp-cygpath-convert-file-name (javaimp-xml-first-child (javaimp-xml-child 'sourceDirectory build-elt (file-name-as-directory -(javaimp-cygpath-convert-maybe +(javaimp-cygpath-convert-file-name (javaimp-xml-first-child (javaimp-xml-child 'testSourceDirectory build-elt) :build-dir (file-name-as-directory -(javaimp-cygpath-convert-maybe +(javaimp-cygpath-convert-file-name (javaimp-xml-first-child (javaimp-xml-child 'directory build-elt :dep-jars nil ; dep-jars is initialized lazily on demand :load-ts (current-time) @@ -219,7 +219,7 @@ are somewhat arbitrary." (javaimp--call-build-tool program handler - "-f" (javaimp-cygpath-convert-maybe file) + "-f" (javaimp-cygpath-convert-file-name file) task))) (provide 'javaimp-maven) diff --git a/javaimp-util.el b/javaimp-util.el index 8813b7afb6..645e65286b 100644 --- a/javaimp-util.el +++ b/javaimp-util.el @@ -234,24 +234,25 @@ error, the cache for FILE is cleared." ;; instead of calling `cygpath'. See ;; https://cygwin.com/ml/cygwin/2013-03/msg00228.html -(defun javaimp-cygpath-convert-maybe (path &optional mode is-really-path) - "On Cygwin, converts PATH using cygpath according to MODE and -IS-REALLY-PATH. If MODE is `unix' (the default), adds -u switch. -If MODE is `windows', adds -m switch. If `is-really-path' is -non-nil, adds `-p' switch. On other systems, PATH is returned -unchanged." - (if (and path (eq system-type 'cygwin)) +(defun javaimp-cygpath-convert-file-name (filename &optional mode is-path) + "On Cygwin, converts FILENAME using `cygpath' program according +to MODE. If MODE is `unix' (the default), adds `-u' switch. If +MODE is `windows', adds `-m' switch. If IS-PATH is +non-nil, adds `-p' switch. On non-Cygwin systems just returns +the FILENAME unchanged." + (or mode (setq mode 'unix)) + (if (and filename (eq system-type 'cygwin)) (progn - (unless mode (setq mode 'unix)) (let (args) (push (cond ((eq mode 'unix) "-u") ((eq mode 'windows) "-m") (t (error "In
[elpa] externals/javaimp 7c587270ee: More renames & cleanups
branch: externals/javaimp commit 7c587270eeefc9db27b235fbc63312227bcc5b75 Author: Filipp Gunbin Commit: Filipp Gunbin More renames & cleanups --- javaimp-gradle.el | 8 javaimp-maven.el | 4 ++-- javaimp-util.el | 39 --- javaimp.el| 33 - 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/javaimp-gradle.el b/javaimp-gradle.el index 4a159fab89..6fd35e6660 100644 --- a/javaimp-gradle.el +++ b/javaimp-gradle.el @@ -87,12 +87,12 @@ descriptor." (and (member (file-name-extension final-name) '("jar" "war")) final-name)) :source-dirs (mapcar #'file-name-as-directory -(javaimp--split-native-path +(javaimp-split-native-path (cdr (assq 'source-dirs alist :build-dir (file-name-as-directory (javaimp-cygpath-convert-file-name (cdr (assq 'build-dir alist - :dep-jars (javaimp--split-native-path (cdr (assq 'dep-jars alist))) + :dep-jars (javaimp-split-native-path (cdr (assq 'dep-jars alist))) :load-ts (current-time) :dep-jars-fetcher #'javaimp-gradle--fetch-dep-jars :raw nil)) @@ -122,7 +122,7 @@ descriptor." (javaimp-module-file-orig module) (lambda () (re-search-forward "^dep-jars=\\(.*\\)$") - (javaimp--split-native-path (match-string 1))) + (javaimp-split-native-path (match-string 1))) (let ((mod-path (mapconcat #'javaimp-id-artifact (cdr ids) ":"))) (unless (string-empty-p mod-path) (format ":%s:" mod-path) @@ -139,7 +139,7 @@ descriptor." (program (if (file-exists-p local-gradlew) (concat default-directory local-gradlew) javaimp-gradle-program))) -(javaimp--call-build-tool +(javaimp-call-build-tool program handler "-q" diff --git a/javaimp-maven.el b/javaimp-maven.el index f29ff5030b..49b4388b3a 100644 --- a/javaimp-maven.el +++ b/javaimp-maven.el @@ -201,7 +201,7 @@ are somewhat arbitrary." (lambda () (search-forward "Dependencies classpath:") (forward-line 1) - (javaimp--split-native-path (thing-at-point 'line))) + (javaimp-split-native-path (thing-at-point 'line))) "dependency:build-classpath" ;; Invoke in original file's directory because there may be local ;; build tool wrapper. @@ -216,7 +216,7 @@ are somewhat arbitrary." (program (if (file-exists-p local-mvnw) (concat default-directory local-mvnw) javaimp-mvn-program))) -(javaimp--call-build-tool +(javaimp-call-build-tool program handler "-f" (javaimp-cygpath-convert-file-name file) diff --git a/javaimp-util.el b/javaimp-util.el index 645e65286b..a8850487d2 100644 --- a/javaimp-util.el +++ b/javaimp-util.el @@ -44,7 +44,7 @@ it is initialized from the JAVA_HOME environment variable." :group 'javaimp) (defvar javaimp-tool-output-buf-name "*javaimp-tool-output*" - "Name of the buffer to which `javaimp--call-build-tool' copies + "Name of the buffer to which `javaimp-call-build-tool' copies build tool output. Can be let-bound to nil to suppress copying.") @@ -196,38 +196,7 @@ additionally tested by PRED." -;; Misc - -(defsubst javaimp--get-file-ts (file) - (nth 5 (file-attributes file))) - -(defun javaimp--get-file-classes-cached (file cache-sym class-reader) - "Return list of classes for FILE. Use CACHE-SYM as a cache, it -should be an alist with elements of the form (FILE -. CACHED-FILE). If not found in cache, or the cache is outdated, -then classes are read using CLASS-READER, which should be a -function of one argument, a FILE. If that function throws an -error, the cache for FILE is cleared." - (condition-case err - (let ((cached-file - (alist-get file (symbol-value cache-sym) nil nil #'string=))) -(when (or (not cached-file) - ;; If the file doesn't exist this will be current - ;; time, and thus condition always true - (> (float-time (javaimp--get-file-ts file)) -(float-time (javaimp-cached-file-read-ts cached-file - (setq cached-file (make-javaimp-cached-file -:file file -:read-ts (javaimp--get-file-ts file) -:classes (funcall class-reader file -(setf (alist-get file (symbol-value cache-sym) nil 'remove #'string=) - cached-file) -(javaimp-cached-file-classes cached-file)) -(t - ;; Clear on any error - (setf (alist-
[elpa] branch externals/sql-cassandra created (now a203380be4)
fgunbin pushed a change to branch externals/sql-cassandra. at a203380be4 Initial commit This branch includes the following new commits: new a203380be4 Initial commit
[elpa] externals/sql-cassandra a203380be4: Initial commit
branch: externals/sql-cassandra commit a203380be4fb70e914945703fb8b022186694e35 Author: Filipp Gunbin Commit: Filipp Gunbin Initial commit --- packages/sql-cassandra/sql-cassandra.el | 195 1 file changed, 195 insertions(+) diff --git a/packages/sql-cassandra/sql-cassandra.el b/packages/sql-cassandra/sql-cassandra.el new file mode 100644 index 00..825e4fca92 --- /dev/null +++ b/packages/sql-cassandra/sql-cassandra.el @@ -0,0 +1,195 @@ +;;; sql-cassandra.el --- Cassandra support for sql.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2022-2022 Free Software Foundation, Inc. + +;; Author: Filipp Gunbin +;; Maintainer: Filipp Gunbin +;; Version: 0.1 +;; Keywords: sql, cassandra, cql, cqlsh + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +;;; Code: + +(require 'sql) +(require 'seq) + +(defcustom sql-cassandra-program "cqlsh" + "Command to start the Cassandra client." + :type 'file + :group 'SQL) + +(defcustom sql-cassandra-options + '("--no-color") + "List of additional options for `sql-cassandra-program'." + :type '(repeat string) + :group 'SQL) + +(defcustom sql-cassandra-login-params + `((user :default ,(user-login-name)) +password +(database :default "system") +(server :default "localhost") +(port :default 9042)) + "List of login parameters needed to connect to Cassandra cluster." + :type 'sql-login-params + :group 'SQL) + + +(defconst sql-cassandra-special-commands + '("capture" "cls" "copy" "describe" "expand" "login" "serial" +"source" "unicode" "clear" "consistency" "desc" "exit" "help" +"paging" "show" "tracing") + "Special commands recognized by cqlsh. + +Refer to: +https://cassandra.apache.org/doc/latest/cassandra/tools/cqlsh.html#special-commands";) + +(defconst sql-cassandra-native-types + '("ascii" "bigint" "blob" "boolean" "counter" "date" "decimal" +"double" "duration" "float" "inet" "int" "smallint" "text" "time" +"timestamp" "timeuuid" "tinyint" "uuid" "varchar" "varint") + "Cassandra native types. + +Refer to + https://cassandra.apache.org/doc/latest/cassandra/cql/types.html#native-types";) + +(defconst sql-cassandra-reserved-types + '("bitstring" "byte" "complex" "enum" "interval" "macaddr") + "Cassandra reserved types. + +Refer to + https://cassandra.apache.org/doc/latest/cassandra/cql/appendices.html#appendix-b-cql-reserved-types.";) + +(defconst sql-cassandra-keywords + '("add" "aggregate" "all" "allow" "alter" "and" "apply" "as" "asc" +"ascii" "authorize" "batch" "begin" "bigint" "blob" "boolean" +"by" "called" "clustering" "columnfamily" "compact" "contains" +"count" "counter" "create" "custom" "date" "decimal" "delete" +"desc" "describe" "distinct" "double" "drop" "entries" "execute" +"exists" "filtering" "finalfunc" "float" "from" "frozen" "full" +"function" "functions" "grant" "if" "in" "index" "inet" "infinity" +"initcond" "input" "insert" "int" "into" "json" "key" "keys" +"keyspace" "keyspaces" "language" "limit" "list" "login" "map" +"modify" "nan" "nologin&qu
[elpa] main f2a8444b2e: * elpa-packages (sql-cassandra): New package
branch: main commit f2a8444b2eaf74211504e4bdfed925bbcd5452f5 Author: Filipp Gunbin Commit: Filipp Gunbin * elpa-packages (sql-cassandra): New package --- elpa-packages | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/elpa-packages b/elpa-packages index 06003bc5fb..bd04950149 100644 --- a/elpa-packages +++ b/elpa-packages @@ -565,6 +565,7 @@ ("sotlisp":url "https://github.com/Malabarba/speed-of-thought-lisp";) ("spinner":url "https://github.com/Malabarba/spinner.el";) ("sql-beeline":url nil) + ("sql-cassandra" :url nil) ("sql-indent" :url "https://github.com/alex-hhh/emacs-sql-indent";) ("sql-smie":url nil) ("ssh-deploy" :url "https://github.com/cjohansson/emacs-ssh-deploy";) @@ -634,7 +635,7 @@ ("vc-hgcmd" :url "https://github.com/muffinmad/emacs-vc-hgcmd"; :auto-sync t) ("vc-backup" :url "https://git.sr.ht/~pkal/vc-backup"; - :auto-sync t) + :auto-sync t) ("vcard" :url nil) ("vdiff" :url "https://github.com/justbur/emacs-vdiff";) ("vcl-mode" :url "git://git.gnu.org.ua/vcl-mode")
[elpa] branch externals/sql-cassandra deleted (was a203380be4)
fgunbin pushed a change to branch externals/sql-cassandra. was a203380be4 Initial commit This change permanently discards the following revisions: discards a203380be4 Initial commit
[elpa] externals/sql-cassandra 19a9bf5412: Initial commit
branch: externals/sql-cassandra commit 19a9bf54120c816f9635ed144b5be67bb11a31ea Author: Filipp Gunbin Commit: Filipp Gunbin Initial commit --- sql-cassandra.el | 195 +++ 1 file changed, 195 insertions(+) diff --git a/sql-cassandra.el b/sql-cassandra.el new file mode 100644 index 00..825e4fca92 --- /dev/null +++ b/sql-cassandra.el @@ -0,0 +1,195 @@ +;;; sql-cassandra.el --- Cassandra support for sql.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2022-2022 Free Software Foundation, Inc. + +;; Author: Filipp Gunbin +;; Maintainer: Filipp Gunbin +;; Version: 0.1 +;; Keywords: sql, cassandra, cql, cqlsh + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see <http://www.gnu.org/licenses/>. + +;;; Code: + +(require 'sql) +(require 'seq) + +(defcustom sql-cassandra-program "cqlsh" + "Command to start the Cassandra client." + :type 'file + :group 'SQL) + +(defcustom sql-cassandra-options + '("--no-color") + "List of additional options for `sql-cassandra-program'." + :type '(repeat string) + :group 'SQL) + +(defcustom sql-cassandra-login-params + `((user :default ,(user-login-name)) +password +(database :default "system") +(server :default "localhost") +(port :default 9042)) + "List of login parameters needed to connect to Cassandra cluster." + :type 'sql-login-params + :group 'SQL) + + +(defconst sql-cassandra-special-commands + '("capture" "cls" "copy" "describe" "expand" "login" "serial" +"source" "unicode" "clear" "consistency" "desc" "exit" "help" +"paging" "show" "tracing") + "Special commands recognized by cqlsh. + +Refer to: +https://cassandra.apache.org/doc/latest/cassandra/tools/cqlsh.html#special-commands";) + +(defconst sql-cassandra-native-types + '("ascii" "bigint" "blob" "boolean" "counter" "date" "decimal" +"double" "duration" "float" "inet" "int" "smallint" "text" "time" +"timestamp" "timeuuid" "tinyint" "uuid" "varchar" "varint") + "Cassandra native types. + +Refer to + https://cassandra.apache.org/doc/latest/cassandra/cql/types.html#native-types";) + +(defconst sql-cassandra-reserved-types + '("bitstring" "byte" "complex" "enum" "interval" "macaddr") + "Cassandra reserved types. + +Refer to + https://cassandra.apache.org/doc/latest/cassandra/cql/appendices.html#appendix-b-cql-reserved-types.";) + +(defconst sql-cassandra-keywords + '("add" "aggregate" "all" "allow" "alter" "and" "apply" "as" "asc" +"ascii" "authorize" "batch" "begin" "bigint" "blob" "boolean" +"by" "called" "clustering" "columnfamily" "compact" "contains" +"count" "counter" "create" "custom" "date" "decimal" "delete" +"desc" "describe" "distinct" "double" "drop" "entries" "execute" +"exists" "filtering" "finalfunc" "float" "from" "frozen" "full" +"function" "functions" "grant" "if" "in" "index" "inet" "infinity" +"initcond" "input" "insert" "int" "into" "json" "key" "keys" +"keyspace" "keyspaces" "language" "limit" "list" "login" "map" +"modify" "nan" "nologin" "norecursive" "nosuperuser" "not&quo
[elpa] branch externals/sql-cassandra created (now 19a9bf5412)
fgunbin pushed a change to branch externals/sql-cassandra. at 19a9bf5412 Initial commit This branch includes the following new commits: new 19a9bf5412 Initial commit
[elpa] externals/sql-cassandra 1358c2eda1: .gitignore: New file
branch: externals/sql-cassandra commit 1358c2eda10cf905e9228e5da4d2e0fb96211292 Author: Filipp Gunbin Commit: Filipp Gunbin .gitignore: New file --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore new file mode 100644 index 00..6a5760af08 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/sql-cassandra-pkg.el +/sql-cassandra-autoloads.el +*.elc
[elpa] externals/sql-cassandra 3e919c88b2: Move defconsts inside eval-when-compile
branch: externals/sql-cassandra commit 3e919c88b248e6030694c1d090c81a487cf549ba Author: Filipp Gunbin Commit: Filipp Gunbin Move defconsts inside eval-when-compile --- sql-cassandra.el | 69 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/sql-cassandra.el b/sql-cassandra.el index 825e4fca92..dd783aca6c 100644 --- a/sql-cassandra.el +++ b/sql-cassandra.el @@ -47,52 +47,53 @@ :group 'SQL) -(defconst sql-cassandra-special-commands - '("capture" "cls" "copy" "describe" "expand" "login" "serial" -"source" "unicode" "clear" "consistency" "desc" "exit" "help" -"paging" "show" "tracing") - "Special commands recognized by cqlsh. +(eval-when-compile + (defconst sql-cassandra-special-commands +'("capture" "cls" "copy" "describe" "expand" "login" "serial" + "source" "unicode" "clear" "consistency" "desc" "exit" "help" + "paging" "show" "tracing") +"Special commands recognized by cqlsh. Refer to: https://cassandra.apache.org/doc/latest/cassandra/tools/cqlsh.html#special-commands";) -(defconst sql-cassandra-native-types - '("ascii" "bigint" "blob" "boolean" "counter" "date" "decimal" -"double" "duration" "float" "inet" "int" "smallint" "text" "time" -"timestamp" "timeuuid" "tinyint" "uuid" "varchar" "varint") - "Cassandra native types. + (defconst sql-cassandra-native-types +'("ascii" "bigint" "blob" "boolean" "counter" "date" "decimal" + "double" "duration" "float" "inet" "int" "smallint" "text" "time" + "timestamp" "timeuuid" "tinyint" "uuid" "varchar" "varint") +"Cassandra native types. Refer to https://cassandra.apache.org/doc/latest/cassandra/cql/types.html#native-types";) -(defconst sql-cassandra-reserved-types - '("bitstring" "byte" "complex" "enum" "interval" "macaddr") - "Cassandra reserved types. + (defconst sql-cassandra-reserved-types +'("bitstring" "byte" "complex" "enum" "interval" "macaddr") +"Cassandra reserved types. Refer to https://cassandra.apache.org/doc/latest/cassandra/cql/appendices.html#appendix-b-cql-reserved-types.";) -(defconst sql-cassandra-keywords - '("add" "aggregate" "all" "allow" "alter" "and" "apply" "as" "asc" -"ascii" "authorize" "batch" "begin" "bigint" "blob" "boolean" -"by" "called" "clustering" "columnfamily" "compact" "contains" -"count" "counter" "create" "custom" "date" "decimal" "delete" -"desc" "describe" "distinct" "double" "drop" "entries" "execute" -"exists" "filtering" "finalfunc" "float" "from" "frozen" "full" -"function" "functions" "grant" "if" "in" "index" "inet" "infinity" -"initcond" "input" "insert" "int" "into" "json" "key" "keys" -"keyspace" "keyspaces" "language" "limit" "list" "login" "map" -"modify" "nan" "nologin" "norecursive" "nosuperuser" "not" "null" -"of" "on" "options" "or" "order" "password" "permission" "permissions" -"primary" "rename" "replace" "returns" "revoke" "role" "roles" -"schema" "select" "set" "sfunc" "smallint" "static" "storage" -"stype" "superuser" "table" "text" "time" "timestamp" "timeuuid" -"tinyint" "to" "token" "trigger" "truncate" "ttl" "tuple" "type" -"unlogged" "update" "use" "user" "users" "using" "uuid" "values" -"varchar" "varint" "where" "with" "writetime") - "Cassandra keywords. - -Refer to https://cassandra.apache.org/doc/latest/cassandra/cql/appendices.html#appendix-A";) + (defconst sql-cassandra-keywords +'("add" "aggregate" "all" "allow" "alter" "and" "apply" "as" "asc" + "ascii" "authorize" "batch" "begin" "bigint" "blob" "boolean" + "by" "called" "clustering" "columnfamily" "compact" "contains" + "count" "counter" "create" "custom" "date" "decimal" "delete" + "desc" "describe" "distinct" "double" "drop" "entries" "execute" + "exists" "filtering" "finalfunc" "float" "from" "frozen" "full" + "function" "functions" "grant" "if" "in" "index" "inet" "infinity" + "initcond" "input" "insert" "int" "into" "json" "key" "keys" + "keyspace" "keyspaces" "language" "limit" "list" "login" "map" + "modify" "nan" "nologin" "norecursive" "nosuperuser" "not" "null" + "of" "on" "options" "or" "order" "password" "permission" "permissions" + "primary" "rename" "replace" "returns" "revoke" "role" "roles" + "schema" "select" "set" "sfunc" "smallint" "static" "storage" + "stype" "superuser" "table" "text" "time" "timestamp" "timeuuid" + "tinyint" "to" "token" "trigger" "truncate" "ttl" "tuple" "type" + "unlogged" "update" "use" "user" "users" "using" "uuid" "values" + "varchar" "varint" "where" "with" "writetime") +"Cassandra keywords. + +Refer to https://cassandra.apache.org/doc/latest/cassandra/cql/appendices.html#appendix-A";)) (defvar sql-cassandra-font-lock-keywords (eval-when-compile
[elpa] externals/javaimp 81bd14f2fa: Use progress reporter for reading jars / parsing sources
branch: externals/javaimp commit 81bd14f2fa4ef5ff23fb89445e74b9934090fa69 Author: Filipp Gunbin Commit: Filipp Gunbin Use progress reporter for reading jars / parsing sources --- javaimp-gradle.el | 21 --- javaimp-maven.el | 13 +++-- javaimp-util.el | 26 + javaimp.el| 169 ++ 4 files changed, 131 insertions(+), 98 deletions(-) diff --git a/javaimp-gradle.el b/javaimp-gradle.el index 6fd35e6660..24e00761ab 100644 --- a/javaimp-gradle.el +++ b/javaimp-gradle.el @@ -33,14 +33,16 @@ gradlew (Gradle wrapper), it is used in preference." Passes specially crafted init file as -I argument to gradle and invokes task contained in it. This task outputs all needed information." - (message "Visiting Gradle build file %s..." file) + (when javaimp-verbose +(message "Visiting Gradle build file %s..." file)) (let* ((alists (javaimp-gradle--call file #'javaimp-gradle--handler)) (modules (mapcar (lambda (alist) (javaimp-gradle--module-from-alist alist file)) alists))) ;; first module is always root -(message "Building tree for root: %s" - (javaimp-print-id (javaimp-module-id (car modules +(when javaimp-verbose + (message "Building tree for root: %s" + (javaimp-print-id (javaimp-module-id (car modules) (list (javaimp-tree-build (car modules) modules ;; more or less reliable way to find children @@ -133,13 +135,15 @@ descriptor." ;; in build file directory. (default-directory (file-name-directory file)) ;; Prefer local gradle wrapper - (local-gradlew (if (memq system-type '(cygwin windows-nt)) + (local-gradlew (if (eq system-type '(windows-nt)) "gradlew.bat" "gradlew")) (program (if (file-exists-p local-gradlew) (concat default-directory local-gradlew) -javaimp-gradle-program))) -(javaimp-call-build-tool +javaimp-gradle-program)) + (task (concat mod-path "javaimpTask"))) +(message "Calling Gradle task %s on %s ..." task file) +(javaimp-call-java-program program handler "-q" @@ -149,8 +153,7 @@ descriptor." "-Dorg.gradle.java.compile-classpath-packaging=true" "-I" (javaimp-cygpath-convert-file-name (expand-file-name "javaimp-init-script.gradle" - (concat javaimp-basedir - (file-name-as-directory "support" - (concat mod-path "javaimpTask" + (file-name-concat javaimp-basedir "support"))) + task))) (provide 'javaimp-gradle) diff --git a/javaimp-maven.el b/javaimp-maven.el index 49b4388b3a..02a036c76f 100644 --- a/javaimp-maven.el +++ b/javaimp-maven.el @@ -35,7 +35,8 @@ mvnw (Maven wrapper), it is used in preference." reads project structure from the output and records which files belong to which modules and other module information. Returns resulting module trees." - (message "Visiting Maven POM file %s..." file) + (when javaimp-verbose +(message "Visiting Maven POM file %s..." file)) (let* ((xml-tree (javaimp-maven--call file #'javaimp-maven--effective-pom-handler @@ -76,8 +77,9 @@ resulting module trees." modules))) (cdr modules) (mapcar (lambda (root) -(message "Building tree for root: %s" - (javaimp-print-id (javaimp-module-id root))) +(when javaimp-verbose + (message "Building tree for root: %s" + (javaimp-print-id (javaimp-module-id root (javaimp-tree-build root modules ;; more or less reliable way to find children is to @@ -210,13 +212,14 @@ are somewhat arbitrary." (defun javaimp-maven--call (file handler task &optional dir) (let* ((default-directory (or dir (file-name-directory file))) ;; Prefer local mvn wrapper - (local-mvnw (if (memq system-type '(cygwin windows-nt)) + (local-mvnw (if (memq system-type '(windows-nt)) "mvnw.cmd" "mvnw")) (program (if (file-exists-p local-mvnw) (concat default-directory local-mvnw) javaimp-mvn-program))) -(javaimp-call-build-tool +(message "Calling Maven task %s on %s ..." task f
[elpa] externals/sql-cassandra becfd49d11: Update for rewritten sql-interactive-remove-continuation-prompt
branch: externals/sql-cassandra commit becfd49d11dc6924a1cd33e8efb4bb079865c6ba Author: Filipp Gunbin Commit: Filipp Gunbin Update for rewritten sql-interactive-remove-continuation-prompt --- sql-cassandra.el | 19 ++- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/sql-cassandra.el b/sql-cassandra.el index dd783aca6c..c569829067 100644 --- a/sql-cassandra.el +++ b/sql-cassandra.el @@ -132,10 +132,6 @@ Refer to https://cassandra.apache.org/doc/latest/cassandra/cql/appendices.html#a (remove-hook 'sql-login-hook #'sql-cassandra--setup-interactive-mode) (setq comint-process-echoes t) - ;; Remove prefix from echoed continuation lines, otherwise comint - ;; doesn't recognize them - (add-hook 'comint-output-filter-functions - #'sql-cassandra--remove-echo-prefix 0 t) ;; Use our product's terminator (setq-local sql-send-terminator t) @@ -150,18 +146,6 @@ Refer to https://cassandra.apache.org/doc/latest/cassandra/cql/appendices.html#a (not (re-search-backward "^disabled query paging" nil t))) (sleep-for 0.1 -(defun sql-cassandra--remove-echo-prefix (_string) - "Remove prefix which cqlsh adds to each line it echoes. This -function is intended to be added to -`comint-output-filter-functions'." - (when-let ((process (get-buffer-process (current-buffer))) -(pmark (process-mark process))) -(save-excursion - (goto-char comint-last-output-start) - (while (re-search-forward "^ +\\.\\{3\\} " pmark t) - (replace-match "") - - ;;;###autoload (defun sql-cassandra (&optional buffer) "Run Cassandra client as an inferior process." @@ -178,7 +162,8 @@ function is intended to be added to :sqli-comint-func #'sql-comint-cassandra :list-all "describe tables" :list-table "describe table %s" - :prompt-regexp "^[^ .][^>\n]*> " + :prompt-regexp "^cqlsh:[[:alnum:]_]*> " + :prompt-cont-regexp "^ +\\.\\{3\\} " :syntax-alist '(;; map / set / udt literals (?{ . "(") (?} . ")") ;; list literals
[elpa] externals/sql-cassandra f0daf06e19: Require emacs 29. Bump version.
branch: externals/sql-cassandra commit f0daf06e1933cf207449538adc455412998acd02 Author: Filipp Gunbin Commit: Filipp Gunbin Require emacs 29. Bump version. --- sql-cassandra.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql-cassandra.el b/sql-cassandra.el index c569829067..d4aa1a0f48 100644 --- a/sql-cassandra.el +++ b/sql-cassandra.el @@ -4,7 +4,8 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin -;; Version: 0.1 +;; Package-Requires: ((emacs "29")) +;; Version: 0.2 ;; Keywords: sql, cassandra, cql, cqlsh ;; This program is free software; you can redistribute it and/or modify
[elpa] externals/javaimp 0afe95ca1f: Use ert-x in tests
branch: externals/javaimp commit 0afe95ca1fe9ae2d2478ee21439e60475ead3f84 Author: Filipp Gunbin Commit: Filipp Gunbin Use ert-x in tests --- Makefile | 2 +- javaimp-tests.el | 23 +++-- tests/gradle.el| 4 ++-- tests/imenu.el | 9 +++- tests/maven.el | 7 +++ tests/parse.el | 4 ++-- tests/{data => resources}/gradle-multi.tar.gz | Bin tests/{data => resources}/maven-multi.tar.gz | Bin tests/{data => resources}/maven-single.tar.gz | Bin .../test1.java}| 0 tests/tests.el | 4 ++-- 11 files changed, 25 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 6c8f3ec3e9..9164c1a52a 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ # use "make check SELECTOR=t". EMACS = emacs -Q -batch -L . -SRCS = javaimp-util.el javaimp-gradle.el javaimp-maven.el javaimp-parse.el javaimp.el +SRCS = javaimp-util.el javaimp-gradle.el javaimp-maven.el javaimp-parse.el javaimp.el javaimp-tests.el TESTS = $(wildcard tests/*.el) OBJS = $(SRCS:.el=.elc) $(TESTS:.el=.elc) SELECTOR ?= (not (tag :expensive)) diff --git a/javaimp-tests.el b/javaimp-tests.el index 165eef1ec2..9542ae2774 100644 --- a/javaimp-tests.el +++ b/javaimp-tests.el @@ -5,19 +5,20 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin +(require 'ert-x) + (defun javaimp-call-with-data (filename handler) "Untar FILENAME into temporary directory and call HANDLER, supplying that directory name as the only arg." - (let ((tmpdir (file-name-as-directory (make-temp-file "javaimp" t -(unwind-protect -(let ((rc (call-process - "tar" nil nil nil - "-x" - "-f" filename - "-C" tmpdir))) - (unless (= rc 0) -(error "Cannot untar test data %s: %d" filename rc)) - (funcall handler tmpdir)) - (delete-directory tmpdir t + (ert-with-temp-directory tmpdir +:prefix "javaimp-test" +(let ((rc (call-process + "tar" nil nil nil + "-x" + "-f" filename + "-C" tmpdir))) + (if (= rc 0) + (funcall handler tmpdir) +(error "Cannot untar test data file %s: %d" filename rc) (provide 'javaimp-tests) diff --git a/tests/gradle.el b/tests/gradle.el index f9e4e78e15..53d9b91010 100644 --- a/tests/gradle.el +++ b/tests/gradle.el @@ -6,6 +6,7 @@ ;; Maintainer: Filipp Gunbin (require 'ert) +(require 'ert-x) (require 'javaimp-gradle) (require 'javaimp-tests) @@ -32,8 +33,7 @@ (ert-deftest javaimp-gradle-visit-multi () :tags '(:expensive) (javaimp-call-with-data - (file-name-concat -javaimp-basedir "tests" "data" "gradle-multi.tar.gz") + (ert-resource-file "gradle-multi.tar.gz") (lambda (tmpdir) (should (equal diff --git a/tests/imenu.el b/tests/imenu.el index 39c186f55a..f1d5d9ed83 100644 --- a/tests/imenu.el +++ b/tests/imenu.el @@ -6,6 +6,7 @@ ;; Maintainer: Filipp Gunbin (require 'ert) +(require 'ert-x) (require 'javaimp) (defun javaimp-test-imenu--simplify-entries (alist) @@ -18,9 +19,7 @@ (ert-deftest javaimp-imenu-create-index () (let ((actual (with-temp-buffer - (insert-file-contents - (file-name-concat -javaimp-basedir "tests" "data" "test1-misc-classes.java")) + (insert-file-contents (ert-resource-file "test1.java")) (let ((imenu-use-markers nil)) (javaimp-imenu-create-index (expected-names @@ -47,9 +46,7 @@ (ert-deftest javaimp-imenu-create-index-use-sub-alists () (let ((actual (with-temp-buffer - (insert-file-contents - (file-name-concat -javaimp-basedir "tests" "data" "test1-misc-classes.java")) + (insert-file-contents (ert-resource-file "test1.java")) (let ((imenu-use-markers nil) (javaimp-imenu-use-sub-alists t)) (javaimp-imenu-create-index diff --git a/tests/maven.el b/tests/maven.el index ee83f63f88..4a74c76f54 100644 --- a/tests/maven.el +++ b/tests/maven.el @@ -6,6 +6,7 @@ ;; Maintainer: Filipp Gunbin (require 'ert) +(require 'ert-x) (require 'javaimp-maven) (require 'javaimp-tests) @@ -32,8 +33,7 @@ (ert-deftest
[elpa] externals/javaimp 8f97478e0f: Add tests for javaimp-parse-get-enclosing-scope
branch: externals/javaimp commit 8f97478e0fa1e3009bf308bd7178e9635d2d3477 Author: Filipp Gunbin Commit: Filipp Gunbin Add tests for javaimp-parse-get-enclosing-scope --- tests/parse.el | 104 + 1 file changed, 83 insertions(+), 21 deletions(-) diff --git a/tests/parse.el b/tests/parse.el index f8d8706f5d..62f6abd180 100644 --- a/tests/parse.el +++ b/tests/parse.el @@ -175,36 +175,35 @@ throws E1 {" ;; Tests for parse api -(defun javaimp-test-parse--check-defuns () +(defun javaimp-test-parse--get-all-scopes-defuns () (let* ((scopes (javaimp-parse-get-all-scopes nil nil (lambda (s) -(memq (javaimp-scope-type s) '(class interface enum method))) +(memq (javaimp-scope-type s) + '(class interface enum method))) (lambda (s) -(memq (javaimp-scope-type s) '(class interface enum method) - (actual (mapcar - (lambda (s) -(let (res) - (while s -(push (list (javaimp-scope-type s) -(javaimp-scope-name s)) - res) -(setq s (javaimp-scope-parent s))) - (nreverse res))) - scopes)) +(memq (javaimp-scope-type s) + '(class interface enum method) + (actual (mapcar #'javaimp-test-parse--simplify-scope scopes)) (expected '(((class "Top")) + ((class "CInner1") (class "Top")) + ((method "foo()") (class "CInner1") (class "Top")) + ((class "CInner1_CLocal1") (method "foo()") (class "CInner1") (class "Top")) + ((method "foo()") (class "CInner1_CLocal1") (method "foo()") (class "CInner1") (class "Top")) + ((class "CInner1_CLocal1_CLocal1") (method "foo()") (class "CInner1_CLocal1") (method "foo()") (class "CInner1") (class "Top")) + ((method "foo()") (class "CInner1_CLocal1_CLocal1") (method "foo()") @@ -213,6 +212,7 @@ throws E1 {" ((class "CInner1_CLocal2") (method "foo()") (class "CInner1") (class "Top")) + ((method "foo()") (class "CInner1_CLocal2") (method "foo()") (class "CInner1") (class "Top")) @@ -221,46 +221,64 @@ throws E1 {" (class "CInner1") (class "Top")) ((class "CInner1_CInner1") (class "CInner1") (class "Top")) + ((method "foo()") (class "CInner1_CInner1") (class "CInner1") (class "Top")) + ((method "bar()") (class "CInner1_CInner1") (class "CInner1") (class "Top")) ((interface "IInner1") (class "Top")) + ((method "foo()") (interface "IInner1") (class "Top")) + ((class "IInner1_CInner1") (interface "IInner1") (class "Top")) + ((method "foo()") (class "IInner1_CInner1") (interface "IInner1") (class "Top")) + ((method "defaultMethod(String)") (interface "IInner1") (class "Top")) ((interface "IInner1_IInner1") (interface "IInner1") (class "Top")) + ((method "defaultMethod(String)") (interface "IInner1_IInner1") (interface "IInner1") (class "Top")) ((enum "EnumInner1") (class "Top")) + ((method "EnumInner1()") (enum "EnumInner1") (class "Top")) + ((method "foo()") (enum "EnumInner1") (class "Top")) + ((enum "EnumInner1_EInner1") (enum "EnumInner1") (class "Top")) ((class "ColocatedTop")) + ((method "foo()") (class "ColocatedTop")) + ((method "bar(String,String)") (class "ColocatedTop") (should (= (length expected) (length actual))) (dotimes (i (length expected))
[elpa] externals/sql-cassandra updated (f0daf06e19 -> e5aea0fa0b)
fgunbin pushed a change to branch externals/sql-cassandra. from f0daf06e19 Require emacs 29. Bump version. new ed260c2f83 Move sql-cassandra-special-commands into eval-and-compile new a1de42bd8a auto-mode-alist for .cql files new e5aea0fa0b Bump version Summary of changes: sql-cassandra.el | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-)
[elpa] externals/sql-cassandra ed260c2f83 1/3: Move sql-cassandra-special-commands into eval-and-compile
branch: externals/sql-cassandra commit ed260c2f832e3dfa8942f2fc8dd57710ead702e9 Author: Filipp Gunbin Commit: Filipp Gunbin Move sql-cassandra-special-commands into eval-and-compile --- sql-cassandra.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql-cassandra.el b/sql-cassandra.el index d4aa1a0f48..2b12ab8d5a 100644 --- a/sql-cassandra.el +++ b/sql-cassandra.el @@ -48,7 +48,7 @@ :group 'SQL) -(eval-when-compile +(eval-and-compile (defconst sql-cassandra-special-commands '("capture" "cls" "copy" "describe" "expand" "login" "serial" "source" "unicode" "clear" "consistency" "desc" "exit" "help" @@ -56,8 +56,9 @@ "Special commands recognized by cqlsh. Refer to: -https://cassandra.apache.org/doc/latest/cassandra/tools/cqlsh.html#special-commands";) +https://cassandra.apache.org/doc/latest/cassandra/tools/cqlsh.html#special-commands";)) +(eval-when-compile (defconst sql-cassandra-native-types '("ascii" "bigint" "blob" "boolean" "counter" "date" "decimal" "double" "duration" "float" "inet" "int" "smallint" "text" "time"
[elpa] externals/sql-cassandra e5aea0fa0b 3/3: Bump version
branch: externals/sql-cassandra commit e5aea0fa0b45dcc07edbcda75e7dff30260a066e Author: Filipp Gunbin Commit: Filipp Gunbin Bump version --- sql-cassandra.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-cassandra.el b/sql-cassandra.el index 9b448c26ec..23801dbbb9 100644 --- a/sql-cassandra.el +++ b/sql-cassandra.el @@ -5,7 +5,7 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin ;; Package-Requires: ((emacs "29")) -;; Version: 0.2 +;; Version: 0.21 ;; Keywords: sql, cassandra, cql, cqlsh ;; This program is free software; you can redistribute it and/or modify
[elpa] externals/sql-cassandra a1de42bd8a 2/3: auto-mode-alist for .cql files
branch: externals/sql-cassandra commit a1de42bd8a08ba2675de258550eea41f4fef8f51 Author: Filipp Gunbin Commit: Filipp Gunbin auto-mode-alist for .cql files --- sql-cassandra.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sql-cassandra.el b/sql-cassandra.el index 2b12ab8d5a..9b448c26ec 100644 --- a/sql-cassandra.el +++ b/sql-cassandra.el @@ -154,6 +154,9 @@ Refer to https://cassandra.apache.org/doc/latest/cassandra/cql/appendices.html#a (interactive "P") (sql-product-interactive 'cassandra buffer)) +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.cql\\'" . sql-mode)) + (sql-add-product 'cassandra "Cassandra" :free-software t
[elpa] externals/sql-cassandra 2920f8c64e: Fix version
branch: externals/sql-cassandra commit 2920f8c64e937904087f3636696501fb1cfe7acc Author: Filipp Gunbin Commit: Filipp Gunbin Fix version --- sql-cassandra.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-cassandra.el b/sql-cassandra.el index 23801dbbb9..e1aec871b3 100644 --- a/sql-cassandra.el +++ b/sql-cassandra.el @@ -5,7 +5,7 @@ ;; Author: Filipp Gunbin ;; Maintainer: Filipp Gunbin ;; Package-Requires: ((emacs "29")) -;; Version: 0.21 +;; Version: 0.2.1 ;; Keywords: sql, cassandra, cql, cqlsh ;; This program is free software; you can redistribute it and/or modify
[elpa] externals/javaimp 22801e7614: * javaimp.el (javaimp-add-log-current-defun): New function
branch: externals/javaimp commit 22801e7614fd61b732458626b235e824fe28fee3 Author: Filipp Gunbin Commit: Filipp Gunbin * javaimp.el (javaimp-add-log-current-defun): New function --- javaimp.el | 30 +++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/javaimp.el b/javaimp.el index cd872d580c..455033bdb0 100644 --- a/javaimp.el +++ b/javaimp.el @@ -28,7 +28,8 @@ ;; errors. In addition, this module provides good Imenu support for ;; Java source files - with nesting and abstract methods in interfaces ;; and abstract classes. It provides suitable functions to use as -;; beginning-of-defun-function / end-of-defun-function as well. +;; `beginning-of-defun-function' / `end-of-defun-function' / +;; `add-log-current-defun-function' as well. ;; ;; ;; Quick start: @@ -95,8 +96,8 @@ ;; Parsing is also used for Imenu support and for navigation commands. ;; As there's no minor/major mode (yet), you have to set ;; `imenu-create-index-function' and `beginning-of-defun-function' / -;; `end-of-defun-function' in major mode hook yourself. See example -;; below. +;; `end-of-defun-function' / `add-log-current-defun-function' in major +;; mode hook yourself. See example below. ;; ;; - `javaimp-imenu-use-sub-alists' - if non-nil then Imenu items are ;; presented in a nested fashion, instead of a flat list (the @@ -132,6 +133,7 @@ ;; ;; (setq beginning-of-defun-function #'javaimp-beginning-of-defun) ;; (setq end-of-defun-function #'javaimp-end-of-defun) +;; (setq add-log-current-defun-function #'javaimp-add-log-current-defun) ;; (define-key java-mode-map (kbd "C-M-a") #'beginning-of-defun) ;; (define-key java-mode-map (kbd "C-M-e") #'end-of-defun) ;; @@ -1001,6 +1003,28 @@ after this group of defuns." siblings) +(defun javaimp-add-log-current-defun () + "Function to be used as `add-log-current-defun-function'." + (save-excursion +(save-restriction + (widen) + (let ((s (javaimp-parse-get-enclosing-scope +(javaimp-scope-defun-p '(method anon-class +names) +(while s + (push (javaimp-scope-name s) names) + (setq s (javaimp-scope-parent s))) +;; Omit top-level class name if there're other components, +;; but only if it matches file name (it usually will). +(when (and (> (length names) 1) + buffer-file-name + (equal (car names) (file-name-sans-extension + (file-name-nondirectory buffer-file-name + (setq names (cdr names))) +(when names + (string-join names ".")) + + ;; Misc
[elpa] externals/javaimp b7a5b1a649: javaimp-show-scopes: Use markers. Add javaimp-show-scopes-revert.
branch: externals/javaimp commit b7a5b1a649b9ab0d2bd3d2477d90e0003ab5407e Author: Filipp Gunbin Commit: Filipp Gunbin javaimp-show-scopes: Use markers. Add javaimp-show-scopes-revert. --- javaimp.el | 102 + 1 file changed, 62 insertions(+), 40 deletions(-) diff --git a/javaimp.el b/javaimp.el index 455033bdb0..d4ae6b7bdd 100644 --- a/javaimp.el +++ b/javaimp.el @@ -818,7 +818,6 @@ in a major mode hook." map) "Javaimp Show Scopes keymap.") -;; TODO handle mouse-1 (defun javaimp-show-scopes-goto-scope (event &optional to-start) "Go to the opening brace (`javaimp-scope-open-brace') of the scope. Target scope is determined by location of mouse EVENT, if it's @@ -826,55 +825,78 @@ non-nil. Else, take the scope at current line. When TO-START is non-nil, go to scope start (`javaimp-scope-start') instead of the opening brace." (interactive (list last-nonmenu-event current-prefix-arg)) - (let ((buf (current-buffer)) -(scopes-buf-pos - (if event - (cons (window-buffer (posn-window (event-end event))) - (posn-point (event-end event))) - (cons (current-buffer) - (point -source-file scope) -(with-current-buffer (car scopes-buf-pos) - (setq source-file -(get-text-property (point-min) 'javaimp-show-scopes-file) -scope -(get-text-property (cdr scopes-buf-pos) 'javaimp-show-scopes-scope))) -(unless (and source-file scope) - (user-error "No target scope")) -(pop-to-buffer (find-file-noselect source-file)) -(goto-char (if to-start - (javaimp-scope-start scope) - (javaimp-scope-open-brace scope))) + (let* ((buf (current-buffer)) + (scopes-buf (if event + (window-buffer (posn-window (event-end event))) + (current-buffer))) + (scopes-pos (if event + (posn-point (event-end event)) + (point))) + (markers (or (with-current-buffer scopes-buf +(get-text-property scopes-pos 'javaimp-show-scopes-markers)) + (user-error "No scope on this line"))) + (marker (if to-start + (cadr markers) + (car markers +(unless (buffer-live-p (marker-buffer marker)) + (user-error "Buffer for this scope was killed")) +(pop-to-buffer (marker-buffer marker)) +(goto-char marker) (next-error-found buf (current-buffer - (put 'javaimp-show-scopes-mode 'mode-class 'special) (define-derived-mode javaimp-show-scopes-mode special-mode "Javaimp Show Scopes" + (setq-local revert-buffer-function #'javaimp-show-scopes-revert) (setq next-error-function #'javaimp-show-scopes-next-error)) (defun javaimp-show-scopes () "Show scopes in *javaimp-scopes* buffer." (interactive) + (display-buffer + (javaimp-show-scopes-1 (current-buffer + +(defun javaimp-show-scopes-revert (_ignore1 _ignore2) + "Function to be used as `revert-buffer-function' in +`javaimp-show-scopes-mode' buffers." + (let ((source-buf + (get-file-buffer + (get-text-property (point-min) 'javaimp-show-scopes-file +(if source-buf +(javaimp-show-scopes-1 source-buf) + (user-error "Source buffer has been killed" + +(defun javaimp-show-scopes-1 (source-buf) + "Subroutine of `javaimp-show-scopes', outputs scopes from +SOURCE-BUF in *javaimp-scopes* buffer. Returns resulting +buffer." (let ((scopes - (save-excursion - (save-restriction - (widen) - (javaimp-parse-get-all-scopes - nil nil (javaimp-scope-defun-p '(method anon-class)) -(source-buf (current-buffer)) -(source-default-dir default-directory) + (with-current-buffer source-buf + (save-excursion + (save-restriction + (widen) + (javaimp-parse-get-all-scopes +nil nil (javaimp-scope-defun-p '(method anon-class))) +(default-dir + (with-current-buffer source-buf + default-directory)) (buf (get-buffer-create "*javaimp-scopes*"))) (with-current-buffer buf - (setq default-directory source-default-dir) + (setq default-directory default-dir) (javaimp-show-scopes-mode) (let ((inhibit-read-only t) (buffer-undo-list t)) (erase-buffer) -(insert (propertize (format "%s\n\n" (buffer-file-name source-buf)) -'javaimp-show-scopes-file (buffer-file-name source-buf))) +(insert (propertize (format "%s&