outlining fails on later outlining when earlier changes made

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by Kelly Leahy - Software Architect, Milliman
Version: 4.0.0245
Avatar
In my language, I have one type of node that supports outlining. When it parses successfully, everything works fine. The language looks like:

formula <id>
applies to <id> { , <id> }
<expression>
applies to <id> { , <id> }
<expression>
...

where applies to ... can appear as many times as desired, but must appear at least once.

My outlining is for the "expression" after applies to's ID list. Expression can be quite long (not indicated above).

Anyway, when I make changes to each "applies to" section, the outlining will go away while the text in the section is not a valid expression and come back as soon as it is a valid expression.

However, when I edit the first "applies to" section, the outlining controls for all sections disappear (not terribly surprising, since the entire formula is bogus), but then when I correct the syntax problems in that section, only the outlining controls for that section reappear, the others continue to be missing. Only after I edit the later "applies to" sections do they reappear.]

The question is this - is this a bug, or am I doing something wrong in my parser / call to CollapsibleNodeOutliningParser? Oh... I almost forgot, I've modeled my collapsing "applies to" sections after the simple language demo's ICollapsibleNode implementation (for function, IIRC).

Thanks,

Kelly Leahy Software Architect Milliman, USA

Comments (4)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Kelly,

Check out this recent post and let us know if it describes the same scenario. Perhaps the info posted there will help:
http://www.actiprosoftware.com/Support/Forums/ViewForumTopic.aspx?ForumTopicID=2166


Actipro Software Support

Posted 18 years ago by Kelly Leahy - Software Architect, Milliman
Avatar
Well... I forgot to mention I'm using a mergeable non-dynamic language implementation, so I don't think that post applies.

However, here's some snippets, in case they help you...

        public override void ResetAutomaticOutliningBehavior()
        {
            this.AutomaticOutliningBehavior = ActiproSoftware.SyntaxEditor.AutomaticOutliningBehavior.SemanticParseDataChange;
        }

        public override TextRange PerformAutomaticOutlining(Document document, TextRange parseTextRange)
        {
            TextRange newRange = new TextRange(Math.Max(0, parseTextRange.StartOffset - 100), Math.Min(document.Length, parseTextRange.EndOffset));
            return new CollapsibleNodeOutliningParser().UpdateOutlining(document, newRange, document.SemanticParseData as RootFormula);
        }

Kelly Leahy Software Architect Milliman, USA

Posted 18 years ago by Kelly Leahy - Software Architect, Milliman
Avatar
Actually, I reread that thread and tried this:

        public override TextRange PerformAutomaticOutlining(Document document, TextRange parseTextRange)
        {
            //TextRange newRange = new TextRange(Math.Max(0, parseTextRange.StartOffset - 100), Math.Min(document.Length, parseTextRange.EndOffset));
            TextRange newRange = new TextRange(0, document.Length - 1);
            return new CollapsibleNodeOutliningParser().UpdateOutlining(document, newRange, document.SemanticParseData as RootFormula);
        }
which seems to do the trick. However, is this very efficient? Is there a better solution to this problem, or is this, in fact, the correct solution?

My documents are not going to be very large (for this parser), so I don't think it's that big a deal, but I just want to know as a FYI whether this is the best solution to this problem (i.e. to capture the entire applicable range in the textRange).

Thanks for pointing me in the right direction, though! I'll go with this for now.

My real question now, is does this reparse the entire document, or does it just affect which nodes in the AST that the outliningparser looks at?

[Modified at 03/08/2007 01:17 PM]

Kelly Leahy Software Architect Milliman, USA

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The CollapsibleNodeOutliningParser.UpdateOutlining method uses the TextRange you pass in to determine how best to optimize itself so that it doesn't update any more than it needs to. Normally it takes the start offset you pass and backs up several characters just in case one of those has caused a change. However in your case it seems that that range is not large enough. Once it has a range, it compares the AST nodes in that range with the outlining nodes in the document and updates them as needed. It quits as soon as it can as well.

The TextRange that we pass should indicate the optimized range of characters that were modified by the lexical parser.

Without being able to debug your code, it's hard to say why moving the start offset back like you did didn't help. Maybe it needed to be moved back even further than what you indicated. However having it reparse the whole document's nodes with your latter post will impact performance eventually if you have larger documents.

One thing you might be able to do is print out where your desired outlining node's start offset is and then print out if your modified TextRange when you move back is reaching that or not.


Actipro Software Support

The latest build of this product (v24.1.1) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.