private static async Task RunAsync(AnalysisEngine engine, Options options, CancellationToken cancellationToken) { var regionInfos = await engine.GetConditionalRegionInfo(cancellationToken); PrintConditionalRegionInfo(options, regionInfos); if (options.PrintSymbolInfo) { Console.WriteLine(); PrintSymbolInfo(engine); } }
private static async Task OnDocumentAnalyzed(AnalysisEngine engine, Options options, DocumentConditionalRegionInfo info, CancellationToken cancellationToken) { if (options.Edit) { var fileInfo = new FileInfo(info.Document.FilePath); if (fileInfo.IsReadOnly || !fileInfo.Exists) { Console.WriteLine("warning: skipping document '{0}' because it {1}.", info.Document.FilePath, fileInfo.IsReadOnly ? "is read-only" : "does not exist"); return; } var document = await engine.RemoveUnnecessaryRegions(info, cancellationToken); document = await engine.SimplifyVaryingPreprocessorExpressions(document, cancellationToken); var text = await document.GetTextAsync(cancellationToken); using (var file = File.Open(document.FilePath, FileMode.Truncate, FileAccess.Write)) { var writer = new StreamWriter(file, text.Encoding); text.Write(writer, cancellationToken); await writer.FlushAsync(); } } }
private static void PrintSymbolInfo(AnalysisEngine engine) { Console.WriteLine("Symbols"); Console.WriteLine(" {0,5} unique symbol(s) specified: {1}", engine.SpecifiedSymbols.Count(), string.Join(";", engine.SpecifiedSymbols)); Console.WriteLine(" {0,5} unique symbol(s) visited: {1}", engine.VisitedSymbols.Count(), string.Join(";", engine.VisitedSymbols)); Console.WriteLine(" {0,5} specified symbol(s) unvisited: {1}", engine.UnvisitedSymbols.Count(), string.Join(";", engine.UnvisitedSymbols)); }