Knowing when typing a comment

SyntaxEditor for WPF Forum

Posted 10 years ago by John Dunn
Version: 9.2.0514
Avatar
I'd like to know when the user is typing a comment so I don't show the Intelliprompt popup. In the DocumentTextChanged handler, it looks like I can use _Editor.ActiveView.GetReader().ReadTokenReverse() to grab the current token. If it's currently inside a comment, the token Key will be "SingleLineCommentText" or "MultiLineCommentText" ( this is for a lua editor ). The .langdef file also defines a DefaultClassificationTypeKey for both types of comments as "Comment". Is there a way to get this value from the current reader? If I added an Id to the .langdef comment definition would that then be available here?

EDIT : Poking through the documentation, it looks like it might be better if I get the current LexicalState - if I'm in SingleQuoteString, DoubleQuoteString, LongBracketString, MultiLineComment or SingleLineComment I don't want to show the popup. How would I go about getting the current ILexicalState inside the DocumentTextChanged handler?

[Modified at 02/05/2010 04:34 PM]

Comments (3)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi John,

If you are loading from a .langdef file, then you know the token type will be an IMergableToken (which also implements IToken). IMergable token has everything you are looking for like ClassificationType, LexicalState, etc.

Yes a token ID defined in the language definition will show up in IToken.ID. A lexical state ID defined in the language definition will show up in the LexicalStateID for a token, and also in the ILexicalState.ID property for an ILexicalState.

So to sum up, yes using an ITextSnapshotReader is what you want to do here like you are. And just cast your IToken to an IMergableToken when appropriate and you can get all the info you need.


Actipro Software Support

Posted 10 years ago by John Dunn
Avatar
Thanks. Is there an automatic way to managed IDs or do I just need to manually make sure that the ID I put in the langdef file is that same as what I have in my source?
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Right now you'd have to ensure they are the same. Eventually we hope to add some code to the Language Designer to generate a token ID class with ID constant properties on it that you could use.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.