IAstNode StartOffset and EndOffset return values depend on product version

SyntaxEditor Web Languages Add-on for WPF Forum

Posted 5 years ago by P. Chwoika - Inosoft GmbH
Version: 14.1.0601
Platform: .NET 4.5
Environment: Windows 7 (64-bit)
Avatar

Hello actipro team :)

We are using your AstNodes to analyse the structure of XAML-Documents and use the offsets of these AstNodes to replace and cut text in this document.

We recently upated from version 12.1 to 13.2 and discovered that the return values of the StartOffset and EndOffset-Properties change depending on your product version.

I created a little sample with a SyntaxEditor and an XmlSyntaxLanguage:

 <editor:SyntaxEditor x:Name="xmlEditor" >
            <editor:EditorDocument x:Name="editorDocument">
                <editor:EditorDocument.Language>
                    <editor:XmlSyntaxLanguage />
                </editor:EditorDocument.Language>
            </editor:EditorDocument>
        </editor:SyntaxEditor>

 The EditorDocument is filled with a simple WPF UserControl.

Now I access the ParseData of the EditorDocument and get a specific node:

XmlParseData parseData = this.editorDocument.ParseData as XmlParseData;
IAstNode node = parseData.Ast.Children[0].Children[2].Children[0].Children[2];

 If we now look at the .toString() output from this AstNode we can see the differences:

            //Version 12.1.560 output:
            //Nodes[1 child] (478-586)

            //Version 12.2.573 output:
            //Nodes[1 child] (478-586)

            //Version 13.2.591 output:
            //Nodes[1 child] (479-591)

            //Version 14.1.601 output:
            //Nodes[1 child] (479-591)

 Can you please tell us if this is a bug? Or is it the result of a bug you fixed in the past?

Thanks in advance.

Comments (3)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello, I'm not seeing anything related to this in the release history so I'm not sure what changed here.  It might have been a very minor tweak that we didn't think was necessary to list in the release history.

Which one is correct?  Is the newer version appropriately covering the range?  I suspect it was probably a bug fix and the newer version is correct.


Actipro Software Support

Posted 5 years ago by P. Chwoika - Inosoft GmbH
Avatar

At the moment, i can't see which one is correct.

Maybe you can help me determine that :)

I opened my XML Document in Notepad++ and used the "Go To Line" function which shows the current cursor offset. Unfortunately this doesn't match with the line numbers of the AstNodes.

Isn't it that you don't count the \r \n chars? Maybe that's why notepad++ has different offsets?

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

While the document is loaded, that is correct that we only count each line terminator as a single \n.  So offsets could be different from other apps. 

An easy way to tell if the offsets are ok is just pick a node offset range and programmatically select that range in the editor.  See if the selection falls over the range that you expect for that particular node.


Actipro Software Support

The latest build of this product (v2019.1 build 0682) was released 3 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.