/// <summary>
        /// Initializes a new instance of the DebugService class and uses
        /// the given execution service for all future operations.
        /// </summary>
        public DebugService(
            IInternalPowerShellExecutionService executionService,
            IPowerShellDebugContext debugContext,
            RemoteFileManagerService remoteFileManager,
            BreakpointService breakpointService,
            PsesInternalHost psesHost,
            ILoggerFactory factory)
        {
            Validate.IsNotNull(nameof(executionService), executionService);

            _logger                          = factory.CreateLogger <DebugService>();
            _executionService                = executionService;
            _breakpointService               = breakpointService;
            _psesHost                        = psesHost;
            _debugContext                    = debugContext;
            _debugContext.DebuggerStopped   += OnDebuggerStopAsync;
            _debugContext.DebuggerResuming  += OnDebuggerResuming;
            _debugContext.BreakpointUpdated += OnBreakpointUpdated;
            _remoteFileManager               = remoteFileManager;

            invocationTypeScriptPositionProperty =
                typeof(InvocationInfo)
                .GetProperty(
                    "ScriptPosition",
                    BindingFlags.NonPublic | BindingFlags.Instance);
        }
 public EvaluateHandler(
     ILoggerFactory factory,
     IInternalPowerShellExecutionService executionService)
 {
     _logger           = factory.CreateLogger <EvaluateHandler>();
     _executionService = executionService;
 }
Exemplo n.º 3
0
 public PsesSignatureHelpHandler(
     ILoggerFactory factory,
     SymbolsService symbolsService,
     WorkspaceService workspaceService,
     IInternalPowerShellExecutionService executionService)
 {
     _logger           = factory.CreateLogger <PsesHoverHandler>();
     _symbolsService   = symbolsService;
     _workspaceService = workspaceService;
     _executionService = executionService;
 }
 public PsesCompletionHandler(
     ILoggerFactory factory,
     IRunspaceContext runspaceContext,
     IInternalPowerShellExecutionService executionService,
     WorkspaceService workspaceService)
 {
     _logger           = factory.CreateLogger <PsesCompletionHandler>();
     _runspaceContext  = runspaceContext;
     _executionService = executionService;
     _workspaceService = workspaceService;
 }
 public DebugEvaluateHandler(
     ILoggerFactory factory,
     IPowerShellDebugContext debugContext,
     IInternalPowerShellExecutionService executionService,
     DebugService debugService)
 {
     _logger           = factory.CreateLogger <DebugEvaluateHandler>();
     _debugContext     = debugContext;
     _executionService = executionService;
     _debugService     = debugService;
 }
Exemplo n.º 6
0
 public EditorOperationsService(
     PsesInternalHost psesHost,
     WorkspaceService workspaceService,
     IInternalPowerShellExecutionService executionService,
     ILanguageServerFacade languageServer)
 {
     _psesHost         = psesHost;
     _workspaceService = workspaceService;
     _executionService = executionService;
     _languageServer   = languageServer;
 }
 public GetVersionHandler(
     ILoggerFactory factory,
     IRunspaceContext runspaceContext,
     IInternalPowerShellExecutionService executionService,
     ILanguageServerFacade languageServer,
     ConfigurationService configurationService)
 {
     _logger               = factory.CreateLogger <GetVersionHandler>();
     _runspaceContext      = runspaceContext;
     _executionService     = executionService;
     _languageServer       = languageServer;
     _configurationService = configurationService;
 }
Exemplo n.º 8
0
        internal static async Task <SymbolDetails> CreateAsync(
            SymbolReference symbolReference,
            IRunspaceInfo currentRunspace,
            IInternalPowerShellExecutionService executionService)
        {
            SymbolDetails symbolDetails = new()
            {
                SymbolReference = symbolReference
            };

            switch (symbolReference.SymbolType)
            {
            case SymbolType.Function:
                CommandInfo commandInfo = await CommandHelpers.GetCommandInfoAsync(
                    symbolReference.SymbolName,
                    currentRunspace,
                    executionService).ConfigureAwait(false);

                if (commandInfo != null)
                {
                    symbolDetails.Documentation =
                        await CommandHelpers.GetCommandSynopsisAsync(
                            commandInfo,
                            executionService).ConfigureAwait(false);

                    if (commandInfo.CommandType == CommandTypes.Application)
                    {
                        symbolDetails.DisplayString = "(application) " + symbolReference.SymbolName;
                        return(symbolDetails);
                    }
                }

                symbolDetails.DisplayString = "function " + symbolReference.SymbolName;
                return(symbolDetails);

            case SymbolType.Parameter:
                // TODO: Get parameter help
                symbolDetails.DisplayString = "(parameter) " + symbolReference.SymbolName;
                return(symbolDetails);

            case SymbolType.Variable:
                symbolDetails.DisplayString = symbolReference.SymbolName;
                return(symbolDetails);

            default:
                return(symbolDetails);
            }
        }

        #endregion
    }
 public DebugEventHandlerService(
     ILoggerFactory factory,
     IInternalPowerShellExecutionService executionService,
     DebugService debugService,
     DebugStateService debugStateService,
     IDebugAdapterServerFacade debugAdapterServer,
     IPowerShellDebugContext debugContext)
 {
     _logger             = factory.CreateLogger <DebugEventHandlerService>();
     _executionService   = executionService;
     _debugService       = debugService;
     _debugStateService  = debugStateService;
     _debugAdapterServer = debugAdapterServer;
     _debugContext       = debugContext;
 }
Exemplo n.º 10
0
 public DisconnectHandler(
     ILoggerFactory factory,
     PsesDebugServer psesDebugServer,
     IRunspaceContext runspaceContext,
     IInternalPowerShellExecutionService executionService,
     DebugService debugService,
     DebugStateService debugStateService,
     DebugEventHandlerService debugEventHandlerService)
 {
     _logger                   = factory.CreateLogger <DisconnectHandler>();
     _psesDebugServer          = psesDebugServer;
     _runspaceContext          = runspaceContext;
     _executionService         = executionService;
     _debugService             = debugService;
     _debugStateService        = debugStateService;
     _debugEventHandlerService = debugEventHandlerService;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Gets completions for the symbol found in the Ast at
        /// the given file offset.
        /// </summary>
        /// <param name="scriptAst">
        /// The Ast which will be traversed to find a completable symbol.
        /// </param>
        /// <param name="currentTokens">
        /// The array of tokens corresponding to the scriptAst parameter.
        /// </param>
        /// <param name="fileOffset">
        /// The 1-based file offset at which a symbol will be located.
        /// </param>
        /// <param name="executionService">
        /// The PowerShellContext to use for gathering completions.
        /// </param>
        /// <param name="logger">An ILogger implementation used for writing log messages.</param>
        /// <param name="cancellationToken">
        /// A CancellationToken to cancel completion requests.
        /// </param>
        /// <returns>
        /// A CommandCompletion instance that contains completions for the
        /// symbol at the given offset.
        /// </returns>
        public static async Task <CommandCompletion> GetCompletionsAsync(
            Ast scriptAst,
            Token[] currentTokens,
            int fileOffset,
            IInternalPowerShellExecutionService executionService,
            ILogger logger,
            CancellationToken cancellationToken)
        {
            IScriptPosition cursorPosition = s_clonePositionWithNewOffset(scriptAst.Extent.StartScriptPosition, fileOffset);

            logger.LogTrace(
                string.Format(
                    "Getting completions at offset {0} (line: {1}, column: {2})",
                    fileOffset,
                    cursorPosition.LineNumber,
                    cursorPosition.ColumnNumber));

            Stopwatch stopwatch = new();

            CommandCompletion commandCompletion = null;
            await executionService.ExecuteDelegateAsync(
                representation : "CompleteInput",
                new ExecutionOptions { Priority = ExecutionPriority.Next },
                (pwsh, _) =>
            {
                stopwatch.Start();
                commandCompletion = CommandCompletion.CompleteInput(
                    scriptAst,
                    currentTokens,
                    cursorPosition,
                    options: null,
                    powershell: pwsh);
            },
                cancellationToken)
            .ConfigureAwait(false);

            stopwatch.Stop();
            logger.LogTrace($"IntelliSense completed in {stopwatch.ElapsedMilliseconds}ms.");

            return(commandCompletion);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Constructs an instance of the SymbolsService class and uses
        /// the given Runspace to execute language service operations.
        /// </summary>
        /// <param name="factory">An ILoggerFactory implementation used for writing log messages.</param>
        /// <param name="runspaceContext"></param>
        /// <param name="executionService"></param>
        /// <param name="workspaceService"></param>
        /// <param name="configurationService"></param>
        public SymbolsService(
            ILoggerFactory factory,
            IRunspaceContext runspaceContext,
            IInternalPowerShellExecutionService executionService,
            WorkspaceService workspaceService,
            ConfigurationService configurationService)
        {
            _logger           = factory.CreateLogger <SymbolsService>();
            _runspaceContext  = runspaceContext;
            _executionService = executionService;
            _workspaceService = workspaceService;

            _codeLensProviders = new ConcurrentDictionary <string, ICodeLensProvider>();
            ICodeLensProvider[] codeLensProviders = new ICodeLensProvider[]
            {
                new ReferencesCodeLensProvider(_workspaceService, this),
                new PesterCodeLensProvider(configurationService)
            };

            foreach (ICodeLensProvider codeLensProvider in codeLensProviders)
            {
                _codeLensProviders.TryAdd(codeLensProvider.ProviderId, codeLensProvider);
            }

            _documentSymbolProviders = new ConcurrentDictionary <string, IDocumentSymbolProvider>();
            IDocumentSymbolProvider[] documentSymbolProviders = new IDocumentSymbolProvider[]
            {
                new ScriptDocumentSymbolProvider(),
                new PsdDocumentSymbolProvider(),
                new PesterDocumentSymbolProvider(),
            };
            foreach (IDocumentSymbolProvider documentSymbolProvider in documentSymbolProviders)
            {
                _documentSymbolProviders.TryAdd(documentSymbolProvider.ProviderId, documentSymbolProvider);
            }
        }
 public ShowHelpHandler(IInternalPowerShellExecutionService executionService) => _executionService = executionService;
 public EvaluateHandler(IInternalPowerShellExecutionService executionService) => _executionService = executionService;
 public GetCommandHandler(IInternalPowerShellExecutionService executionService) => _executionService = executionService;
 public PSHostProcessAndRunspaceHandlers(ILoggerFactory factory, IInternalPowerShellExecutionService executionService)
 {
     _logger           = factory.CreateLogger <PSHostProcessAndRunspaceHandlers>();
     _executionService = executionService;
 }
 public ExpandAliasHandler(IInternalPowerShellExecutionService executionService) => _executionService = executionService;
 /// <summary>
 /// Creates a new instance of the TemplateService class.
 /// </summary>
 /// <param name="executionService">The PowerShellContext to use for this service.</param>
 /// <param name="factory">An ILoggerFactory implementation used for writing log messages.</param>
 public TemplateService(IInternalPowerShellExecutionService executionService, ILoggerFactory factory)
 {
     _logger           = factory.CreateLogger <TemplateService>();
     _executionService = executionService;
 }