/// <summary> /// Ctor (unit test hook) /// </summary> /// <param name="callback">Callback context object (unit test hook)</param> public PowerShellIntelliSenseService(IIntelliSenseServiceCallback callback) : this() { _callback = callback; _testRunspace = RunspaceFactory.CreateRunspace(); _testRunspace.Open(); }
private void ProcessCompletion(string script, int caretPosition, int requestWindowId, long triggerTag) { lock (_syncLock) { _requestTrigger = triggerTag; } if (_callback == null) { _callback = OperationContext.Current.GetCallbackChannel <IIntelliSenseServiceCallback>(); } // Start process the existing waiting request, should only be one Task.Run(() => { try { CommandCompletion commandCompletion = null; lock (ServiceCommon.RunspaceLock) { if (_runspace.RunspaceAvailability == RunspaceAvailability.Available) { commandCompletion = CommandCompletionHelper.GetCommandCompletionList(script, caretPosition, _runspace); } else { // we'll handle it when we work on giving intellisense for debugging command // for now we just simply return with null for this request to complete. } } ServiceCommon.LogCallbackEvent("Callback intellisense at position {0}", caretPosition); _callback.PushCompletionResult(CompletionResultList.FromCommandCompletion(commandCompletion), requestWindowId); // Reset trigger lock (_syncLock) { _requestTrigger = 0; } } catch (Exception ex) { ServiceCommon.Log("Failed to retrieve the completion list per request due to exception: {0}", ex.Message); } }); }
public void Init() { _context = new IntelliSenseEventsHandlerProxy(); _service = new PowerShellIntelliSenseService(_context); }