I have spent ages on this problem and I know it must be staring me in the face but I just can’t figure it out.
I have (heavily) modified old code by @Kem_Tekinay and @Jeremy_Cowgar (see here) that takes a Xojo project file and parses it into the constituent items (such as modules, classes, interfaces, etc).
This code creates a File
instance for each class, module, etc. Each File
tracks the unique ID of it’s parent (which might be the root of the project, a module, folder, etc). It uses this information to construct the File
s name and path.
After modification, my code knows the path in the project for every item. For example, given this project structure:
App
Class1
Module1
- Module2
--- Class2
- Class3
Folder
- SubFolder
-- Class4
I have this information:
App.Path = ""
Class1.Path = ""
Module1.Path = ""
Class2.Path = "Module1>Module2"
Class3.Path = "Module1"
Folder.Path = ""
SubFolder.Path = "Folder"
Class4.Path = "Folder>SubFolder"
I also know the unique ID for each item’s parent.
I’ve been trying for hours to turn this flat structure into a tree. Specifically, I want to use @Björn_Eiríksson TreeView control to represent this hierarchy. I know I need to use some sort of recursion but I just can’t work out how to find nodes that have already been added to the tree view. At this point I’d settle for using a hierarchical listbox.
Any help would be greatly appreciated.
As you might imagine, this is for a tool in development to help other Xojo coders manage their projects.