Skip to content

Commit

Permalink
Fixed module path separator in Windows (#116)
Browse files Browse the repository at this point in the history
* 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).

* Fixed per code review
  • Loading branch information
abiharbani authored Jun 4, 2024
1 parent b444c5b commit 0326c88
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(relPath, FileSystems.getDefault().getSeparator());
} else {
return NameIdentifierHelper.fromWeaveFilePath(contentRootForFile.getPath());
}
Expand Down

0 comments on commit 0326c88

Please sign in to comment.