Exemple #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);
        }
Exemple #2
0
        public void Execute(RazorCodeDocument document)
        {
            var syntaxTree = document.GetSyntaxTree();

            if (syntaxTree == null)
            {
                syntaxTree = RazorParser.Parse(document.Source);
            }

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

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

            document.SetSyntaxTree(syntaxTree);
        }