Retrieving DeletedToken Text

SyntaxEditor for Windows Forms Forum

Posted 14 years ago by Marianne
Avatar
When trying to get the deleted token text like so:
                foreach (Token t in document.Tokens.DeletedTokens)
                {
                    if (t.Key == "VariableDefinitionToken") 
                        Console.WriteLine("Def deleted: " + document.GetTokenText(t));
                }
It only ends up giving me the text at the location formerly occupied by the token, but now that it's deleted the document.GetTokenText() method does not give me the deleted tokens text. How can I retrieve the deleted token's text? Thanks.

------------------------------- Marianne

Comments (1)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Marianne,

For memory reasons we don't store the text of the token with each token. In the PostParse method of the semantic parser, you know the full text of the completed document. You also know the change start location which is indicated in the modification's StartOffset. You know the text that was deleted (if any) in the modification's DeletedText property and you know what was inserted (if any) in the modification's InsertedText property. By combining that sort of information you could derive the text that was deleted by looking at a combination of what is currently in the document (which really also includes the inserted text) and the DeletedText in the modification if the token's range falls in that.


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.