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

Add support for binary USD files #7

Open
justint opened this issue Nov 9, 2019 · 3 comments
Open

Add support for binary USD files #7

justint opened this issue Nov 9, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@justint
Copy link
Owner

justint commented Nov 9, 2019

If a user tries to open a binary usd file, PyCharm will read the binary data as-is which isn't helpful.

Instead, the plug-in should be converting the binary data to ASCII whenever a binary file is opened, and converted back whenever the user saves the file (essentially mimicking what usdedit does).

This can likely be done using the VirtualFile system, I'll have to do further investigations on how to implement this functionality.

@justint justint added the enhancement New feature or request label Nov 9, 2019
@justint
Copy link
Owner Author

justint commented Apr 18, 2020

Following Peter's instructions in the IntelliJ Platform IDE Support Forum on creating a PSI from a binary file, I've had limited success getting this to work:

  • I've written a USDFileDecompiler class that uses usdcat to convert the binary file into ASCII, but the resulting text is neither syntax highlighted or editable. It seems like decompiled files are by default not associated with a language (resulting in no syntax highlighting) and are read-only.

  • My other attempt was to implement a USDFileViewProviderFactory and mimic JetBrains' approach towards Java Class files, but that seemed to have no effect on opening binary USD files (they weren't even being decompiled).

I'm going to pause on trying to implement this feature and focus my efforts towards other features for now. I'll revisit this at some point later when I have a better idea of how to get this working.

@justint justint self-assigned this Dec 1, 2020
@OlessiaSS
Copy link

Any updates on revisiting USD binary support?

@justint
Copy link
Owner Author

justint commented Sep 19, 2022

This feature has been a long saga for me, with sadly no promising results of a perfect solution.

Since my last comment in 2020, I've made the following attempt with mixed success:

I subclassed LightVirtualFile to a custom USDVirtualFile which defines how binary USD files are read and written (with usdcat), and then implemented a USDFileEditorProvider to override its createEditor method. In that overridden method, I cast the provided VirtualFile to a USDVirtualFile, and then pass that USDVirtualFile into a new text editor with TextEditorProvider.getInstance().createEditor(project, usdVirtualFile).

This has been successful in converting the binary file to ASCII and providing syntax highlighting, but a new critical bug has arisen from this method that I've never been able to solve: whenever one clicks a node within the open file's Structure View, a new tab of the same file opens up, resulting in two open tabs of the same file. The second tab will have no text in the tab title, and the structure view "Jump To Source" will only work in the second tab.

I've come to realize this is likely happening because there are two VirtualFiles of the binary USD: the original provided by the LocalFileSystem, and the USDVirtualFile provided by me in the FileEditorProvider. Having these two VirtualFiles active are confusing the IDE, and it doesn't realize the file is already open in one tab when using the "Jump To Source" action. The OpenFileDescriptor is failing to identify the opened editor to navigate to when called upon in FileNavigator, which could all come back to the two VirtualFile problem.


So long story short, it seems like the JetBrains IDEA software is just not built to support this kind of workflow, and any workarounds I've attempted have not been successful. I'm going to unassign myself but leave this open in case someone else would like to take a stab at this (I'm also happy to share more details to anyone interested in picking up this work).

@justint justint removed their assignment Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants