public static bool TryGetLastNamespaceDirective( RazorSyntaxTree syntaxTree, out string namespaceDirectiveContent, out SourceSpan namespaceDirectiveSpan) { var visitor = new NamespaceVisitor(syntaxTree.Source); visitor.Visit(syntaxTree.Root); if (string.IsNullOrEmpty(visitor.LastNamespaceContent)) { namespaceDirectiveContent = null; namespaceDirectiveSpan = SourceSpan.Undefined; return(false); } namespaceDirectiveContent = visitor.LastNamespaceContent; namespaceDirectiveSpan = visitor.LastNamespaceLocation; return(true); }
private string GetNamespaceForSyntaxTree(SyntaxTree syntaxTree) { var namespaceVisitor = new NamespaceVisitor(); namespaceVisitor.Visit(syntaxTree.GetRoot()); return namespaceVisitor.Namespace; }