Esempio n. 1
0
        /// <summary>
        /// Registers a new SpecialNodesInserter with the output visitor.
        /// Make sure to call Finish() (or Dispose()) on the returned SpecialNodesInserter
        /// when the output is finished.
        /// </summary>
        public static SpecialNodesUserDataInserter Install(IEnumerable <ISpecial> specials, IOutputAstVisitor outputVisitor)
        {
            SpecialNodesUserDataInserter sni = new SpecialNodesUserDataInserter(specials, new SpecialOutputVisitor(outputVisitor.OutputFormatter));

            outputVisitor.BeforeNodeVisit += sni.AcceptNodeStart;
            outputVisitor.AfterNodeVisit  += sni.AcceptNodeEnd;
            return(sni);
        }
        public static void InsertSpecials(CompilationUnit unit, IList <ISpecial> specials)
        {
            IOutputAstVisitor outputVisitor = new CSharpOutputVisitor();

            using (SpecialNodesUserDataInserter.Install(specials, outputVisitor)) {
                unit.AcceptVisitor(outputVisitor, null);
            }

            /*
             * List<ISpecial> collectedSpecials = new List<ISpecial>();
             * CollectSpecials(collectedSpecials, unit.Children);
             *
             * if (collectedSpecials.Count != specials.Count) {
             *  Console.Out.WriteLine(collectedSpecials.Count);
             *  Console.Out.WriteLine(specials.Count);
             *
             * }*/
        }