Exemplo n.º 1
0
        private static void ApplyTestResultsToFeatures(IContainer container, IConfiguration configuration, GeneralTree <INode> features)
        {
            var testResults = container.Resolve <ITestResults>();

            var actionVisitor = new ActionVisitor <INode>(node =>
            {
                var featureTreeNode = node as FeatureNode;
                if (featureTreeNode == null)
                {
                    return;
                }

                if (configuration.HasTestResults)
                {
                    SetResultsAtFeatureLevel(featureTreeNode, testResults);
                    SetResultsForIndividualScenariosUnderFeature(featureTreeNode, testResults);
                }
                else
                {
                    featureTreeNode.Feature.Result = TestResult.Inconclusive;
                }
            });

            features.AcceptVisitor(actionVisitor);
        }
Exemplo n.º 2
0
        public IQsiTreeNode Parse(QsiScript script, CancellationToken cancellationToken = default)
        {
            var parser = MySQLUtility.CreateParser(script.Script, _version);
            var query  = parser.query();

            if (query.children[0] is not SimpleStatementContext simpleStatement)
            {
                return(null);
            }

            switch (simpleStatement.children[0])
            {
            case SelectStatementContext selectStatement:
                return(TableVisitor.VisitSelectStatement(selectStatement));

            case CreateStatementContext createStatement when
                createStatement.children[1] is CreateViewContext createView:
                return(TableVisitor.VisitCreateView(createView));

            case DeleteStatementContext deleteStatement:
                return(ActionVisitor.VisitDeleteStatement(deleteStatement));

            case ReplaceStatementContext replaceStatement:
                return(ActionVisitor.VisitReplaceStatement(replaceStatement));

            case UpdateStatementContext updateStatement:
                return(ActionVisitor.VisitUpdateStatement(updateStatement));

            case InsertStatementContext insertStatement:
                return(ActionVisitor.VisitInsertStatement(insertStatement));

            default:
                throw TreeHelper.NotSupportedTree(simpleStatement.children[0]);
            }
        }
Exemplo n.º 3
0
        private IQsiTreeNode ParseInternal(QsiScript script, Parser parser)
        {
            var primarSqlParser = (global::PrimarSql.Internal.PrimarSqlParser)parser;
            var rootContext     = primarSqlParser.root();

            if (rootContext.children[0] is not SqlStatementContext sqlStatement)
            {
                return(null);
            }

            if (sqlStatement.children[0] is not DmlStatementContext dmlStatement)
            {
                return(null);
            }

            switch (dmlStatement.children[0])
            {
            case SelectStatementContext selectStatement:
                return(TableVisitor.VisitSelectStatement(selectStatement));

            case InsertStatementContext insertStatement:
                return(ActionVisitor.VisitInsertStatement(insertStatement));

            case DeleteStatementContext deleteStatement:
                return(ActionVisitor.VisitDeleteStatement(deleteStatement));

            case UpdateStatementContext updateStatement:
                return(ActionVisitor.VisitUpdateStatement(updateStatement));

            default:
                return(null);
            }
        }
Exemplo n.º 4
0
        private IQsiTreeNode ParseDataManipulationStatement(DataManipulationStatementContext statement)
        {
            switch (statement.children[0])
            {
            case SelectStatementContext selectStatement:
                return(TableVisitor.VisitSelectStatement(selectStatement));

            case SelectIntoStatementContext selectIntoStatement:
                return(ActionVisitor.VisitSelectIntoStatement(selectIntoStatement));

            case DeleteStatementContext deleteStatement:
                return(ActionVisitor.VisitDeleteStatement(deleteStatement));

            case InsertStatementContext insertStatement:
                return(ActionVisitor.VisitInsertStatement(insertStatement));

            case ReplaceStatementContext replaceStatement:
                return(ActionVisitor.VisitReplaceStatement(replaceStatement));

            case UpdateStatementContext updateStatement:
                return(ActionVisitor.VisitUpdateStatement(updateStatement));

            case MergeDeltaParameterContext mergeDeltaParameter:
                throw new NotImplementedException();

            case MergeIntoStatementContext mergeIntoStatement:
                throw new NotImplementedException();

            default:
                throw TreeHelper.NotSupportedTree(statement.children[0]);
            }
        }
Exemplo n.º 5
0
        void ProcessType(TypeDefinition type)
        {
            ActionVisitor.Visit(Options, type, a => ProcessTypeActions(type, a));

            if (false && type.HasNestedTypes)
            {
                foreach (var nested in type.NestedTypes)
                {
                    ProcessType(nested);
                }
            }

            foreach (var method in type.Methods)
            {
                ProcessMethod(method);
            }

            if (Options.Preprocessor == OptimizerOptions.PreprocessorMode.Full)
            {
                foreach (var property in type.Properties)
                {
                    ProcessProperty(property);
                }
            }
        }
Exemplo n.º 6
0
        public IQsiTreeNode Parse(QsiScript script, CancellationToken cancellationToken = default)
        {
            var stream = new AntlrInputStream(script.Script);
            var lexer  = new CqlLexerInternal(stream);
            var tokens = new CommonTokenStream(lexer);
            var parser = new CqlParserInternal(tokens);

            parser.AddErrorListener(new ErrorListener());

            var statement = parser.cqlStatement().children[0];

            switch (statement)
            {
            case SelectStatementContext selectStatement:
                return(TableVisitor.VisitSelectStatement(selectStatement));

            case CreateMaterializedViewStatementContext createMaterializedViewStatement:
                return(DefinitionVisitor.VisitCreateMaterializedViewStatement(createMaterializedViewStatement));

            case UseStatementContext useStatement:
                return(ActionVisitor.VisitUseStatement(useStatement));

            case InsertStatementContext insertStatement:
                return(ActionVisitor.VisitInsertStatement(insertStatement));

            case UpdateStatementContext updateStatement:
                return(ActionVisitor.VisitUpdateStatement(updateStatement));

            case DeleteStatementContext deleteStatement:
                return(ActionVisitor.VisitDeleteStatement(deleteStatement));

            default:
                throw TreeHelper.NotSupportedTree(statement);
            }
        }
Exemplo n.º 7
0
        public void Build(GeneralTree <INode> features)
        {
            if (log.IsInfoEnabled)
            {
                log.Info("Writing HTML to {0}", this.configuration.OutputFolder.FullName);
            }

            this.htmlResourceWriter.WriteTo(this.configuration.OutputFolder.FullName);


            var actionVisitor = new ActionVisitor <INode>(node =>
            {
                if (node.IsIndexMarkDownNode())
                {
                    return;
                }

                string nodePath =
                    this.fileSystem.Path.Combine(
                        this.configuration.OutputFolder.
                        FullName,
                        node.RelativePathFromRoot);
                string htmlFilePath;

                if (node.IsContent)
                {
                    htmlFilePath =
                        nodePath.Replace(
                            this.fileSystem.Path.GetExtension(nodePath),
                            ".html");
                }
                else
                {
                    this.fileSystem.Directory.CreateDirectory(nodePath);

                    htmlFilePath = this.fileSystem.Path.Combine(nodePath,
                                                                "index.html");
                }

                using (
                    var writer =
                        new System.IO.StreamWriter(htmlFilePath,
                                                   false,
                                                   Encoding.UTF8))
                {
                    XDocument document =
                        this.htmlDocumentFormatter.Format(
                            node, features,
                            this.configuration.FeatureFolder);
                    document.Save(writer);
                    writer.Close();
                }
            });

            if (features != null)
            {
                features.AcceptVisitor(actionVisitor);
            }
        }
Exemplo n.º 8
0
 public SqlServerParser(TransactSqlVersion transactSqlVersion)
 {
     _parser            = new TSqlParserInternal(transactSqlVersion, false);
     _tableVisitor      = CreateTableVisitor();
     _expressionVisitor = CreateExpressionVisitor();
     _identifierVisitor = CreateIdentifierVisitor();
     _actionVisitor     = CreateActionVisitor();
 }
Exemplo n.º 9
0
        private static void VisitActions(Thing thing, IEnumerable <IInterceptorFactory> factories)
        {
            var intercepts = factories
                             .Select(x => x.CreatActionIntercept())
                             .ToArray();

            ActionVisitor.Visit(intercepts, thing);
        }
Exemplo n.º 10
0
        public void Build(GeneralTree <IDirectoryTreeNode> features)
        {
            string filename = string.IsNullOrEmpty(configuration.SystemUnderTestName)
                                  ? "features.docx"
                                  : configuration.SystemUnderTestName + ".docx";
            string documentFileName = Path.Combine(configuration.OutputFolder.FullName, filename);

            if (File.Exists(documentFileName))
            {
                File.Delete(documentFileName);
            }

            using (
                WordprocessingDocument wordProcessingDocument = WordprocessingDocument.Create(documentFileName,
                                                                                              WordprocessingDocumentType
                                                                                              .Document))
            {
                MainDocumentPart mainDocumentPart = wordProcessingDocument.AddMainDocumentPart();
                wordStyleApplicator.AddStylesPartToPackage(wordProcessingDocument);
                wordStyleApplicator.AddStylesWithEffectsPartToPackage(wordProcessingDocument);
                wordFontApplicator.AddFontTablePartToPackage(wordProcessingDocument);
                var documentSettingsPart = mainDocumentPart.AddNewPart <DocumentSettingsPart>();
                documentSettingsPart.Settings = new Settings();
                wordHeaderFooterFormatter.ApplyHeaderAndFooter(wordProcessingDocument);

                var document = new Document();
                var body     = new Body();
                document.Append(body);

                var actionVisitor = new ActionVisitor <IDirectoryTreeNode>(node =>
                {
                    var featureDirectoryTreeNode =
                        node as FeatureDirectoryTreeNode;
                    if (featureDirectoryTreeNode != null)
                    {
                        wordFeatureFormatter.Format(body,
                                                    featureDirectoryTreeNode);
                    }
                });

                features.AcceptVisitor(actionVisitor);

                mainDocumentPart.Document = document;
                mainDocumentPart.Document.Save();
            }

            // HACK - Add the table of contents
            using (WordprocessingDocument wordProcessingDocument = WordprocessingDocument.Open(documentFileName, true))
            {
                XElement firstPara = wordProcessingDocument
                                     .MainDocumentPart
                                     .GetXDocument()
                                     .Descendants(W.p)
                                     .FirstOrDefault();

                TocAdder.AddToc(wordProcessingDocument, firstPara, @"TOC \o '1-2' \h \z \u", null, 4);
            }
        }
Exemplo n.º 11
0
        // Reads //
        public static StagedReadName RenderStagedReadPlan(Workspace Home, HScriptParser.Crudam_readContext context)
        {

            // Get the data source //
            DataSet data = VisitorHelper.GetData(Home, context.full_table_name());
            string alias =
                (context.K_AS() != null)
                ? context.IDENTIFIER().GetText()
                : data.Name;

            // Create a local heap to work off of //
            MemoryStruct local_heap = new MemoryStruct(true);

            // Create a record register //
            StreamRegister memory = new StreamRegister(null);

            // Create expression visitor //
            ExpressionVisitor exp_vis = new ExpressionVisitor(local_heap, Home, alias, data.Columns, memory);

            // Where clause //
            Predicate where = VisitorHelper.GetWhere(exp_vis, context.where_clause());

            // Create a reader //
            RecordReader reader = data.OpenReader(where);

            // Attach the reader to the register //
            memory.BaseStream = reader;

            // Create the action visitor //
            ActionVisitor act_vis = new ActionVisitor(Home, local_heap, exp_vis);

            // Get the declarations //
            if (context.crudam_declare_many() != null)
            {
                VisitorHelper.AllocateMemory(Home, local_heap, exp_vis, context.crudam_declare_many());
            }

            // Get the initial actionset //
            TNode pre_run =
                (context.init_action() != null)
                ? act_vis.ToNode(context.init_action().query_action())
                : new TNodeNothing(null);

            // Get the main actionset //
            TNode run = act_vis.ToNode(context.main_action().query_action());

            // Get the final actionset //
            TNode post_run =
                (context.final_action() != null)
                ? act_vis.ToNode(context.final_action().query_action())
                : new TNodeNothing(null);

            return new StagedReadName(reader, pre_run, run, post_run);

        }
Exemplo n.º 12
0
        private IQsiTreeNode ParseUtilityStatement(UtilityStatementContext context)
        {
            switch (context.children[0])
            {
            case UseCommandContext useCommand:
                return(ActionVisitor.VisitUseCommand(useCommand));

            default:
                throw TreeHelper.NotSupportedTree(context.children[0]);
            }
        }
Exemplo n.º 13
0
        private IQsiActionNode ParseSessionManagementStatement(SessionManagementStatementContext statement)
        {
            switch (statement.children[0])
            {
            case SetSchemaStatementContext setSchemaStatement:
                return(ActionVisitor.VisitSetSchemaStatement(setSchemaStatement));

            default:
                throw TreeHelper.NotSupportedTree(statement.children[0]);
            }
        }
        public void Build(GeneralTree<INode> features)
        {
            if (Log.IsInfoEnabled)
            {
                Log.Info("Writing HTML to {0}", this.configuration.OutputFolder.FullName);
            }

            this.htmlResourceWriter.WriteTo(this.configuration.OutputFolder.FullName);

            var actionVisitor = new ActionVisitor<INode>(node => this.VisitNodes(features, node));
            features?.AcceptVisitor(actionVisitor);
        }
Exemplo n.º 15
0
        public void Build(GeneralTree <INode> features)
        {
            if (Log.IsInfoEnabled)
            {
                Log.Info("Writing HTML to {0}", this.configuration.OutputFolder.FullName);
            }

            this.htmlResourceWriter.WriteTo(this.configuration.OutputFolder.FullName);

            var actionVisitor = new ActionVisitor <INode>(node => this.VisitNodes(features, node));

            features?.AcceptVisitor(actionVisitor);
        }
Exemplo n.º 16
0
        public IQsiTreeNode Parse(QsiScript script, CancellationToken cancellationToken = default)
        {
            _pgParser ??= new PgQuery10();

            var pgTree = (IPg10Node)_pgParser.Parse(script.Script) ?? throw new QsiException(QsiError.NotSupportedScript, script.ScriptType);

            switch (script.ScriptType)
            {
            case QsiScriptType.Set:
                return(ActionVisitor.Visit(pgTree));

            default:
                return(TableVisitor.Visit(pgTree));
            }
        }
        public void Build(NGenerics.DataStructures.Trees.GeneralTree<DirectoryCrawler.IDirectoryTreeNode> features)
        {
            this.ditaMapBuilder.Build(features);

            var actionVisitor = new ActionVisitor<IDirectoryTreeNode>(node =>
            {
                var featureDirectoryTreeNode = node as FeatureDirectoryTreeNode;
                if (featureDirectoryTreeNode != null)
                {
                    this.ditaFeatureFormatter.Format(featureDirectoryTreeNode);
                }
            });

            features.AcceptVisitor(actionVisitor);
        }
Exemplo n.º 18
0
        public void ActionShouldBeCalledOnEveryObject()
        {
            var list = new List <int> {
                1, 2, -3
            };


            var recorded = new List <int>();
            var visitor  = new ActionVisitor <int>(x => recorded.Add(x));

            list.AcceptVisitor(visitor);

            Assert.Contains(1, recorded);
            Assert.Contains(2, recorded);
            Assert.Contains(-3, recorded);
        }
        public void Build(NGenerics.DataStructures.Trees.GeneralTree<DirectoryCrawler.IDirectoryTreeNode> features)
        {
            string filename = string.IsNullOrEmpty(this.configuration.SystemUnderTestName) ? "features.docx" : this.configuration.SystemUnderTestName + ".docx";
            var documentFileName = Path.Combine(this.configuration.OutputFolder.FullName, filename);
            if (File.Exists(documentFileName)) File.Delete(documentFileName);

            using (var wordProcessingDocument = WordprocessingDocument.Create(documentFileName, DocumentFormat.OpenXml.WordprocessingDocumentType.Document))
            {
                var mainDocumentPart = wordProcessingDocument.AddMainDocumentPart();
                this.wordStyleApplicator.AddStylesPartToPackage(wordProcessingDocument);
                this.wordStyleApplicator.AddStylesWithEffectsPartToPackage(wordProcessingDocument);
                this.wordFontApplicator.AddFontTablePartToPackage(wordProcessingDocument);
                var documentSettingsPart = mainDocumentPart.AddNewPart<DocumentSettingsPart>();
                documentSettingsPart.Settings = new Settings();
                this.wordHeaderFooterFormatter.ApplyHeaderAndFooter(wordProcessingDocument);
                
                var document = new Document();
                var body = new Body();
                document.Append(body);

                var actionVisitor = new ActionVisitor<IDirectoryTreeNode>(node =>
                {
                    var featureDirectoryTreeNode = node as FeatureDirectoryTreeNode;
                    if (featureDirectoryTreeNode != null)
                    {
                        this.wordFeatureFormatter.Format(body, featureDirectoryTreeNode);
                    }
                });

                features.AcceptVisitor(actionVisitor);

                mainDocumentPart.Document = document;
                mainDocumentPart.Document.Save();
            }

            // HACK - Add the table of contents
            using (var wordProcessingDocument = WordprocessingDocument.Open(documentFileName, true))
            {
                XElement firstPara = wordProcessingDocument
                                    .MainDocumentPart
                                    .GetXDocument()
                                    .Descendants(W.p)
                                    .FirstOrDefault();

                TocAdder.AddToc(wordProcessingDocument, firstPara, @"TOC \o '1-2' \h \z \u", null, 4);
            }
        }
Exemplo n.º 20
0
        public void Build(GeneralTree<IDirectoryTreeNode> features)
        {
            ditaMapBuilder.Build(features);

            var actionVisitor = new ActionVisitor<IDirectoryTreeNode>(node =>
                                                                          {
                                                                              var featureDirectoryTreeNode =
                                                                                  node as FeatureDirectoryTreeNode;
                                                                              if (featureDirectoryTreeNode != null)
                                                                              {
                                                                                  ditaFeatureFormatter.Format(
                                                                                      featureDirectoryTreeNode);
                                                                              }
                                                                          });

            features.AcceptVisitor(actionVisitor);
        }
Exemplo n.º 21
0
        public void Build(GeneralTree <INode> features)
        {
            this.ditaMapBuilder.Build(features);

            var actionVisitor = new ActionVisitor <INode>(node =>
            {
                var featureDirectoryTreeNode =
                    node as FeatureNode;
                if (featureDirectoryTreeNode != null)
                {
                    this.ditaFeatureFormatter.Format(
                        featureDirectoryTreeNode);
                }
            });

            features.AcceptVisitor(actionVisitor);
        }
Exemplo n.º 22
0
        private static void ApplyTestResultsToFeatures(IContainer container, Configuration configuration, GeneralTree<INode> features)
        {
            var testResults = container.Resolve<ITestResults>();

            var actionVisitor = new ActionVisitor<INode>(node =>
                {
                    var featureTreeNode = node as FeatureNode;
                    if (featureTreeNode == null) return;
                    if (configuration.HasTestResults)
                    {
                        SetResultsAtFeatureLevel(featureTreeNode, testResults);
                        SetResultsForIndividualScenariosUnderFeature(featureTreeNode, testResults);
                    }
                    else
                    {
                        featureTreeNode.Feature.Result = TestResult.Inconclusive;
                    }
                });

            features.AcceptVisitor(actionVisitor);
        }
Exemplo n.º 23
0
        public void Build(GeneralTree<IDirectoryTreeNode> features)
        {   
            if (log.IsInfoEnabled)
            {
                log.InfoFormat("Writing HTML to {0}", this.configuration.OutputFolder.FullName);
            }

            this.htmlResourceWriter.WriteTo(this.configuration.OutputFolder.FullName);

            var actionVisitor = new ActionVisitor<IDirectoryTreeNode>(node =>
                {
                  if (node.IsIndexMarkDownNode())
                  {
                    return;
                  }

                    var nodePath = Path.Combine(this.configuration.OutputFolder.FullName, node.RelativePathFromRoot);
                  string htmlFilePath;

                    if (node.IsContent)
                    {
                        htmlFilePath = nodePath.Replace(Path.GetExtension(nodePath), ".html");
                    }
                    else
                    {
                        Directory.CreateDirectory(nodePath);

                        htmlFilePath = Path.Combine(nodePath, "index.html");
                    }

                    using (var writer = new StreamWriter(htmlFilePath, false, Encoding.UTF8))
                    {
                      var document = this.htmlDocumentFormatter.Format(node, features, this.configuration.FeatureFolder);
                      document.Save(writer);
                      writer.Close();
                    }
                });

            features.AcceptVisitor(actionVisitor);
        }
Exemplo n.º 24
0
        public IQsiTreeNode Parse(QsiScript script, CancellationToken cancellationToken = default)
        {
            var parser = ImpalaUtility.CreateParserInternal(
                script.Script,
                Dialect
                );

            var stmt = parser.root().stmt();

            switch (stmt.children[0])
            {
            case Query_stmtContext queryStmt:
                return(TableVisitor.VisitQueryStmt(queryStmt));

            case Create_view_stmtContext createViewStmt:
                return(ActionVisitor.VisitCreateViewStmt(createViewStmt));

            case Create_tbl_as_select_stmtContext createTblAsSelectStmt:
                return(ActionVisitor.VisitCreateTblAsSelectStmt(createTblAsSelectStmt));

            case Use_stmtContext useStmt:
                return(ActionVisitor.VisitUseStmt(useStmt));

            case Upsert_stmtContext upsertStmt:
                return(ActionVisitor.VisitUpsertStmt(upsertStmt));

            case Update_stmtContext updateStmt:
                return(ActionVisitor.VisitUpdateStmt(updateStmt));

            case Insert_stmtContext insertStmt:
                return(ActionVisitor.VisitInsertStmt(insertStmt));

            case Delete_stmtContext deleteStmt:
                return(ActionVisitor.VisitDeleteStmt(deleteStmt));

            default:
                throw TreeHelper.NotSupportedTree(stmt.children[0]);
            }
        }
        public void Build(GeneralTree <INode> features)
        {
            if (Log.IsInfoEnabled)
            {
                Log.Info("Writing Cucumber to {0}", this.configuration.OutputFolder.FullName);
            }

            List <Feature> featuresToFormat = new List <Feature>();

            ActionVisitor <INode> actionVisitor = new ActionVisitor <INode>(node =>
            {
                FeatureNode featureTreeNode = node as FeatureNode;
                if (featureTreeNode != null)
                {
                    featuresToFormat.Add(featureTreeNode.Feature);
                }
            });

            features.AcceptVisitor(actionVisitor);

            this.CreateFile(this.OutputFilePath, this.GenerateJson(featuresToFormat));
        }
Exemplo n.º 26
0
        private IQsiTreeNode ParseInternal(QsiScript script, Parser parser)
        {
            var primarSqlParser = (global::PrimarSql.Internal.PrimarSqlParser)parser;

            switch (script.ScriptType)
            {
            case QsiScriptType.Select:
                return(TableVisitor.VisitSelectStatement(primarSqlParser.selectStatement()));

            case QsiScriptType.Insert:
                return(ActionVisitor.VisitInsertStatement(primarSqlParser.insertStatement()));

            case QsiScriptType.Delete:
                return(ActionVisitor.VisitDeleteStatement(primarSqlParser.deleteStatement()));

            case QsiScriptType.Update:
                return(ActionVisitor.VisitUpdateStatement(primarSqlParser.updateStatement()));

            default:
                return(null);
            }
        }
Exemplo n.º 27
0
        public void ActionShouldBeCalledOnEveryObject()
        {
            var list = new List<int>
                           {
                               1, 2, -3
                           };

            var mockRepository = new MockRepository();

            // Just looking for an interface with a method that matches Action<T> - temporarily settled on list.
            var recorder = mockRepository.StrictMock<IList<int>>();
            recorder.Add(1);
            recorder.Add(2);
            recorder.Add(-3);

            mockRepository.ReplayAll();

            var visitor = new ActionVisitor<int>(recorder.Add);
            list.AcceptVisitor(visitor);

            mockRepository.VerifyAll();
        }
Exemplo n.º 28
0
        public void Build(GeneralTree <INode> features)
        {
            if (log.IsInfoEnabled)
            {
                log.Info("Writing JSON to {0}", this.configuration.OutputFolder.FullName);
            }

            var featuresToFormat = new List <FeatureWithMetaInfo>();

            var actionVisitor = new ActionVisitor <INode>(node =>
            {
                var featureTreeNode =
                    node as FeatureNode;
                if (featureTreeNode != null)
                {
                    if (this.configuration.HasTestResults)
                    {
                        featuresToFormat.Add(
                            new FeatureWithMetaInfo(
                                featureTreeNode,
                                this.testResults.
                                GetFeatureResult(
                                    featureTreeNode.
                                    Feature)));
                    }
                    else
                    {
                        featuresToFormat.Add(
                            new FeatureWithMetaInfo(
                                featureTreeNode));
                    }
                }
            });

            features.AcceptVisitor(actionVisitor);

            CreateFile(this.OutputFilePath, GenerateJSON(featuresToFormat));
        }
Exemplo n.º 29
0
        public void Build(GeneralTree <IDirectoryTreeNode> features)
        {
            if (log.IsInfoEnabled)
            {
                log.InfoFormat("Writing Excel workbook to {0}", configuration.OutputFolder.FullName);
            }

            string spreadsheetPath = Path.Combine(configuration.OutputFolder.FullName, "features.xlsx");

            using (var workbook = new XLWorkbook())
            {
                var actionVisitor = new ActionVisitor <IDirectoryTreeNode>(node =>
                {
                    var featureDirectoryTreeNode =
                        node as FeatureDirectoryTreeNode;
                    if (featureDirectoryTreeNode != null)
                    {
                        IXLWorksheet worksheet =
                            workbook.AddWorksheet(
                                excelSheetNameGenerator.
                                GenerateSheetName(
                                    workbook,
                                    featureDirectoryTreeNode
                                    .Feature));
                        excelFeatureFormatter.Format(
                            worksheet,
                            featureDirectoryTreeNode.
                            Feature);
                    }
                });

                features.AcceptVisitor(actionVisitor);

                excelTableOfContentsFormatter.Format(workbook, features);

                workbook.SaveAs(spreadsheetPath);
            }
        }
Exemplo n.º 30
0
        public IQsiTreeNode Parse(QsiScript script, CancellationToken cancellationToken = default)
        {
            var result = PhoenixSqlParserInternal.Parse(script.Script);

            switch (result)
            {
            case SelectStatement selectStatement:
                return(TableVisitor.VisitSelectStatement(selectStatement));

            case CreateTableStatement {
                    TableType: PTableType.View
            } createTableStatement:
                return(TableVisitor.VisitCreateViewStatement(createTableStatement));

            case IDMLStatement dmlStatement:
                return(ActionVisitor.Visit(dmlStatement));

            case UseSchemaStatement useSchemaStatement:
                return(ActionVisitor.VisitUseSchemaStatement(useSchemaStatement));
            }

            throw TreeHelper.NotSupportedTree(result);
        }
        public void Build(GeneralTree<IDirectoryTreeNode> features)
        {
            if (log.IsInfoEnabled)
            {
                log.InfoFormat("Writing Excel workbook to {0}", this.configuration.OutputFolder.FullName);
            }

            string spreadsheetPath = Path.Combine(this.configuration.OutputFolder.FullName, "features.xlsx");
            using (var workbook = new XLWorkbook())
            {
                var actionVisitor = new ActionVisitor<IDirectoryTreeNode>(node =>
                                                                              {
                                                                                  var featureDirectoryTreeNode =
                                                                                      node as FeatureDirectoryTreeNode;
                                                                                  if (featureDirectoryTreeNode != null)
                                                                                  {
                                                                                      IXLWorksheet worksheet =
                                                                                          workbook.AddWorksheet(
                                                                                              this.excelSheetNameGenerator.
                                                                                                  GenerateSheetName(
                                                                                                      workbook,
                                                                                                      featureDirectoryTreeNode
                                                                                                          .Feature));
                                                                                      this.excelFeatureFormatter.Format(
                                                                                          worksheet,
                                                                                          featureDirectoryTreeNode.
                                                                                              Feature);
                                                                                  }
                                                                              });

                features.AcceptVisitor(actionVisitor);

                this.excelTableOfContentsFormatter.Format(workbook, features);

                workbook.SaveAs(spreadsheetPath);
            }
        }
Exemplo n.º 32
0
        public void ActionShouldBeCalledOnEveryObject()
        {
            var list = new List <int>
            {
                1, 2, -3
            };

            var mockRepository = new MockRepository();

            // Just looking for an interface with a method that matches Action<T> - temporarily settled on list.
            var recorder = mockRepository.StrictMock <IList <int> >();

            recorder.Add(1);
            recorder.Add(2);
            recorder.Add(-3);

            mockRepository.ReplayAll();

            var visitor = new ActionVisitor <int>(recorder.Add);

            list.AcceptVisitor(visitor);

            mockRepository.VerifyAll();
        }
Exemplo n.º 33
0
        public void Build(GeneralTree<INode> features)
        {
            string filename = string.IsNullOrEmpty(this.configuration.SystemUnderTestName)
                ? "features.docx"
                : this.configuration.SystemUnderTestName + ".docx";
            string documentFileName = this.fileSystem.Path.Combine(this.configuration.OutputFolder.FullName, filename);
            if (this.fileSystem.File.Exists(documentFileName))
            {
                try
                {
                    this.fileSystem.File.Delete(documentFileName);
                }
                catch (System.IO.IOException ex)
                {
                    Log.Error("Cannot delete Word file. Is it still open in Word?", ex);
                    return;
                }
            }

            using (
                WordprocessingDocument wordProcessingDocument = WordprocessingDocument.Create(
                    documentFileName,
                    WordprocessingDocumentType.Document))
            {
                MainDocumentPart mainDocumentPart = wordProcessingDocument.AddMainDocumentPart();
                this.wordStyleApplicator.AddStylesPartToPackage(wordProcessingDocument);
                this.wordStyleApplicator.AddStylesWithEffectsPartToPackage(wordProcessingDocument);
                this.wordFontApplicator.AddFontTablePartToPackage(wordProcessingDocument);
                var documentSettingsPart = mainDocumentPart.AddNewPart<DocumentSettingsPart>();
                documentSettingsPart.Settings = new Settings();
                this.wordHeaderFooterFormatter.ApplyHeaderAndFooter(wordProcessingDocument);

                var document = new Document();
                var body = new Body();
                document.Append(body);

                var actionVisitor = new ActionVisitor<INode>(node =>
                {
                    var featureDirectoryTreeNode =
                        node as FeatureNode;
                    if (featureDirectoryTreeNode != null)
                    {
                        this.wordFeatureFormatter.Format(body, featureDirectoryTreeNode);
                    }
                });

                features.AcceptVisitor(actionVisitor);

                mainDocumentPart.Document = document;
                mainDocumentPart.Document.Save();
            }

            // HACK - Add the table of contents
            using (WordprocessingDocument wordProcessingDocument = WordprocessingDocument.Open(documentFileName, true))
            {
                XElement firstPara = wordProcessingDocument
                    .MainDocumentPart
                    .GetXDocument()
                    .Descendants(W.p)
                    .FirstOrDefault();

                TocAdder.AddToc(wordProcessingDocument, firstPara, @"TOC \o '1-2' \h \z \u", null, 4);
            }
        }
Exemplo n.º 34
0
        public void Build(GeneralTree<INode> features)
        {
            if (log.IsInfoEnabled)
            {
              log.Info("Writing JSON to {0}", this.configuration.OutputFolder.FullName);
            }

            var featuresToFormat = new List<FeatureWithMetaInfo>();

            var actionVisitor = new ActionVisitor<INode>(node =>
                                                                          {
                                                                              var featureTreeNode =
                                                                                  node as FeatureNode;
                                                                              if (featureTreeNode != null)
                                                                              {
                                                                                  if (this.configuration.HasTestResults)
                                                                                  {
                                                                                      featuresToFormat.Add(
                                                                                          new FeatureWithMetaInfo(
                                                                                              featureTreeNode,
                                                                                              this.testResults.
                                                                                                  GetFeatureResult(
                                                                                                      featureTreeNode.
                                                                                                          Feature)));
                                                                                  }
                                                                                  else
                                                                                  {
                                                                                      featuresToFormat.Add(
                                                                                          new FeatureWithMetaInfo(
                                                                                              featureTreeNode));
                                                                                  }
                                                                              }
                                                                          });

            features.AcceptVisitor(actionVisitor);

            CreateFile(this.OutputFilePath, GenerateJSON(featuresToFormat));
        }
Exemplo n.º 35
0
        internal static ReadMapNode RenderMapNode(Workspace Home, int PartitionID, HScriptParser.Crudam_read_maprContext context)
        {

            // Get the data source //
            DataSet data = VisitorHelper.GetData(Home, context.full_table_name());
            string alias =
                (context.K_AS() != null)
                ? context.IDENTIFIER().GetText()
                : data.Name;

            // Create a local heap to work off of //
            MemoryStruct local_heap = new MemoryStruct(true);

            // Create a record register //
            StaticRegister memory = new StaticRegister(null);

            // Create expression visitor //
            ExpressionVisitor exp_vis = new ExpressionVisitor(local_heap, Home, alias, data.Columns, memory);

            // Where clause //
            Predicate where = VisitorHelper.GetWhere(exp_vis, context.where_clause());

            // Create a reader //
            RecordReader reader = data.OpenReader(where);

            // Get the declarations //
            if (context.crudam_declare_many() != null)
            {
                VisitorHelper.AllocateMemory(Home, local_heap, exp_vis, context.crudam_declare_many());
            }

            // Get the map actions //
            ActionVisitor act_vis = new ActionVisitor(Home, local_heap, exp_vis);
            act_vis.IsAsync = true;
            TNode map = act_vis.ToNode(context.map_action().query_action());

            // Get the reduce actions //
            act_vis = new ActionVisitor(Home, local_heap, exp_vis);
            act_vis.IsAsync = false;
            TNode red = act_vis.ToNode(context.reduce_action().query_action());

            ReadMapNode node = new ReadMapNode(PartitionID, map, red, memory, where);

            return node;

        }
Exemplo n.º 36
0
        public void Build(DirectoryInfo inputPath, DirectoryInfo outputPath)
        {
            if (log.IsInfoEnabled)
            {
                log.InfoFormat("Writing HTML to {0}", outputPath.FullName);
            }

            this.htmlResourceWriter.WriteTo(outputPath.FullName);

            var features = this.featureCrawler.Crawl(inputPath);
            var actionVisitor = new ActionVisitor<FeatureNode>(node =>
                {
                    var nodePath = Path.Combine(outputPath.FullName, node.RelativePathFromRoot);

                    if (!node.IsDirectory)
                    {
                        var htmlFilePath = nodePath.Replace(Path.GetExtension(nodePath), ".xhtml");

                        using (var writer = new StreamWriter(htmlFilePath, false, Encoding.UTF8))
                        {
                            var document = this.htmlDocumentFormatter.Format(node, features);
                            document.Save(writer);
                            writer.Close();
                        }
                    }
                    else if (!node.IsEmpty)
                    {
                        Directory.CreateDirectory(nodePath);
                    }
                });

            features.AcceptVisitor(actionVisitor);
        }
Exemplo n.º 37
0
        // Action Node //
        public static ActionPlan RenderActionPlan(Workspace Home, HScriptParser.Query_actionContext context)
        {

            ExpressionVisitor exp_vis = new ExpressionVisitor(null, Home);
            ActionVisitor act_vis = new ActionVisitor(Home, null, exp_vis);
            TNode act = act_vis.ToNode(context);

            return new ActionPlan(act);

        }
Exemplo n.º 38
0
 void ProcessMethod(MethodDefinition method)
 {
     ActionVisitor.Visit(Options, method, a => ProcessMethodActions(method, a));
 }