Commits

Taku Miyakawa committed 66a6b84

Refactors the enhancer module of java.nio.file.Path: renames names of local variables "Path" to "File_path" to avoid naming conflict

  • Participants
  • Parent commits cced200

Comments (0)

Files changed (1)

File src/main/kink/_enhance/java/nio/file/Path.kn

 # Trait for the paths
 :Path_trait = [
     # Parent path of the path
-    'parent_path' { > :Path ()
-        Path.getParent
+    'parent_path' { > :File_path ()
+        File_path.getParent
     }
 
     # Child path of the path
     # ex. path('/usr/local') + 'bin' -> path('/usr/local/bin')
     # ex. path('/usr/local') + path('bin') -> path('/usr/local/bin')
-    'op_add' { > :Path (:Other)
-        Path.resolve(Other)
+    'op_add' { > :File_path (:Other)
+        File_path.resolve(Other)
     }
 
     # Relative path of the receiver from the argument
     # Sibling path
     # ex. path('/usr/local/bin').sibling('lib') -> path('/usr/local/lib')
     # ex. path('/usr/local/bin').sibling(path('lib')) -> path('/usr/local/lib')
-    'sibling' { > :Path (:Other)
-        Path.resolveSibling(Other)
+    'sibling' { > :File_path (:Other)
+        File_path.resolveSibling(Other)
     }
 
     # Leaf of the path
     # ex. path('/usr/local/bin').leaf -> path('bin')
-    'leaf' { > :Path ()
-        Path.getFileName
+    'leaf' { > :File_path ()
+        File_path.getFileName
     }
 
     # Decides if the path has a root or not
     # ex. path('/usr/local/bin').has_root? -> true
     # ex. path('bin/kink').has_root? -> false
-    'has_root?' { > :Path ()
-        Path.getRoot.object??
+    'has_root?' { > :File_path ()
+        File_path.getRoot.object??
     }
 
     # Root path
     # ex. path('/usr/local/bin').root -> path('/')
-    'root' { > :Path ()
-        Path.getRoot
+    'root' { > :File_path ()
+        File_path.getRoot
     }
 
     # Normalizes a path
     # ex. path('/usr/local/bin/../lib') -> path('/usr/local/lib')
-    'normalize' { > :Path ()
-        Path.call_method('normalize')
+    'normalize' { > :File_path ()
+        File_path.call_method('normalize')
     }
 
     # Determines the path is absolute or not
     # ex. path('/usr/local/bin').absolute? -> true
     # ex. path('bin').absolute? -> false
-    'absolute?' { > :Path ()
-        Path.isAbsolute
+    'absolute?' { > :File_path ()
+        File_path.isAbsolute
     }
 
     # Returns the absolute path
     # ex. path('some.txt').absolute -> path('/home/me/work/some.txt')
-    'absolute' { > :Path ()
-        Path.toAbsolutePath
+    'absolute' { > :File_path ()
+        File_path.toAbsolutePath
     }
 
     # Returns the real path
     # ex. path('.' LinkOption.NOFOLLOW_LINKS) -> path('/home/me')
     # ex. path('/bin/sh') -> path('/usr/bin/bash') # Follows the link
-    'real' { > :Path (* :Args)
-        Path.toRealPath(*** Args)
+    'real' { > :File_path (* :Args)
+        File_path.toRealPath(*** Args)
     }
 
     # Determines if the path is a directory or not
     # ex. path('/usr/bin').dir? -> true
     # ex. path('/usr/bin/ls').dir? -> false
-    'dir?' { > :Path (* :Link_options)
-        Files.isDirectory(Path *** Link_options)
+    'dir?' { > :File_path (* :Link_options)
+        Files.isDirectory(File_path *** Link_options)
     }
 
     # Determines if the path is a file or not
     # ex. path('/usr/bin/ls').file? -> true
     # ex. path('/usr/bin').file? -> false
-    'file?' { > :Path (* :Link_options)
-        Files.isRegularFile(Path *** Link_options)
+    'file?' { > :File_path (* :Link_options)
+        Files.isRegularFile(File_path *** Link_options)
     }
 
     # Determines if the path is a symbolic link or not
-    'symlink?' { > :Path ()
-        Files.isSymbolicLink(Path)
+    'symlink?' { > :File_path ()
+        Files.isSymbolicLink(File_path)
     }
 
     # Determines if the path exists
-    'exists?' { > :Path (* :Link_options)
-        Files.exists(Path *** Link_options)
+    'exists?' { > :File_path (* :Link_options)
+        Files.exists(File_path *** Link_options)
     }
 
     # Determines if the path does not exist
-    'not_exists?' { > :Path (* :Link_options)
-        Files.notExists(Path *** Link_options)
+    'not_exists?' { > :File_path (* :Link_options)
+        Files.notExists(File_path *** Link_options)
     }
 
     #
     #
 
     # Determines if the file is readable or not
-    'readable?' { > :Path ()
-        Files.isReadable(Path)
+    'readable?' { > :File_path ()
+        Files.isReadable(File_path)
     }
 
     # Determines if the file is writable or not
-    'writable?' { > :Path ()
-        Files.isWritable(Path)
+    'writable?' { > :File_path ()
+        Files.isWritable(File_path)
     }
 
     # Determines if the file is executable or not
-    'executable?' { > :Path ()
-        Files.isExecutable(Path)
+    'executable?' { > :File_path ()
+        Files.isExecutable(File_path)
     }
 
     # Determines if the two paths are same or not
     }
 
     # Determines if the path is hidden
-    'hidden?' { > :Path ()
-        Files.isHidden(Path)
+    'hidden?' { > :File_path ()
+        Files.isHidden(File_path)
     }
 
     # Returns a target of the symbolic link (readlink operation)
     }
 
     # Removes a file or a directory
-    'delete' { > :Path ()
-        Files.delete(Path)
+    'delete' { > :File_path ()
+        Files.delete(File_path)
     }
 
     # Removes a directory recursively
-    'delete_recursively' { > :Path ()
-        Files.walkFileTree(Path _rmr_visitor)
+    'delete_recursively' { > :File_path ()
+        Files.walkFileTree(File_path _rmr_visitor)
         ()
     }
 
     #
 
     # Output stream
-    'out' { > :Path (* :Open_options)
-        Files.newOutputStream(Path *** Open_options)
+    'out' { > :File_path (* :Open_options)
+        Files.newOutputStream(File_path *** Open_options)
     }
 
     # Output stream for append
-    'out_to_append' { > :Path ()
-        Path.out(
+    'out_to_append' { > :File_path ()
+        File_path.out(
             StandardOpenOption.WRITE
             StandardOpenOption.CREATE
             StandardOpenOption.APPEND
     }
 
     # Input stream
-    'in' { > :Path (* :Open_options)
-        Files.newInputStream(Path *** Open_options)
+    'in' { > :File_path (* :Open_options)
+        Files.newInputStream(File_path *** Open_options)
     }
 
     # Writes bytes to the file
     }
 
     # Writes a text to the file
-    'print' { > :Path (:Text :Charset)
+    'print' { > :File_path (:Text :Charset)
         use('USING.using')
-        using(Path.out) { (:Out)
+        using(File_path.out) { (:Out)
             :Charset.exists?.then { Out.print(Text Charset) } { Out.print(Text) }
         }
     }
 
     # Appends a text to the file
-    'append_text' { > :Path (:Text :Charset)
+    'append_text' { > :File_path (:Text :Charset)
         use('USING.using')
-        using(Path.out_to_append) { (:Out)
+        using(File_path.out_to_append) { (:Out)
             :Charset.exists?.then { Out.print(Text Charset) } { Out.print(Text) }
         }
     }
 
     # Reads a text from the file
-    'text' { > :Path (:Charset)
+    'text' { > :File_path (:Charset)
         use('USING.using')
-        using(Path.in) { (:In)
+        using(File_path.in) { (:In)
             :Charset.exists?.then { In.text(Charset) } { In.text }
         }
     }
     }
 
     # Writes a line to the file
-    'print_line' { > :Path (:Text :Charset)
+    'print_line' { > :File_path (:Text :Charset)
         use('USING.using')
-        using(Path.out) { (:Out)
+        using(File_path.out) { (:Out)
             :Charset.exists?.then { Out.print_line(Text Charset) } { Out.print_line(Text) }
         }
     }
 
     # Appends a line to the file
-    'append_line' { > :Path (:Text :Charset)
+    'append_line' { > :File_path (:Text :Charset)
         use('USING.using')
-        using(Path.out_to_append) { (:Out)
+        using(File_path.out_to_append) { (:Out)
             :Charset.exists?.then { Out.print_line(Text Charset) } { Out.print_line(Text) }
         }
     }
 
     # Reads lines from the file
-    'lines' { > :Path (:Charset)
+    'lines' { > :File_path (:Charset)
         use('USING.using')
-        using(Path.in) { (:In)
+        using(File_path.in) { (:In)
             :Charset.exists?.then { In.lines(Charset) } { In.lines }
         }
     }
 
     # Returns paths of children of the directory
-    'child_paths' { > :Path ()
+    'child_paths' { > :File_path ()
         use('USING.using')
-        using(Files.newDirectoryStream(Path)) { (:Stream)
+        using(Files.newDirectoryStream(File_path)) { (:Stream)
             Stream.list
         }
     }
 
     # Returns paths of descendant files and directories
-    'tree' { > :Path ()
+    'tree' { > :File_path ()
         :Accum = []
-        Files.walkFileTree(Path _tree_visitor(Accum))
+        Files.walkFileTree(File_path _tree_visitor(Accum))
         Accum
     }
 
     # ex. path('/bin').can_into?(Object) -> true
     # ex. path('/bin').can_into?(File) -> true
     # ex. path('/bin').can_into?(String) -> false
-    'can_into?' { > :Path (:Class)
-        Path.object?? && (Path.instance_of?(Class) || Class == File)
+    'can_into?' { > :File_path (:Class)
+        File_path.object?? && (File_path.instance_of?(Class) || Class == File)
     }
 
     # Convert the path to a path or a file
     # ex. path('/bin').into(Path) -> path('/bin')
     # ex. path('/bin').into(Object) -> path('/bin')
     # ex. path('/bin').into(File) -> File.new('/bin')
-    'into' { > :Path (:Class)
-        (Class == File).then { Path.toFile } { Path }
+    'into' { > :File_path (:Class)
+        (Class == File).then { File_path.toFile } { File_path }
     }
 
     # Returns the path name
     # ex. path('/bin').name -> '/bin'
-    'name' { > :Path ()
-        Path.toString
+    'name' { > :File_path ()
+        File_path.toString
     }
 
     # Returns the string representation of the path
     # ex. path('/bin').show -> path("/bin")
-    'show' { > :Path ()
-        Path.object??.then { 'path(' + Path.name.show + ')' } { 'null-path' }
+    'show' { > :File_path ()
+        File_path.object??.then { 'path(' + File_path.name.show + ')' } { 'null-path' }
     }
 
     # Returns true if the receiver is a path
     # ex. path('/bin').path?? -> true
-    'path??' { > :Path ()
-        Path.object??
+    'path??' { > :File_path ()
+        File_path.object??
     }
 
 ]