# Class CodeAutocompleteProvider OptimaJet.Workflow.Core.Runtime.CodeAutocomplete.CodeAutocompleteProvider Aggregates, stores, and routes autocomplete requests to [ICodeAutocompleter](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/ICodeAutocompleter/) implementations. Namespace: [OptimaJet.Workflow.Core.Runtime.CodeAutocomplete](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/) ```csharp public class CodeAutocompleteProvider : ICodeAutocompleteProvider ``` ## Type Hierarchy - CodeAutocompleteProvider Current type - Implemented interfaces - [ICodeAutocompleteProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/ICodeAutocompleteProvider/) ## Constructors `public CodeAutocompleteProvider(Func getLogger, bool allowParallel = true, bool supressAutoAddDefaultAutocompleter = false, params ICodeAutocompleter[] autocompleters)` Initializes a new [CodeAutocompleteProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/CodeAutocompleteProvider/) with optional custom autocompleters. ### Parameters | Name | Type | Description | | --- | --- | --- | | `getLogger` | `Func` | A factory that returns a logger instance for diagnostics. | | `allowParallel` | `Boolean` | `true` to use parallel enumeration when configuring and iterating autocompleters; otherwise `false`. | | `supressAutoAddDefaultAutocompleter` | `Boolean` | When `false`, this provider adds [DefaultAutocompleter](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/DefaultAutocompleter/) if a default implementation is not supplied. | | `autocompleters` | `ICodeAutocompleter[]` | Custom autocompleters to register. | `public CodeAutocompleteProvider(Func logger)` Initializes a new [CodeAutocompleteProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/CodeAutocompleteProvider/) with parallel behavior and default autocompleter setup. ### Parameters | Name | Type | Description | | --- | --- | --- | | `logger` | `Func` | A factory that returns a logger instance for diagnostics. | `public CodeAutocompleteProvider(Func logger, params ICodeAutocompleter[] autocompleters)` Initializes a new [CodeAutocompleteProvider](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/CodeAutocompleteProvider/) with custom autocompleters. ### Parameters | Name | Type | Description | | --- | --- | --- | | `logger` | `Func` | A factory that returns a logger instance for diagnostics. | | `autocompleters` | `ICodeAutocompleter[]` | Custom autocompleters to register. | ## Properties `protected Action Log { get; }` Gets a callback that logs exceptions with both tracing and optional logger infrastructure. ## Methods `public virtual void RunInitTask()` Starts asynchronous initialization of all autocompleters that are not initialized. `public virtual void InitCodeAutocomletersThatNoInitialized()` Initializes all configured autocompleters that have not been initialized yet. ### Remarks Exceptions from individual autocompleters are logged and do not stop initializing the remaining providers. `public virtual void RegisterCodeAutocompleters(params ICodeAutocompleter[] completers)` Adds custom autocompleters to the provider without initializing them. ### Parameters | Name | Type | Description | | --- | --- | --- | | `completers` | `ICodeAutocompleter[]` | Autocompleter instances to append. | ### Remarks Passing `null` for `completers` is ignored. `public virtual void AddVariablesToDefaultCompleterIfEnable(IEnumerable variables)` Adds variables to the [DefaultAutocompleter](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/DefaultAutocompleter/) when it is present. ### Parameters | Name | Type | Description | | --- | --- | --- | | `variables` | `IEnumerable` | Variables to add to the default autocompleter. | ### Remarks If the default autocompleter is not configured, no action is taken. If the default autocompleter has not been initialized, it is initialized first. `public virtual void AddVariablesToDefaultCompleterIfEnable(string varName, Type varType)` Adds a single variable definition to the [DefaultAutocompleter](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/DefaultAutocompleter/) when it is present. ### Parameters | Name | Type | Description | | --- | --- | --- | | `varName` | `String` | Variable name used for autocomplete. | | `varType` | `Type` | Variable [Type](https://learn.microsoft.com/dotnet/api/system.type) whose full name is used by the default completer. | ### Remarks If the default autocompleter is not configured, no action is taken. If the default autocompleter has not been initialized, it is initialized first. `public virtual HashSet Get(string pattern, IEnumerable usings, IEnumerable variables)` Gets autocomplete suggestions from all configured and already initialized autocompleters. ### Parameters | Name | Type | Description | | --- | --- | --- | | `pattern` | `String` | Text to match, for example, `System.Thr`. | | `usings` | `IEnumerable` | Usings in scope, for example, `System` or `System.Threading`. | | `variables` | `IEnumerable` | Variables that can be used in autocomplete. | ### Returns | Type | Description | | --- | --- | | `HashSet` | A distinct set of matching [AutocompleteItem](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/AutocompleteItem/) values. | ### Remarks Errors from individual autocompleters are logged and do not prevent collecting results from others. `protected virtual IEnumerable UseParallelOption(bool allowParallel, IEnumerable autocompleters)` Applies the provider's parallel execution setting to the autocompleter sequence. ### Parameters | Name | Type | Description | | --- | --- | --- | | `allowParallel` | `Boolean` | `true` to return a parallel sequence; otherwise returns the source sequence as-is. | | `autocompleters` | `IEnumerable` | The source autocompleters. | ### Returns | Type | Description | | --- | --- | | `IEnumerable` | An enumerable view of autocompleters used by this provider. | ## Fields `protected IEnumerable _autocompleters` Registered autocompleters used by this provider. `protected readonly Func _getLogger` Factory used to create logger instances for diagnostics. `protected readonly bool _allowParallel` Indicates whether autocompleter enumeration should be prepared for parallel execution. [Previous AutocompleteVariable](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/AutocompleteVariable/) [Next DefaultAutocompleter](https://api.workflowengine.io/core/OptimaJet.Workflow.Core.Runtime.CodeAutocomplete/DefaultAutocompleter/)