public void AddSyntaxTree(SyntaxTree tree) { var root = tree.GetRoot(); // assume the usings are at the beginning and apply to all classes var usings = root.DescendantNodes().OfType<UsingDirectiveSyntax>(); // iterate class and enum declarations, including nested items. foreach (var node in root.DescendantNodes().OfType<BaseTypeDeclarationSyntax>()) { var qname = GetQualifiedTypeName(node); if (node is ClassDeclarationSyntax | node is EnumDeclarationSyntax | node is InterfaceDeclarationSyntax) { Trace("processing [{0}] '{1}' ...", node.GetType().Name, qname); ITypeItem ltype; try { CurrentClassName = qname; ltype = LoadType(qname); } catch (Exception ex) { if (ProcessException(ex)) { continue; } else { throw ex; } } finally { CurrentClassName = null; } if (ltype.DoNotGenerate) { continue; } // associate the source syntax node with the type item. var dsc = new DeclarationSourceContext(node, usings); ltype.SetSourceNode(dsc); // register this class ClassToQueue(ltype); } } }
public DeclarationEmitContext(ITypeItem type, DeclarationSourceContext dsc) { _dsc = dsc; LType = type; Writer = new JScriptWriter(); }