private async Task AddQuickFixes(ICollection <QuickFix> quickFixes, IEnumerable <ISymbol> symbols) { foreach (var symbol in symbols) { foreach (var location in symbol.Locations) { await QuickFixHelper.AddQuickFix(quickFixes, _workspace, location); } } }
public async Task <QuickFixResponse> Handle(FindUsagesRequest request) { var document = _workspace.GetDocument(request.FileName); var response = new QuickFixResponse(); if (document != null) { var locations = new List <Location>(); var semanticModel = await document.GetSemanticModelAsync(); var sourceText = await document.GetTextAsync(); var position = sourceText.Lines.GetPosition(new LinePosition(request.Line, request.Column)); var symbol = await SymbolFinder.FindSymbolAtPositionAsync(semanticModel, position, _workspace); var definition = await SymbolFinder.FindSourceDefinitionAsync(symbol, _workspace.CurrentSolution); var usages = request.OnlyThisFile ? await SymbolFinder.FindReferencesAsync(definition ?? symbol, _workspace.CurrentSolution, ImmutableHashSet.Create(document)) : await SymbolFinder.FindReferencesAsync(definition ?? symbol, _workspace.CurrentSolution); foreach (var usage in usages.Where(u => u.Definition.CanBeReferencedByName || (symbol as IMethodSymbol)?.MethodKind == MethodKind.Constructor)) { foreach (var location in usage.Locations) { locations.Add(location.Location); } if (!request.ExcludeDefinition) { var definitionLocations = usage.Definition.Locations .Where(loc => loc.IsInSource && (!request.OnlyThisFile || loc.SourceTree.FilePath == request.FileName)); foreach (var location in definitionLocations) { locations.Add(location); } } } var quickFixTasks = locations.Distinct().Select(async l => await QuickFixHelper.GetQuickFix(_workspace, l)); var quickFixes = await Task.WhenAll(quickFixTasks); response = new QuickFixResponse(quickFixes.Distinct() .OrderBy(q => q.FileName) .ThenBy(q => q.Line) .ThenBy(q => q.Column)); } return(response); }
public async Task <QuickFixResponse> Handle(GotoRegionRequest request) { var regions = new List <QuickFix>(); var document = _workspace.GetDocument(request.FileName); if (document != null) { var root = await document.GetSyntaxRootAsync(); var regionTrivias = root.DescendantNodesAndTokens() .Where(node => node.HasLeadingTrivia) .SelectMany(node => node.GetLeadingTrivia()) .Where(x => (x.RawKind == (int)SyntaxKind.RegionDirectiveTrivia || x.RawKind == (int)SyntaxKind.EndRegionDirectiveTrivia)); foreach (var regionTrivia in regionTrivias.Distinct()) { regions.Add(await QuickFixHelper.GetQuickFix(_workspace, regionTrivia.GetLocation())); } } return(new QuickFixResponse(regions)); }
private async void CollectAndUploadLog() { var pd = await this.ShowProgressAsync("Uploading log", $"Please wait while the application log is uploaded to the ME3Tweaks Log Viewing Service."); pd.SetIndeterminate(); NamedBackgroundWorker nbw = new NamedBackgroundWorker("DiagnosticsWorker"); nbw.DoWork += (a, b) => { //ProgressIndeterminate = true; //GameTarget target = GameChosen != null ? Locations.GetTarget(GameChosen.Value) : null; StringBuilder logUploadText = new StringBuilder(); string logText = ""; //if (target != null) //{ // logUploadText.Append("[MODE]diagnostics\n"); //do not localize // logUploadText.Append(LogCollector.PerformDiagnostic(target, FullDiagChosen, // x => DiagnosticStatusText = x, // x => // { // ProgressIndeterminate = false; // ProgressValue = x; // }, // () => ProgressIndeterminate = true)); // logUploadText.Append("\n"); //do not localize //} if (SelectedLogForUpload != null) { logUploadText.Append("[MODE]logs\n"); //do not localize logUploadText.AppendLine(LogCollector.CollectLogs(SelectedLogForUpload.filepath)); logUploadText.Append("\n"); //do not localize } //DiagnosticStatusText = "Uploading to log viewing service"; //ProgressIndeterminate = true; var response = LogUploader.UploadLog(logUploadText.ToString(), "https://me3tweaks.com/masseffect2randomizer/logservice/logupload"); if (response.uploaded) { var DiagnosticResultText = response.result; if (response.result.StartsWith("http")) { Utilities.OpenWebPage(response.result); } } if (!response.uploaded || QuickFixHelper.IsQuickFixEnabled(QuickFixHelper.QuickFixName.ForceSavingLogLocally)) { // Upload failed. var GeneratedLogPath = Path.Combine(LogCollector.LogDir, $"FailedLogUpload_{DateTime.Now.ToString("s").Replace(":", ".")}.txt"); File.WriteAllText(GeneratedLogPath, logUploadText.ToString()); } //DiagnosticComplete = true; //DiagnosticInProgress = false; }; nbw.RunWorkerCompleted += async(sender, args) => { CommandManager.InvalidateRequerySuggested(); LogUploaderFlyoutOpen = false; await pd.CloseAsync(); }; //DiagnosticInProgress = true; nbw.RunWorkerAsync(); }