You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Goooler (via GitHub)" <gi...@apache.org> on 2023/02/18 20:56:22 UTC

[GitHub] [groovy] Goooler opened a new pull request, #1859: Add `extension` & `nameWithoutExtension` extension methods

Goooler opened a new pull request, #1859:
URL: https://github.com/apache/groovy/pull/1859

   Ref:
   https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io.path/java.nio.file.-path/extension.html
   https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io.path/java.nio.file.-path/name-without-extension.html


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [groovy] Goooler commented on pull request #1859: GROOVY-10942 Add `extension` & `nameWithoutExtension` extension methods

Posted by "Goooler (via GitHub)" <gi...@apache.org>.
Goooler commented on PR #1859:
URL: https://github.com/apache/groovy/pull/1859#issuecomment-1435915780

   GROOVY-10942
   
   1. Agreed.
   2. I misjudged `Path.getFileName()` to return a non-null String, will fix it later.
   3. Will add a `getBaseName()`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [groovy] Goooler commented on a diff in pull request #1859: GROOVY-10942 Add `extension` & `nameWithoutExtension` extension methods

Posted by "Goooler (via GitHub)" <gi...@apache.org>.
Goooler commented on code in PR #1859:
URL: https://github.com/apache/groovy/pull/1859#discussion_r1111187417


##########
subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java:
##########
@@ -101,6 +101,36 @@ public static long size(Path self) throws IOException {
         return Files.size(self);
     }
 
+    /**
+     * Provide the extension of this path.
+     *
+     * @param self a path object
+     * @return the extension of this path (not including the dot), or an empty string if it doesn't have one.
+     * @since 5.0.0
+     */
+    public static String getExtension(Path self) {
+        final Path fileName = self.getFileName();
+        final String name = fileName == null ? "" : fileName.toString();

Review Comment:
   If we can resue this part, add a `Path.name()` like [`Path.name` in Kotlin](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io.path/java.nio.file.-path/name.html)?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [groovy] Goooler commented on pull request #1859: GROOVY-10942 Add `extension` & `nameWithoutExtension` extension methods

Posted by "Goooler (via GitHub)" <gi...@apache.org>.
Goooler commented on PR #1859:
URL: https://github.com/apache/groovy/pull/1859#issuecomment-1435925146

   Renamed to `getBaseName`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [groovy] paulk-asert commented on a diff in pull request #1859: GROOVY-10942 Add `extension` & `nameWithoutExtension` extension methods

Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert commented on code in PR #1859:
URL: https://github.com/apache/groovy/pull/1859#discussion_r1111190501


##########
subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java:
##########
@@ -101,6 +101,36 @@ public static long size(Path self) throws IOException {
         return Files.size(self);
     }
 
+    /**
+     * Provide the extension of this path.
+     *
+     * @param self a path object
+     * @return the extension of this path (not including the dot), or an empty string if it doesn't have one.
+     * @since 5.0.0
+     */
+    public static String getExtension(Path self) {
+        final Path fileName = self.getFileName();
+        final String name = fileName == null ? "" : fileName.toString();

Review Comment:
   You want `Path.getName()`, with shorthand `Path.name` as a shorthand for `Path.getFileName()`/`Path.fileName`?
   That could work but there is the existing `getName(int index)` method which might confuse some folks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [groovy] paulk-asert merged pull request #1859: GROOVY-10942 Add `extension` & `baseName` extension methods

Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert merged PR #1859:
URL: https://github.com/apache/groovy/pull/1859


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [groovy] paulk-asert commented on pull request #1859: GROOVY-10942 Add `extension` & `nameWithoutExtension` extension methods

Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert commented on PR #1859:
URL: https://github.com/apache/groovy/pull/1859#issuecomment-1435923221

   Can you elaborate what you mean by "too implicit"? (Just checking I understood) You mean "too obscure" whereas the longer one is "more self-describing"? I guess the shorter one relies on some familiarity with *nix commands which might not always be the case.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [groovy] paulk-asert commented on pull request #1859: Add `extension` & `nameWithoutExtension` extension methods

Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert commented on PR #1859:
URL: https://github.com/apache/groovy/pull/1859#issuecomment-1435914481

   I like the idea behind these extensions. Can you create a corresponding Jira issue?
   
   Also, some minor points:
   
   - I think using `getExtension` rather than `extension` would be closer to existing methods. WDYT?
   - Also, `extension` doesn't currently return empty string when there is no extension. This is what the javadocs state but not what the implementation does. The javadoc matches how Kotlin and commons-io FilenameUtils behave.
   - An alternative to `nameWithoutExtension` is `baseName` (what commons-io uses) or just `basename` (again, I'd go with the getter variant). I guess there is some merit in following Kotlin but `basename` would certainly be shorter. WDYT?
   
   Naming is always tricky, we can always ask on the mailing list if we want to confirm preferences.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [groovy] codecov-commenter commented on pull request #1859: Add `extension` & `nameWithoutExtension` extension methods

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #1859:
URL: https://github.com/apache/groovy/pull/1859#issuecomment-1435771833

   # [Codecov](https://codecov.io/gh/apache/groovy/pull/1859?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#1859](https://codecov.io/gh/apache/groovy/pull/1859?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (259eedb) into [master](https://codecov.io/gh/apache/groovy/commit/0cc849962cb4bd7381de6c530d2b528c73b6b743?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0cc8499) will **increase** coverage by `0.0045%`.
   > The diff coverage is `100.0000%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/groovy/pull/1859/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/groovy/pull/1859?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #1859        +/-   ##
   ==================================================
   + Coverage     68.0676%   68.0721%   +0.0045%     
   - Complexity      28607      28614         +7     
   ==================================================
     Files            1427       1427                
     Lines          113067     113083        +16     
     Branches        19330      19334         +4     
   ==================================================
   + Hits            76962      76978        +16     
     Misses          29608      29608                
     Partials         6497       6497                
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/groovy/pull/1859?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...codehaus/groovy/runtime/ResourceGroovyMethods.java](https://codecov.io/gh/apache/groovy/pull/1859?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3J1bnRpbWUvUmVzb3VyY2VHcm9vdnlNZXRob2RzLmphdmE=) | `84.1060% <100.0000%> (+0.2857%)` | :arrow_up: |
   | [...rg/apache/groovy/nio/extensions/NioExtensions.java](https://codecov.io/gh/apache/groovy/pull/1859?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LW5pby9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ3Jvb3Z5L25pby9leHRlbnNpb25zL05pb0V4dGVuc2lvbnMuamF2YQ==) | `38.3523% <100.0000%> (+1.4337%)` | :arrow_up: |
   | [...org/codehaus/groovy/vmplugin/v8/IndyInterface.java](https://codecov.io/gh/apache/groovy/pull/1859?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3ZtcGx1Z2luL3Y4L0luZHlJbnRlcmZhY2UuamF2YQ==) | `85.2459% <0.0000%> (-0.8197%)` | :arrow_down: |
   | [...ncurrentlinkedhashmap/ConcurrentLinkedHashMap.java](https://codecov.io/gh/apache/groovy/pull/1859?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS91dGlsL2NvbmN1cnJlbnQvY29uY3VycmVudGxpbmtlZGhhc2htYXAvQ29uY3VycmVudExpbmtlZEhhc2hNYXAuamF2YQ==) | `45.0593% <0.0000%> (+0.1976%)` | :arrow_up: |
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [groovy] Goooler commented on a diff in pull request #1859: GROOVY-10942 Add `extension` & `nameWithoutExtension` extension methods

Posted by "Goooler (via GitHub)" <gi...@apache.org>.
Goooler commented on code in PR #1859:
URL: https://github.com/apache/groovy/pull/1859#discussion_r1111190774


##########
subprojects/groovy-nio/src/main/java/org/apache/groovy/nio/extensions/NioExtensions.java:
##########
@@ -101,6 +101,36 @@ public static long size(Path self) throws IOException {
         return Files.size(self);
     }
 
+    /**
+     * Provide the extension of this path.
+     *
+     * @param self a path object
+     * @return the extension of this path (not including the dot), or an empty string if it doesn't have one.
+     * @since 5.0.0
+     */
+    public static String getExtension(Path self) {
+        final Path fileName = self.getFileName();
+        final String name = fileName == null ? "" : fileName.toString();

Review Comment:
   Yeah, that's what I'm afraid.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org