The Actipro Blog

All the latest UI control development news from Actipro

SyntaxEditor IntelliPrompt Code Snippets

BlogPostBanner

Today I'd like to show a preview of the next huge feature area coming to SyntaxEditor for WPF and SilverlightIntelliPrompt code snippets!

UPDATE: Code snippet features are now live for WPF and Silverlight with the release of version 2012.1!

Overview

Code snippets are predefined templates of code that can be inserted into the document to help the end user develop code more efficiently.  They can contain multiple fields and the end user can tab between the fields while the code snippet is active.  Dependent fields can be set up such that when the first field's value is changed, all the dependent fields update their values as well.

Activating Code Snippets

Via Shortcuts

Code snippets can be activated by typing their shortcut and pressing Tab immediately after.

.NET Languages Add-on Integration

The .NET Languages Add-on has been enhanced to automatically show available code snippets in the completion list displayed by Ctrl+Space.  This feature works in both C# and Visual Basic.

CodeSnippets1

Press Tab to insert the code snippet's shortcut text.  Then Tab again to activate it per above.

Insert Snippet Popup

An Insert Snippet popup (another way to insert code snippets) probably won't make the first 2012.1 release, but it is planned for future implementation.

Editing a Template

Once a code snippet has been activated, it's template code is inserted into the editor and the included fields are highlighted:

CodeSnippets2

In this screen, we inserted a code snippet for a C# for statement.  Note how there are two fields: index and count.  The index field shows up three times in the template.  The second and third times have dotted borders, meaning they are dependent on the first field. 

CodeSnippets3

In this screen, we have changed the index field to have a value of i.

CodeSnippets4

Next, the Tab key is pressed to move focus to the next field in the template, which is count.  When the caret leaves a field that has been edited, the related dependent fields' values update.  In this sample, all the index fields now have the value i.

CodeSnippets5

In this final screen, we pressed Enter to exit template editing mode.  The caret automatically moves to an offset designated by the code snippet.  In this case, it was told to move within the for block, and indented a tab stop.

ToolTips

When hovering the mouse over a code snippet template field in the editor, if a tooltip description for the field was specified in the code snippet, it will be displayed.

Object Model

Our code snippet object model loads and saves to the exact same code snippet file format found in Visual Studio. This makes it easy to import and reuse the hundreds of code snippets distributed with Visual Studio and found out on the web.

Code snippet folder and file hierarchies can be loaded from the file system with one easy call, or can be built completely programmatically.

Events

A new event sink is included that allows languages to listen to multiple code snippet-related events, such as when a new code snippet template is activating, or a new field is activated, etc.

Summary

IntelliPrompt code snippets are a very handy feature for end users.  And with our 100% compatibility with Visual Studio code snippets, it's very easy to add pre-built code snippets to your own apps. 

For those of you with custom language implementations (not C#/VB), code snippets can be used with your language as well.

We're excited to get this into your hands soon.  It will be included in the upcoming 2012.1 versions of our WPF and Silverlight controls.

UPDATE: Code snippet features are now live for WPF and Silverlight with the release of version 2012.1!

TaskDownload TaskLiveDemo TaskBuyNow

Comments (3) -

April 10, 2012 at 00:00  

zyko Austria

If i have a code that uses a function where there should be documentation for parameters available anything is ok on writing the call of the function.
while typing , help is displayed for the next parameter.
fe

/// <summary>
/// the worldbest function to use
/// </summary>
/// <param name="first"></param>
/// <param name="second"></param>
private void callMeToGetFun(string first, string second) {
}

...
callMeToGetFun("myFirst","mySecond")
...

but if the code has been written an i'm movin above fe. the 2nd argument of the function LATER i cant's see any help.
also CTRL+SPACE does nothing.

the only thing i know till now is to delete the ',' again, and enter it again.
is there any other shortcut for this that someone can use instead?

April 10, 2012 at 03:55  

Bill Henning (Actipro) United States

Hi Helmut,

You can use Ctrl+Shift+Space to reopen a parameter info session where applicable.

April 10, 2012 at 04:19  

zyko Germany

Hi Bill,

You made my day - once again :-o

Ctrl+Shift+Space WORKS

THX Smile
  

Pingbacks and trackbacks (2)+

Comments are closed