Making IDEA open a folder in editor instead of navigating into it

Hello!

I'm writing a Core Data model editor for AppCode.

To prevent AppCode from opening .xcdatamodel files in Xcode I've unregistered built-in com.jetbrains.objc.XCDataModelFileType.
At this point AppCode no longer opens models in Xcode.

Then I've registered and associated custom file type that's not implementing INativeFileType.
Also, I've made custom implementation of FileEditorProvider and registered it in AppCode.

But AppCode doesn't open xcdatamodel file in my editor, I've even tried returning true for any file type in accept method of file editor provider, and it works for any file but models.

And what I think is happening is that OpenFileDescriptor (or some AppCode equivalent of the said file) in navigate method checks whether VirtualFile is directory, and isDirectory method returns yes, so it just navigates to this folder in project view.

  @Override   public void navigate(boolean requestFocus) {     if (!canNavigate()) {       throw new IllegalStateException("Navigation is not possible with null project");     }     if (!myFile.isDirectory() && navigateInEditor(myProject, requestFocus)) return;     navigateInProjectView();   }



Can you give me any tips or suggestions how to proceed?
Thank you in advance.
4 comments
Comment actions Permalink

The easiest way to achieve what you need is to create an in-memory virtual file system implementation based on the DummyFileSystem class, and to represent the Core Data model as a virtual file (not a directory) in your file system. The handling of directories in a way that's different from files is hard-coded in too many places in the IntelliJ Platform core, and it doesn't look like it will be easy to change.

0
Comment actions Permalink

Thank you, I'm actually thought of this idea initially. But hearing confirmation from one of the IDEA developers makes it sound more valid.

0
Comment actions Permalink

I think I'm stuck. I understand how to create virtual file system subclass and virtual file, but how actually to actually use it?
Provide suclasses of TreeStructureProvider and ProjectViewNode or somehow hook into project opening logic?

Don't frown at me, I'm just a humble (and so bad) objective-c developer with whose EE developer friend hinted JAXB.
Thank you.

0
Comment actions Permalink

You could go that way, but I don't think that's really necessary. I would simply implement an action that would create an in-memory virtual file in your VFS and navigate to it, and add this action to the context menu of .xcdatamodel files in the project view.

0

Please sign in to leave a comment.