Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed module path separator in Windows #116

Merged

Conversation

abiharbani
Copy link
Contributor

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).

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).
@abiharbani abiharbani requested a review from a team as a code owner June 1, 2024 20:29
@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return NameIdentifierHelper.fromWeaveFilePath(FileSystems.getDefault().getSeparator().equals("\\") ? relPath.replace("/", "\\") : relPath);
return NameIdentifierHelper.fromWeaveFilePath(relPath, FileSystems.getDefault().getSeparator());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much simpler and should have the same outcome

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, a new fix pushed. Thanks

Copy link

salesforce-cla bot commented Jun 1, 2024

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Abi Harbani <a***@g***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce Inc. Contributor License Agreement and this Pull Request will be revalidated.

@abiharbani abiharbani force-pushed the ah_fixModulesLookupForWindows branch from 4c199f2 to 9c1bf1a Compare June 1, 2024 21:18
@machaval machaval merged commit 0326c88 into mulesoft-labs:master Jun 4, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants