/// <summary> /// Executes the query. /// </summary> public override DocumentResults? ExecuteQuery(String input, String text) { try { var textDocument = new TextDocument(text); var root = csvCompiler.Parse(textDocument.Text); var response = input + " | convert-to-string"; var controlFlowDescriptor = bootstrapper.Compiler.Parse(response); var controlFlow = bootstrapper.ControlFlowFactory.Create(controlFlowDescriptor); var result = controlFlow.Execute(new[] { root }) as String; var documentResults = new DocumentResults() { Source = root.TextDocument.Text, Results = result }; return documentResults; } catch (Exception exception) { Console.WriteLine("Error message: {0}", exception.Message); Console.WriteLine("Stacktrace: "); Console.WriteLine(exception.StackTrace); return null; } }
public override DocumentResults? ExecuteQuery(String input, String text) { try { context = new CompilationContext(workspace, document.WithText(SourceText.From(text))); var csharpBootStrapper = BootstrapperBuilder.Create(bootstrapper) .WithExecutor(new StandardExecutorWithContext(bootstrapper.RunnableManager, context)) .Build(); // var root = this.compiler.Parse(text); var response = input; // + " | convert-to-string"; var controlFlowDescriptor = csharpBootStrapper.Compiler.Parse(response); var controlFlow = csharpBootStrapper.ControlFlowFactory.Create(controlFlowDescriptor); var result = controlFlow.Execute(new[] { context.CurrentDocument.GetSyntaxRootAsync().Result }) as IEnumerable<Object>; var source = context.DocumentEditor.GetChangedDocument().GetSyntaxRootAsync().Result; var documentResults = new DocumentResults() { Source = source.ToFullString(), Results = String.Join(Environment.NewLine, result.OfType<SyntaxNode>().Select(node => node.ToFullString())) }; return documentResults; } catch (Exception exception) { Console.WriteLine($"Error message: {exception.Message}"); Console.WriteLine("Stacktrace: "); Console.WriteLine(exception.StackTrace); return null; } }
/// <summary> /// Executes the query. /// </summary> public override DocumentResults?ExecuteQuery(String input, String text) { try { var textDocument = new TextDocument(text); // root = CsvCompiler.Parse(content); var response = input + " | convert-to-string"; var controlFlowDescriptor = bootstrapper.Compiler.Parse(response); var controlFlow = bootstrapper.ControlFlowFactory.Create(controlFlowDescriptor); var result = controlFlow.Execute(new[] { textDocument.TextRange }) as String; // content = root.TextRange.GetText(); var documentResults = new DocumentResults() { Source = textDocument.Text, Results = result }; return(documentResults); } catch (Exception exception) { Console.WriteLine("Error message: {0}", exception.Message); Console.WriteLine("Stacktrace: "); Console.WriteLine(exception.StackTrace); return(null); } }
public override DocumentResults?ExecuteQuery(String input, String text) { try { context = new CompilationContext(workspace, document.WithText(SourceText.From(text))); var csharpBootStrapper = BootstrapperBuilder.Create(bootstrapper) .WithExecutor(new StandardExecutorWithContext(bootstrapper.RunnableManager, context)) .Build(); // var root = this.compiler.Parse(text); var response = input; // + " | convert-to-string"; var controlFlowDescriptor = csharpBootStrapper.Compiler.Parse(response); var controlFlow = csharpBootStrapper.ControlFlowFactory.Create(controlFlowDescriptor); var result = controlFlow.Execute(new[] { context.CurrentDocument.GetSyntaxRootAsync().Result }) as IEnumerable <Object>; var source = context.DocumentEditor.GetChangedDocument().GetSyntaxRootAsync().Result; var documentResults = new DocumentResults() { Source = source.ToFullString(), Results = String.Join(Environment.NewLine, result.OfType <SyntaxNode>().Select(node => node.ToFullString())) }; return(documentResults); } catch (Exception exception) { Console.WriteLine($"Error message: {exception.Message}"); Console.WriteLine("Stacktrace: "); Console.WriteLine(exception.StackTrace); return(null); } }