retain symlinks in file names from VSCode: relevant for proper file locations in decorations etc.;
authorwenzelm
Fri, 30 Jun 2017 14:26:45 +0200
changeset 66235 d4fa51e7c4ff
parent 66234 836898197296
child 66236 8ae7c5ba1a85
retain symlinks in file names from VSCode: relevant for proper file locations in decorations etc.;
src/Pure/General/url.scala
src/Tools/VSCode/src/protocol.scala
src/Tools/VSCode/src/vscode_rendering.scala
src/Tools/VSCode/src/vscode_resources.scala
--- a/src/Pure/General/url.scala	Fri Jun 30 14:19:37 2017 +0200
+++ b/src/Pure/General/url.scala	Fri Jun 30 14:26:45 2017 +0200
@@ -61,6 +61,9 @@
         false
     }
 
+  def absolute_file(uri: String): JFile = File.absolute(parse_file(uri))
+  def absolute_file_name(uri: String): String = absolute_file(uri).getPath
+
   def canonical_file(uri: String): JFile = File.canonical(parse_file(uri))
   def canonical_file_name(uri: String): String = canonical_file(uri).getPath
 }
--- a/src/Tools/VSCode/src/protocol.scala	Fri Jun 30 14:19:37 2017 +0200
+++ b/src/Tools/VSCode/src/protocol.scala	Fri Jun 30 14:26:45 2017 +0200
@@ -207,7 +207,7 @@
         uri <- JSON.string(json, "uri")
         range_json <- JSON.value(json, "range")
         range <- Range.unapply(range_json)
-      } yield Line.Node_Range(Url.canonical_file_name(uri), range)
+      } yield Line.Node_Range(Url.absolute_file_name(uri), range)
   }
 
   object TextDocumentPosition
@@ -218,7 +218,7 @@
         uri <- JSON.string(doc, "uri")
         pos_json <- JSON.value(json, "position")
         pos <- Position.unapply(pos_json)
-      } yield Line.Node_Position(Url.canonical_file_name(uri), pos)
+      } yield Line.Node_Position(Url.absolute_file_name(uri), pos)
   }
 
 
@@ -280,7 +280,7 @@
             lang <- JSON.string(doc, "languageId")
             version <- JSON.long(doc, "version")
             text <- JSON.string(doc, "text")
-          } yield (Url.canonical_file(uri), lang, version, text)
+          } yield (Url.absolute_file(uri), lang, version, text)
         case _ => None
       }
   }
@@ -302,7 +302,7 @@
             uri <- JSON.string(doc, "uri")
             version <- JSON.long(doc, "version")
             changes <- JSON.array(params, "contentChanges", unapply_change _)
-          } yield (Url.canonical_file(uri), version, changes)
+          } yield (Url.absolute_file(uri), version, changes)
         case _ => None
       }
   }
@@ -315,7 +315,7 @@
           for {
             doc <- JSON.value(params, "textDocument")
             uri <- JSON.string(doc, "uri")
-          } yield Url.canonical_file(uri)
+          } yield Url.absolute_file(uri)
         case _ => None
       }
   }
@@ -497,7 +497,7 @@
               uri <- JSON.string(params, "uri")
               if Url.is_wellformed_file(uri)
               pos <- Position.unapply(params)
-            } yield (Url.canonical_file(uri), pos)
+            } yield (Url.absolute_file(uri), pos)
           Some(caret)
         case _ => None
       }
@@ -560,7 +560,7 @@
             uri <- JSON.string(params, "uri")
             if Url.is_wellformed_file(uri)
             column <- JSON.int(params, "column")
-          } yield (Url.canonical_file(uri), column)
+          } yield (Url.absolute_file(uri), column)
         case _ => None
       }
   }
--- a/src/Tools/VSCode/src/vscode_rendering.scala	Fri Jun 30 14:19:37 2017 +0200
+++ b/src/Tools/VSCode/src/vscode_rendering.scala	Fri Jun 30 14:26:45 2017 +0200
@@ -254,7 +254,7 @@
     for {
       platform_path <- resources.source_file(source_name)
       file <-
-        (try { Some(File.canonical(new JFile(platform_path))) }
+        (try { Some(File.absolute(new JFile(platform_path))) }
          catch { case ERROR(_) => None })
     }
     yield {
--- a/src/Tools/VSCode/src/vscode_resources.scala	Fri Jun 30 14:19:37 2017 +0200
+++ b/src/Tools/VSCode/src/vscode_resources.scala	Fri Jun 30 14:26:45 2017 +0200
@@ -109,7 +109,7 @@
     else if (path.is_basic && !dir.endsWith("/") && !dir.endsWith(JFile.separator))
       dir + JFile.separator + File.platform_path(path)
     else if (path.is_basic) dir + File.platform_path(path)
-    else File.canonical_name(new JFile(dir + JFile.separator + File.platform_path(path)))
+    else File.absolute_name(new JFile(dir + JFile.separator + File.platform_path(path)))
   }
 
   def get_models: Map[JFile, Document_Model] = state.value.models