From a284efc98ab258b822819a77481f926d089ecfb3 Mon Sep 17 00:00:00 2001 From: abiharbani Date: Sat, 1 Jun 2024 13:14:29 -0700 Subject: [PATCH 1/2] Fixed module path separator in Windows Module path separator in Windows is currently "/" ie: dw/util/Math, which is incorrect. It should be "::" (ie: dw::util::Math). This is because Intellij's virtual file uses "/" separator, but Dataweave parser SDK expects the native file separator, which is "\" in Windows. Pre-correcting the file separator before sending the path to the parser SDK fixes this issue. This bug caused modules and some functions as being not resolvable in the editor. Also, the auto suggest gives the wrong path (ie: suggesting dw/util/Math instead of dw::util::Math). --- .../org/mule/tooling/lang/dw/util/VirtualFileSystemUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/util/VirtualFileSystemUtils.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/util/VirtualFileSystemUtils.java index 90e29c9c..ab6f96e5 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/util/VirtualFileSystemUtils.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/util/VirtualFileSystemUtils.java @@ -24,6 +24,7 @@ import org.mule.weave.v2.sdk.NameIdentifierHelper; import java.io.IOException; +import java.nio.file.FileSystems; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -126,7 +127,7 @@ private static VirtualFile resolve(Project project, NameIdentifier name, GlobalS public static NameIdentifier getNameIdentifierWithRelative(VirtualFile vfs, VirtualFile contentRootForFile) { final String relPath = VfsUtil.getRelativePath(vfs, contentRootForFile); if (relPath != null) { - return NameIdentifierHelper.fromWeaveFilePath(relPath); + return NameIdentifierHelper.fromWeaveFilePath(FileSystems.getDefault().getSeparator().equals("\\") ? relPath.replace("/", "\\") : relPath); } else { return NameIdentifierHelper.fromWeaveFilePath(contentRootForFile.getPath()); } From 9c1bf1aa64d1588729295179b0bbe8ec40550998 Mon Sep 17 00:00:00 2001 From: abiharbani Date: Sat, 1 Jun 2024 14:17:14 -0700 Subject: [PATCH 2/2] Fixed per code review --- .../org/mule/tooling/lang/dw/util/VirtualFileSystemUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/util/VirtualFileSystemUtils.java b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/util/VirtualFileSystemUtils.java index ab6f96e5..2c1385bd 100644 --- a/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/util/VirtualFileSystemUtils.java +++ b/data-weave-plugin/src/main/java/org/mule/tooling/lang/dw/util/VirtualFileSystemUtils.java @@ -127,7 +127,7 @@ private static VirtualFile resolve(Project project, NameIdentifier name, GlobalS public static NameIdentifier getNameIdentifierWithRelative(VirtualFile vfs, VirtualFile contentRootForFile) { final String relPath = VfsUtil.getRelativePath(vfs, contentRootForFile); if (relPath != null) { - return NameIdentifierHelper.fromWeaveFilePath(FileSystems.getDefault().getSeparator().equals("\\") ? relPath.replace("/", "\\") : relPath); + return NameIdentifierHelper.fromWeaveFilePath(relPath, FileSystems.getDefault().getSeparator()); } else { return NameIdentifierHelper.fromWeaveFilePath(contentRootForFile.getPath()); }