Intellisense and partial matches

SyntaxEditor for WPF Forum

Posted 4 years ago by John Hennesey
Version: 15.1.0624
Avatar

I am using the intellisense functionality for rehosted workflow designers - LOVE IT!  I would like to extend the functionality a bit so instead of matching on the first bit typed in use a regular expression to match anywhere in the properties/methods/constructors.  Has anyone done this yet?  If so, can you share?  If not, does anybody know where in the sample solution I could put the code?   I can come up with the regex - no problem; I just haven't cracked open the solution enough to explore it.  Trying to avoid reinventing the wheel.  :)

 

Thank you,
John

Comments (6)

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

Hi John,

If you make a class that inherits VBCompletionProvider and override the OnSessionOpening method, you can have access to the IComlpetionSession before it opens.  That method is passed a CompletionSession instance, which has a MatchOptions property you can set.  First call the base method.  Then update the session.MatchOptions to also include the UseShorthand property and return true.  Once you do that, you'll have to register the service on the language to override the default one like this:

language.RegisterService<VBCompletionProvider>(new MyVBCompletionProvider());

Once you do those things, it will have shorthand matching active which allows substrings anywhere.


Actipro Software Support

Posted 4 years ago by John Hennesey
Avatar

Thank you for your quick response - what a great set of classes you have!   The only catch I see is session.MatchOptions is readonly - your response alluded to "update the session.MatchOptions" - I was thinking of adding the two flags.  Am I reading this wrong?

"Property or Indexer 'ICompletionSession.MatchOptions' cannot be assigned to -- it is read only"

using ActiproSoftware.Text.Languages.VB.Implementation;
using ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt;

namespace BreezeWorkflowExpressionEditorService
{
    public class CompletionService : VBCompletionProvider
    {
        protected override bool OnSessionOpening(ICompletionSession session)
        {
            base.OnSessionOpening(session);
            session.MatchOptions += CompletionMatchOptions.IsCaseInsensitive | CompletionMatchOptions.UseShorthand;
            return true;
        }
    }
}

 

Also, where would I register the service?  (I am a db guy... please forgive my ignorance).  I am using the ExpressionEditorService sample project on your web site if that makes it any easier...

(update - would it be in Service.cs constructor?)

 public class ExpressionEditorService : IExpressionEditorService
    {

        private WorkflowDesigner designer;
        private List<IExpressionEditorInstance> editors = new List<IExpressionEditorInstance>();
        private static ISyntaxLanguage language = new VBExpressionEditorSyntaxLanguage();

        static ExpressionEditorService()
        {
            AddCustomResourcesToApplication();
            language.RegisterService<VBCompletionProvider>(new CompletionService());
        }

 

Thanks in advance,
John

[Modified 4 years ago]

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

Hi John,

The interface doesn't have a setter but the CompletionSession implementation class does:

using ActiproSoftware.Text.Languages.VB.Implementation;
using ActiproSoftware.Windows.Controls.SyntaxEditor.IntelliPrompt;
 
namespace BreezeWorkflowExpressionEditorService
{
    public class CompletionService : VBCompletionProvider
    {
        protected override bool OnSessionOpening(ICompletionSession session)
        {
            base.OnSessionOpening(session);
            var session2 = session as CompletionSession;
            if (session2 != null)
                session2.MatchOptions |= CompletionMatchOptions.IsCaseInsensitive | CompletionMatchOptions.UseShorthand;
            return true;
        }
    }
}

And yes, you could register the service like that. 


Actipro Software Support

Posted 4 years ago by John Hennesey
Avatar

Ah, I see!  Works very well!  Is there any way to reduce down the number of entries in the "results" to those that have just the text I type in?  For example, if an object has 50 properties, three of them have the word "JohnId", can it remove all those that do not have a match?

Thank you,
John

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

Yes, you can set session2.CanFilterUnmatchedItems = true to auto-shrink the list.

Check out the "SyntaxEditor / User Interface Features / IntelliPrompt Features / Completion List" topic in the documentation that comes with the product since it walks through all the options that are available.


Actipro Software Support

Posted 4 years ago by John Hennesey
Avatar

Oh that is perfect!  Thank you very much!

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

Add Comment

Please log in to a validated account to post comments.