Outlining help needed

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by Karl Grambow
I've recently started thinking about using Outlining and I'm unsure about how best to achieve what I want. So I thought I'd ask the opinion of those that have used outlining about your thoughts seeing as someone might have already done what I'm hoping to do.

When deciding on what to outline I want to check whether the End token for a given Start token exists. For example, if I want to outline "If...End If" statements, I want to hold off on creating the outline until I can confirm that the corresponding "End If" token key has been found. If the End token wasn't found then the outline won't be created.

Staying with the "If...End If" example and assuming I've just found an "If" token key:

I figured that I could parse the document until I find a corresponding "End If". Obviously, I will need to keep track of any further "If" statements that I might find along the way and process those first - perhaps using recursion?

Does my suggestion have any flaws in it or is there a better way I can achieve the same result? Also, is it better to use automatic outlining or manual? I guess I could implement a class that inherits from SemanticDefaultParser and extend that to suit this situation but I wasn't sure if there was a preferred way.

If there's anything obvious that I'm overlooking please let me know.



Comments (2)

Posted 18 years ago by Matthew Smith - Developer, One Plus One Solutions Pty Limited

I have the same issue myself. The main problem with the auto-outline is the start token automatically opens the outlining.

I've tried a couple of things to get this working (very slow and not neccessarly correct), but if anyone else had a basic quick example of a manual outline process, could they share (at least a qucik overview)?

Regards, Matt

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Sorry we didn't reply sooner, the post notification email slipped through the cracks. Anyhow, automatic outlining means that you the developer programmatically modify the outlining nodes. Manual outlining means that the end user is creating the nodes by using menu options you provide to do things like create an outlining node over the current selected text, etc.

What you are trying to do is hard to do with the approach the SemanticDefaultParser takes. You would have to do a forward scan when you hit the If to see if there is a match.

For v4.0 we're doing a lot of work to support AST building in the background. Once an AST is built of your document, you can use that to know exactly where to place outlining nodes. It's sort of an advanced process because first you need to write a parser that constructs an AST from your document (which can take a while), then you just build outlining nodes from that. We are doing this with our advanced C# implementation and once you have an AST, the outlining node building is pretty fast. In C# we don't want outlining on If node braces ({...}), we only want it on types/members, etc. That is something we couldn't do in v3.1 but is something we can do with an AST type approach.

Actipro Software Support

The latest build of this product (v24.1.0) was released 4 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.