protected override void Display(RecordBase record) { Debug.Assert(record != null); var stringsColored = QueryExecutionResultDisplayer.FormatCellsContentFromRecord(record); QueryExecutionResultDisplayer.DisplayRow(m_ColumnsWidth, stringsColored); QueryExecutionResultDisplayer.WriteSeparatorLine(m_ColumnsWidth); }
public void Run() { var analysisResult = ProjectAnalysisUtils.ChooseAnalysisResult(); var codeBase = analysisResult.CodeBase; Func <string, IQueryCompiled> compileQueryProc = queryString => queryString.Compile(codeBase); // ... but if we can get a compareContext, then compile and execute the query against the compareContext ICompareContext compareContext; if (ProjectAnalysisUtils.TryGetCompareContextDefinedByBaseline(analysisResult, out compareContext)) { Debug.Assert(compareContext != null); compileQueryProc = queryString => queryString.Compile(compareContext); } // // Fill queriesPreviouslyEdited with current project queries // IPreviousNextStack <string> queriesPreviouslyEdited = new PreviousNextStack <string>( analysisResult.AnalysisResultRef.Project.CodeQueries.CodeQueriesSet.AllQueriesRecursive.Reverse().Select(q => q.QueryString), "", (s1, s2) => s1 == s2); // With this line, make sure to begin with the first queries of the project. queriesPreviouslyEdited.GetPrevious(); // // Loop for each query edition // while (true) { IQueryCompiled queryCompiled; using (var queryEditSession = new QueryEditSession(queriesPreviouslyEdited)) { var queryString = queryEditSession.GetQueryString(); COMPILE_QUERY: Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.White; if (queryString == null) { break; } // Try compile query queryCompiled = compileQueryProc(queryString); var queryCompiledError = queryCompiled.QueryCompiledError; if (queryCompiledError != null) { queryString = queryEditSession.ShowCompilatioErrorsAndThenGetQueryString(queryCompiledError); goto COMPILE_QUERY; } } // Execute query compiled var queryCompiledSuccess = queryCompiled.QueryCompiledSuccess; Debug.Assert(queryCompiledSuccess != null); var result = queryCompiledSuccess.Execute(); if (result.Status != QueryExecutionStatus.Success) { var exception = result.Exception; // The error must be an Exception thrown by the query, since we don't use the Execute(...) overload with time-out! Debug.Assert(exception != null); DisplayQueryThrowAnException(exception); continue; } QueryExecutionResultDisplayer.Go(result.SuccessResult); Console.WriteLine(); } }