public Task <Container <SymbolInformation> > Handle(WorkspaceSymbolParams request, CancellationToken cancellationToken) { var symbols = new List <SymbolInformation>(); foreach (ScriptFile scriptFile in _workspaceService.GetOpenedFiles()) { List <SymbolReference> foundSymbols = _symbolsService.FindSymbolsInFile( scriptFile); // TODO: Need to compute a relative path that is based on common path for all workspace files string containerName = Path.GetFileNameWithoutExtension(scriptFile.FilePath); foreach (SymbolReference foundOccurrence in foundSymbols) { if (!IsQueryMatch(request.Query, foundOccurrence.SymbolName)) { continue; } var location = new Location { Uri = PathUtils.ToUri(foundOccurrence.FilePath), Range = GetRangeFromScriptRegion(foundOccurrence.ScriptRegion) }; symbols.Add(new SymbolInformation { ContainerName = containerName, Kind = foundOccurrence.SymbolType == SymbolType.Variable ? SymbolKind.Variable : SymbolKind.Function, Location = location, Name = GetDecoratedSymbolName(foundOccurrence) }); } } _logger.LogWarning("Logging in a handler works now."); return(Task.FromResult(new Container <SymbolInformation>(symbols))); }
public async Task <Unit> Handle(DidChangeConfigurationParams request, CancellationToken cancellationToken) { LanguageServerSettingsWrapper incomingSettings = request.Settings.ToObject <LanguageServerSettingsWrapper>(); if (incomingSettings == null) { return(await Unit.Task.ConfigureAwait(false)); } bool oldLoadProfiles = _configurationService.CurrentSettings.EnableProfileLoading; bool oldScriptAnalysisEnabled = _configurationService.CurrentSettings.ScriptAnalysis.Enable ?? false; string oldScriptAnalysisSettingsPath = _configurationService.CurrentSettings.ScriptAnalysis?.SettingsPath; _configurationService.CurrentSettings.Update( incomingSettings.Powershell, _workspaceService.WorkspacePath, _logger); if (!this._profilesLoaded && _configurationService.CurrentSettings.EnableProfileLoading && oldLoadProfiles != _configurationService.CurrentSettings.EnableProfileLoading) { await _powerShellContextService.LoadHostProfilesAsync().ConfigureAwait(false); this._profilesLoaded = true; } // Wait until after profiles are loaded (or not, if that's the // case) before starting the interactive console. if (!this._consoleReplStarted) { // Start the interactive terminal _powerShellContextService.ConsoleReader.StartCommandLoop(); this._consoleReplStarted = true; } // If there is a new settings file path, restart the analyzer with the new settings. bool settingsPathChanged = false; string newSettingsPath = _configurationService.CurrentSettings.ScriptAnalysis.SettingsPath; if (!string.Equals(oldScriptAnalysisSettingsPath, newSettingsPath, StringComparison.OrdinalIgnoreCase)) { if (_analysisService != null) { _analysisService.SettingsPath = newSettingsPath; settingsPathChanged = true; } } // If script analysis settings have changed we need to clear & possibly update the current diagnostic records. if ((oldScriptAnalysisEnabled != _configurationService.CurrentSettings.ScriptAnalysis?.Enable) || settingsPathChanged) { // If the user just turned off script analysis or changed the settings path, send a diagnostics // event to clear the analysis markers that they already have. if (!_configurationService.CurrentSettings.ScriptAnalysis.Enable.Value || settingsPathChanged) { foreach (var scriptFile in _workspaceService.GetOpenedFiles()) { _analysisService.ClearMarkers(scriptFile); } } } // Convert the editor file glob patterns into an array for the Workspace // Both the files.exclude and search.exclude hash tables look like (glob-text, is-enabled): // "files.exclude" : { // "Makefile": true, // "*.html": true, // "build/*": true // } var excludeFilePatterns = new List <string>(); if (incomingSettings.Files?.Exclude != null) { foreach (KeyValuePair <string, bool> patternEntry in incomingSettings.Files.Exclude) { if (patternEntry.Value) { excludeFilePatterns.Add(patternEntry.Key); } } } if (incomingSettings.Search?.Exclude != null) { foreach (KeyValuePair <string, bool> patternEntry in incomingSettings.Files.Exclude) { if (patternEntry.Value && !excludeFilePatterns.Contains(patternEntry.Key)) { excludeFilePatterns.Add(patternEntry.Key); } } } _workspaceService.ExcludeFilesGlob = excludeFilePatterns; // Convert the editor file search options to Workspace properties if (incomingSettings.Search?.FollowSymlinks != null) { _workspaceService.FollowSymlinks = incomingSettings.Search.FollowSymlinks; } return(await Unit.Task.ConfigureAwait(false)); }