ParamterInfo / Adding to memberlist dynamically?

SyntaxEditor for Windows Forms Forum

Posted 10 years ago by David
Avatar
Hi,

1)

Once you press '(' on a memberlist item, the paramterInfo pops up and then displays the tooltip of a certain string. What i'm trying to figure out is how do I bold each paramter when i press ',' to move to the next argument. At the moment I'm handling the ',' key, and re-drawing the tooltip text everytime but changing the selected parameter to bold. I was wondering if there was a built-in method?

2)

Secondly, I'm trying to figure out the best way to dynamically add items to the memberlist, that have been typed into the editor. It might be a little bit complicated but I would want, when the user types... 'Car a = new Car();', that 'a' would be added to the memberlist. It should also be removed from the list when the text is deleted. This seems like a difficulte thing to pull off, and was looking for some insight in how to achieve it.

Thanks.

Comments (8)

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

1) That is effectively what we do too. Check out our SimpleSyntaxLanguage sample and search that code for "parameterinfo". You'll find all the places we update parameter info based on input etc. However note that our sample shows how to take part in notifications of when a new parameter is active (OnSyntaxEditorIntelliPromptParameterInfoParameterIndexChanged). There is some built-in functionality for handling that. But you still do need to rebuild the markup to bold the appropriate area.

2) The same language sample shows how to build a member list dynamically. Search the code for "memberlist" for that. We construct an AST of the document and use that to enumerate the functions that are declared in it. Then we show those names in the member list. The AST updates via a worker thread running the semantic parser we generated using the Grammar Designer.

Hope this helps.


Actipro Software Support

Posted 10 years ago by David
Avatar
Thanks, that is helpful.

I'm also having a problem with the intelliprompt not working correctly when pressing a key-char on selected text. I'm handling OnSyntaxKeyTyping to show the memberList.

If i have 'hello', select it and type 'int' then 'hello' is overwritten but the memberList only starts to appear when the 'n' in 'int' is typed, and it should appear when the 'i' is typed.

Is that a bug or does it require something else?

:EDIT > also how do i check if i'm currently typing inside a string? I don't want to show the memberlist if i'm inside " .... ".

Thanks, again.

[Modified at 11/05/2009 09:18 PM]
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
David,

OnSyntaxEditorKeyTyping occurs before the character is typed. You probably want to use OnSyntaxEditorKeyTyped instead.

You can get a TextStream at any time from a document (GetTextStream() method) and use that to look at the tokens you are in or around. The tokens should tell you if you are in a token related to a string.


Actipro Software Support

Posted 10 years ago by David
Avatar
I've been working on a different part of my application, but now i'm updating the script controls...

If I used OnSyntaxKeyTyped, then I wont be able to do any pre-validation to see what tokens I am around, eg I don't want to show the memberlist if the previous word is a data type.

So it seems OnSyntaxKeyTyping is the correct method, but it still doesn't work if I have selected text, then press a key. The memberlist doesn't show.

Also using OnSyntaxKeyTyped, say i type 'v' and then the memberlist is shown with 'var'. If i press enter for 'var' then I get 'vvar'.
Posted 10 years ago by David
Avatar
hmm I think i've solved it by adding...

'syntaxEditor.Views[0].DeleteSelectedText(DocumentModificationType.Delete);'

...to the OnSyntaxTypingEvent.

Any advice on how I can achieve that 'Car hi = new Car();' thing using only a dynamic language? My idea is check when a word is typed, use a TextStream to see if the previous word is a datatype, hence a declaration is being made, then add it to an internal list, which the memberlist can be populated with. Only problem is handling when a word has finished.

Is there a OnWordTyped or something similar, or would I have to check each time a character is entered into the document?

Thanks.
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi David,

It's hard to say what is happening without seeing a simple sample showing the issue. But you can pass the member lists a range via the Show method overload that tells it which text range to track and replace when you select a member list item. It auto-adjusts that range based on edits. I would still not recommend showing a member list from the KeyTyping event. You should do it in KeyTyped if at all possible.

It's pretty difficult to properly track variable declarations without some sort of AST. You could do it with a list but it's going to be hard to come up with a scope-based variable list when you just have a stream of text and no semantic hierarchy (like an AST). Depending on your language complexity you may be able to throw together sometime that works for your needs though.

We don't have any sort of word notification events. You'd have to track characters and determine when words are finished.


Actipro Software Support

Posted 10 years ago by David
Avatar
Thank you for your reply. I've been working on a mechanism for the past week and it seems to do everything I need, even if it is a dynamic language. Of course I have more questions...

1) Is there something dodgy with the 'Backspace' key? It seems to fire in the OnSyntaxTyped event sometimes, and then other times doesn't. I've heard of BackSpaceAction/Command, could you tell me how to use it to guarantee the backspace key is picked up.

2) I've highlighting errors in my code. I know this would usually be done using a CompilationUnit, but I'm doing it manually. I'm trying to do something simple like place a 'wiggly' line under ever identifier beginning with 'a'...

foreach(IToken token in document.Tokens)
{
if(token.ID == (int)id.Identifier && document.GetTokenText(token)[0]=='a')
{
token.HighlightingStyle.UnderlineStyle = HighlightingStyleLineStyle.Wave;
token.HighlightingStyle.UnderlineColor == Color.Red;
}
}

...and I thought this would work, but I soon realised this affects the parent highlighting style defined in the XML definition, and so every identifier token will have 'wiggly' lines. What method do you recommend, which is similar to above?
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
David,

1) Backspace should be working correctly and should be getting consumed as long as a backspace key with no modifiers is pressed. If you see something different, please email us a simple sample project that shows it.

2) Correct, that is not a good way to do it since you affect everything. You should use span indicators instead. I believe our QuickStart for indicators shows how to do a wave line too.


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.