branch: externals/javaimp
commit 032d3a86395953237e0f7f6d178cd965b62ad560
Author: Filipp Gunbin <[email protected]>
Commit: Filipp Gunbin <[email protected]>

    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 "Invalid mode: %s" mode)))
                args)
-         (and is-really-path (push "-p" args))
-         (push path args)
+         (when is-path
+            (push "-p" args))
+         (push filename args)
          (car (apply #'process-lines javaimp-cygpath-program args))))
-    path))
+    filename))
 
 (defun javaimp--call-build-tool (program handler &rest args)
   "Run PROGRAM with ARGS, then call HANDLER in the temporary buffer
@@ -286,7 +287,7 @@ with point set to eob and return its result."
   (when path
     ;; don't use parse-colon-path because it makes resulting elements
     ;; to be directories
-    (split-string (javaimp-cygpath-convert-maybe path 'unix t)
+    (split-string (javaimp-cygpath-convert-file-name path 'unix t)
                   (concat "[" path-separator "\n]+")
                   t)))
 
diff --git a/javaimp.el b/javaimp.el
index 857c127cef..4c0fbeb1f5 100644
--- a/javaimp.el
+++ b/javaimp.el
@@ -365,7 +365,7 @@ contained in it as a list."
        (if (equal ext "jar") "tf" "list")
        ;; On cygwin, "jar/jmod" is a windows program, so file path
        ;; needs to be converted appropriately.
-       (javaimp-cygpath-convert-maybe file 'windows)))))
+       (javaimp-cygpath-convert-file-name file 'windows)))))
 
 (defun javaimp--read-jar-classes-handler ()
   "Used by `javaimp--read-jar-classes' to handle jar program

Reply via email to