find out if an outlining node has an end token?

SyntaxEditor for Windows Forms Forum

Posted 13 years ago by Karl Grambow
Version: 4.0.0237
Avatar
Hi,

I'm trying to figure out if an an outlining node has an ending token and can't seem to do it.

Say for example that I have an outlining node that is defined by "begin"..."end". If I just type "begin" the outlining node is automatically created except that the token spans the entire document. But it's still possible to close/open the node. Is there a property of the outlining node that can tell me whether it contains an ending token?

Thanks,

Karl

Comments (7)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I believe there is an IsOpen property, where also the EndOffset is -1.


Actipro Software Support

Posted 13 years ago by Karl Grambow
Avatar
Hi,

Thanks for the reply.

In my case I'm not seeing this behaviour. The IsOpen property is set to true and the EndOffset has a postive integer value.

Karl
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
It is matching something there then. Try looking at the token at that offset.


Actipro Software Support

Posted 13 years ago by Karl Grambow
Avatar
Hi,

Thanks for the reply.

There's a line terminator at the indicated offset.

I'll give you some steps to follow so you can mimic what I'm doing. I haven't done a good job of explaining myself so far but hopefully this will help.

In the sample application:

1. Open up SDI Editor Application and change the language to SQL.
2. Select and delete the pre-loaded SQL example and hit return a few times so you have a few lines in the document.
3. Place the cursor on line 1 and type "--region" (without the quotes).

Upon typing the "n" in "region" you'll notice that an outlining node is created where the end of that outlining node is on the last but second line in the document. So if you have 5 lines in the document the end offset of the outlining node is on line 4. This is despite the fact that this particular outlining node needs "--end region" in order to close it.

Now, if you add a watch for editor.Document.Outlining.RootNode.FindNodeRecursive(0) you'll notice that the endoffset isn't -1.

Essentially I want to check whether a given outlining node has it's ending properly defined (in the above example this would be "--end region"). However, I cannot just check whether the token at the endoffset is "--end region" because it is possible that another node just happens to end in exactly the same place.

The question is, am I doing something wrong here? Or is there another way I should be doing this in order to achieve the desired result?

Thanks,

Karl
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
My apologies, the EndOffset will always return an offset even if there is no match. In the case where the node is a child node and has no end, it will return the end offset of the parent. In the case where the node is a root node and has no end, it will return the document length.

The way to tell if a node has an end is via the IsOpen property by itself. So if IsOpen = true then you know the EndOffset is really a "virtual" offset and doesn't indicate a token ends the node. Rather a parent node or the document end ends it.

I hope that makes sense. IsOpen will be false for all outlining nodes that have a proper end token.


Actipro Software Support

Posted 13 years ago by Karl Grambow
Avatar
Thanks a lot for the clarification. That's perfect!

I had incorrectly assumed that IsOpen referred to whether the node was collapsed or not and I never noticed that it was set to false when the node had an end.

Thanks again,

Karl
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Right, an "open" node is considered to be a node that has no end. The Expanded property will tell you whether the node is expanded or collapsed.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 10 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.