How to open the intellisense when type text?

SyntaxEditor .NET Languages Add-on for WPF Forum

Posted 6 years ago by Roger
Version: 18.1.0672
Avatar

I'm using SyntaxEditor with C# .Net language addon.

I would like to display the intellisense when a type charactor eg. i -> int.

Do you have a option to show intellisense?

Comments (6)

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Roger,

Please see the "SyntaxEditor / User Interface Features / IntelliPrompt Features / Completion List" topic in the documentation that comes with the product.  There is a section in that named "Opening a Session in Response to a Typed Character ('.', '<', etc.)" that has a sub-section "Sample: Showing a Completion List Automatically When a New Word Is Started".  I believe that is what you'd want to look at.


Actipro Software Support

Posted 6 years ago by Roger
Avatar

I read the document and wrote codes as following and it worked.

 

 
private void OnDocumentTextChanged(object sender, EditorSnapshotChangedEventArgs e)
	    {
            if (e.TextChange.Source == this.codeEditor.ActiveView)
            {
                if (e.IsTypedWordStart)
                {
                    // If no completion session is currently open, show a completion list
                    if (!this.codeEditor.IntelliPrompt.Sessions.Contains(IntelliPromptSessionTypes.Completion))
                    {
                        // Open the completion list session here
                        EditorCommands.RequestIntelliPromptCompletionSession.Action.Execute(this.codeEditor.ActiveView);
                    }
                }
            }
        }

 

But I found the documentation as following but it did not work.

Which should I use?

Completion List
IntelliPrompt completion lists are used to present end users with a list of accessible members from the code editor's current caret location. In many cases, the completion list is triggered by key events such as pressing Ctrl+Space or typing a . character after an identifier.

There are two types of completion list scenarios when typing in code blocks. First is when listing members of something. This can occur when typing a . character after an identifier. The second type is when showing all accessible members based on the current context. This can occur when starting to type a new sequence of identifiers.

When typing a < character in documentation comments, a list of appropriate documentation comment tags is displayed.

In cases where a completion list is triggered via Ctrl+Space, if there is a single match for the text that has been typed, it will not show the list but will auto-complete the match. This saves the user from having to type the entire identifier/keyword that was matched.

The completion list features are implemented by the CSharpCompletionProvider class.

Disabling Auto-Show On Typed Word Start
The CSharpCompletionProvider class has a CanShowOnTypedWordStart property that defaults to true. When true, the completion provider will attempt to automatically show a completion list as the user starts to type a new word, but only in certain contexts. Set the property to false to disable this behavior.

 

I also want to use code snippets. How should I set the path from C# .net addon dll?

This is sample code from the document.

var language = new CSharpSyntaxLanguage();

ICodeSnippetFolder snippetFolder = CodeSnippetFolder.LoadFrom(path, "CSharp");
language.RegisterService(new CSharpCodeSnippetProvider() { RootFolder = snippetFolder });

[Modified 6 years ago]

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Roger,

Could you provide some more detail on your exact question in the first portion of your last reply?  You first said it worked but then you said it didn't work, and I'm not sure what you are referring to.  Thanks.

For the code snippets, the path is the file system path to the root folder where your C# code snippet files are stored for your app.  In our sample app, we ship several code snippet files and the path points to the file system path that contains them.


Actipro Software Support

Posted 6 years ago by Roger
Avatar

OnDocumentTextChanged codes work fine. But If I delete OnDocumentTextChanged and I use CSharpCompletionProvider()

var language = new CSharpSyntaxLanguage();
language.RegisterProjectAssembly(this.projectAssembly);
language.RegisterService(new DebugMouseInputEventSink(OnToggleBreakpoint));
this.codeEditor.Document.Language = language;
var provider = new CSharpCompletionProvider();
provider.CanShowOnTypedWordStart = true;
language.RegisterService(provider);

 When I type a characoter, it does not display the intellisense. Should it work?

Posted 6 years ago by Roger
Avatar

About The Code snippets. I registered CSharpCodeSnippetProvider but it deos not display any Snippet.
How to use CSharpCodeSnippetProvider? What is the purpose of this provider?

Posted 6 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

CSharpCompletionProvider.CanShowOnTypedWordStart is actually true by default, so you shouldn't have to set anything there. The CSharpCompletionProvider.ShouldShowForTypedWordStart virtual method is where we return whether a typed word should show the completion list, based on some token scanning and context examination. We currently only return true from that method for scenarios where we are pretty confident of the contextual location kind. Such as when after an expression operator (+), etc. We could pop it up more aggressively but it might get annoying in some cases where we don't have a related completion list narrowed down to that exact contextual location.

For code snippets, those behave the same as the Visual Studio code snippets feature (https://docs.microsoft.com/en-us/visualstudio/ide/code-snippets?view=vs-2017).  We have a documentation topic that covers them as well.  Each code snippet can define a segment of code with certain defined fields that have defaults that  be changed by the end user.  You activate a code snippet by typing its shortcut and pressing Tab.  Both VS and our main SDI Editor have a "for" code snippet that activates when you type "for" and press Tab.  You need to supply all the code snippets that you wish to support.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.