Minor OutliningNode bug; suggestions

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Blaise
Avatar
Hi,

Thanks for a very cool product!

I'm using v3.0.0177 of the SyntaxEditor and have noticed both a minor bug and an "anomaly" of the Text property of the OutliningNode. I also have a suggestion.

The anomaly is that the text returned by the Text property begins with the node's key word (e.g., "Sub" or "Function"). I would have thought that the Text of the outlining node would have begun at the start of the line on which the token is found. So, in this example:
   Private ReadOnly Function Foo() As Boolean
The first 20 characters of the line ( Private ReadOnly ) are not included in the node's Text property. Please consider changing this behavior so that the node starts at the beginning of the line.


The bug is that the last charater of the Text property is missing. That is, the example above might end like so:
   End Function
But the last characters of the Text property are " End Functio"

My goal is to emulate VB.Net's code windows, that have two combo controls at the top of the form for entity (on the left) and routine name (on the right). Not only do I have to populate the combos, but when the caret moves, I have to figure out what routine of which entity the caret is in (so I can display the proper entries in the combos).

I was thinking that since outlining nodes are created as the code is parsed by SE, I can readily accomplish these goals by traversing the outline nodes (to populate the combos), and using the caret position and the node FindRecursive method (to find out which routine the caret is in).

The only issue is to figure out what action of the user will invoke a refresh of the combos (open to suggestion here - perhaps some logic in PostParse?).

My suggestion: an OutliningNode.Identifier property (or perhaps Name). All outlining node key words are followed by an identifier (the name of the Sub, Function, Interface, etc. of the outline node). It would be very handy for a node to have this identifier as a property (instead of having to go look for it). The only exception is a "#Region", but this has a quoted string "label" which could certainly be set as the Identifier (or Name) property.

Thanks!


[Modified at 06/15/2005 08:44 PM]

Comments (7)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks, we just noticed the bug with the outlining node ourselves while debugging the other day so we'll get that fixed for the next release.

As for the OutliningNode.Text property, it only returns the text that is collapsed so that is accurate. Boyd has suggested having an addition offset range added to nodes which provide more of a semantic range which could be used for what you want.

PostParse is probably where you want that sort of logic. We're going to be working on improving parsing for specific languages in the future.

Also each OutliningNode has a ParseData property that has the key that is assigned to the node. Check that out.


Actipro Software Support

Posted 14 years ago by Blaise
Avatar
Thanks,

Yes, I'm using the ParseData.Key to see what type of outline node it is (SubBlock, FunctionBlock, etc). But because I want the Name of the Sub or Function too, I have to look in the text for it (get a TokenStream, read a few tokens till I find an identifier).

That's not hard, but since virtually all outline nodes have an identifying token, it seemed natural that this be a property of the node ... especially given that this code may be in a tight loop, so one would want to avoid the overhead of poking through the text many times repeatedly.

Thanks again.
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
If you want to add additional data to a node then create your own class that inherits OutliningNodeParseData and replace the ParseData property with that. You can examine ours for the Key and create an instance of your class and add whatever properties you need to hold additional info.


Actipro Software Support

Posted 14 years ago by Blaise
Avatar
That's a good idea, but how can I hook into the creation/deletion of OutliningNode objects? That is, nodes are created and removed all the time as the end user edits code in the SE window. As far as I can see, there is no "NodeAdded" event, nor a DocumentModification type of "OutliningNodeAdded" (so I'd catch it in the PostParse event). Is there another way to detect the addition/removal of OutliningNodes that I am missing?

Thanks
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
There isn't an event that fires right now. The best way is to examine the nodes in the range of offsets that are modified for outlining. You can get to this via:
modification.OutliningParseOffsetRange


Actipro Software Support

Posted 14 years ago by Blaise
Avatar
Thanks ... but what is this? Sorry to be obtuse, but I can't find any reference to "OutliningParseOffsetRange" in the docs. Is this a member of the DocumentModificationType Enum?

Perhaps in a later rev ... ? (I'm using SE v3.0.0177)

Looks like current rev is v3.0.0179. As a registered customer, am I entitled to download an upgrade?

Thanks ...
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Oh I apologize. It's an internal property on DocumentModification, not public. We'll make it public for the next release.


Actipro Software Support

The latest build of this product (v2018.1 build 0342) was released 11 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.