Retrieving the previous token

SyntaxEditor for Windows Forms Forum

Posted 16 years ago by Marianne
Avatar
When a trigger fires (for a '.', for example) I'm looking for the previous word. Using:
Editor.Document.CurrentView.GetPreviousToken().Text simply returns '.'. Wouldn't that be the current token? How can I retrieve the actual previous token without using the old 'EndOffset - 2' method?

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

Comments (3)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Technically after you type in a "." the caret is after the dot so the dot really is the previous token. To get the one before it, you would want to probably get a TextStream for the current offset - 2 as you said. Then look at its CurrentToken property. With a TextStream, if you need to iterate further back you just call GoToPreviousToken so it's a great way to do Token navigation.


Actipro Software Support

Posted 16 years ago by Marianne
Avatar
In addition to specifying a token type to move to, would it also be possible to overload GoToPreviousToken() to accept an int to move back (or forwards) x number of tokens. Otherwise, if I want to move backwards three tokens, I need to call that method three times.

Thanks.

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

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
New overloads for GoToNextToken and GoToPreviousToken will be in the next maintenance release that accepts the number of tokens to move as a parameter.

[ 05-03-2004: Message edited by: Actipro Software Support ]


Actipro Software Support

The latest build of this product (v2020.1 build 0400) was released 24 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.