Esempio n. 1
0
        private static IList <RazorSyntaxTree> GetImportedSyntaxTrees(RazorCodeDocument document)
        {
            var trees = document.GetVirtualSyntaxTrees();

            if (trees.Count > 0)
            {
                return(trees);
            }

            var directiveDescriptors = document.GetDirectiveDescriptors();
            var importedDocuments    = document.GetImportedDocuments();

            foreach (var importedDocument in importedDocuments)
            {
                var syntaxTree = RazorParser.Parse(importedDocument, directiveDescriptors);

                foreach (var error in syntaxTree.Diagnostics)
                {
                    document.ErrorSink.OnError(error);
                }

                trees.Add(syntaxTree);
            }

            return(trees);
        }
Esempio n. 2
0
        public void Execute(RazorCodeDocument document)
        {
            var syntaxTree = document.GetSyntaxTree();

            if (syntaxTree == null)
            {
                var directiveDescriptors = document.GetDirectiveDescriptors();
                syntaxTree = RazorParser.Parse(document.Source, directiveDescriptors);
            }

            var passes = Engine.Features.OfType <ISyntaxTreePass>().OrderBy(p => p.Order).ToArray();

            foreach (var pass in passes)
            {
                syntaxTree = pass.Execute(document, syntaxTree);
            }

            document.SetSyntaxTree(syntaxTree);
        }