Export Structure View to txt file

Answered

Help Please,

   I am using Flutter/Dart, and I would like to be able to export the information in the Structure View to a text file.

  I'm overwhelmed by all the information.

  Would someone be able to point me in the right direction, or point me to some existing code that access the information in the Structure view.

Thanks a bunch. 

4 comments
Comment actions Permalink

Dart is implementing lang.psiStructureViewFactory EP that provides a structure view model of the given file:

<lang.psiStructureViewFactory language="Dart" implementationClass="com.jetbrains.lang.dart.ide.structure.DartStructureViewFactory"/>

Such a model – DartStructureViewModel – is used later for component rendering, so you can also try accessing it for your own purposes.

0
Comment actions Permalink

That is a awesome hint! Thanks a bunch.

Now I just have to learn how to use an EP, right? ;-)

0
Comment actions Permalink

You could try with

PsiStructureViewFactory factory = LanguageStructureViewBuilder.INSTANCE.forLanguage(psiFile.getLanguage());
factory.getStructureViewBuilder(psiFile).createStructureView(fileEditor, project).getTreeModel()
0
Comment actions Permalink

I've been trying to rummage through all the docs I can, and yet never came across that info.

Tried using the debugger to inspect the classes but no luck getting it to run debug in the IDE scripting environment. I'll have to transition this to a plugin so I can use the debug features.

So thanks so much for that bit of code, but if you know of a page with any info on this package please let me know.

0

Please sign in to leave a comment.