public bool Visit(NamespaceBlockSyntax space, string path) { var fullPath = space.NamespaceStatement.Name.ToString(); if (path.Length > 0) { fullPath = path + "." + fullPath; } foreach (var member in space.Members) { var basetype = member as TypeBlockSyntax; if (basetype != null) { if (!this.Visit(basetype, fullPath)) { return(false); } continue; } var spacetype = member as NamespaceBlockSyntax; if (spacetype != null) { if (!this.Visit(spacetype, fullPath)) { return(false); } } } return(true); }
public override void VisitNamespaceBlock(NamespaceBlockSyntax node) { var defineName = string.Empty; var nsNode = node.ChildNodes().OfType <NamespaceStatementSyntax>().FirstOrDefault(); var qNode = nsNode.ChildNodes().OfType <QualifiedNameSyntax>().FirstOrDefault(); if (Util.IsNotNull(qNode)) { // Namespace NS1.NS2 defineName = qNode.ToString(); } else { // Namespace NS1 var iNode = nsNode.ChildNodes().OfType <IdentifierNameSyntax>().FirstOrDefault(); defineName = iNode.ToString(); } var startLength = node.Span.Start; var endLength = node.Span.End; var parentNamespace = GetNamespace(DefineKinds.Namespace, startLength, endLength); UserDefinitions.Add(new UserDefinition { DefineKinds = DefineKinds.Namespace, Namespace = parentNamespace, DefineName = defineName, DefineFullName = $"{parentNamespace}.{defineName}", SourceFile = SourceFile, StartLength = startLength, EndLength = endLength, }); base.VisitNamespaceBlock(node); }
public override void VisitNamespaceBlock(NamespaceBlockSyntax node) { AddBlockData(node); base.VisitNamespaceBlock(node); }
public override void VisitNamespaceBlock(NamespaceBlockSyntax node) { LogicalLineCount++; base.VisitNamespaceBlock(node); }
public override SyntaxNode VisitNamespaceBlock(NamespaceBlockSyntax node) { _namespace = node.NamespaceStatement.Name.ToFullString().Trim(); return(base.VisitNamespaceBlock(node)); }
private Namespace TraverseNamespace(NamespaceBlockSyntax nds) { Namespace retNS = new Namespace(); //First, grab any objects defined at the beginning of the namespace (even delegates!) List<DelegateStatementSyntax> delegates = new List<DelegateStatementSyntax>(); List<EventBlockSyntax> delegates2 = new List<EventBlockSyntax>(); List<InterfaceBlockSyntax> interfaces = new List<InterfaceBlockSyntax>(); List<EnumBlockSyntax> enums = new List<EnumBlockSyntax>(); List<StructureBlockSyntax> structs = new List<StructureBlockSyntax>(); List<MethodBlockSyntax> methods = new List<MethodBlockSyntax>(); List<ConstructorBlockSyntax> constructors = new List<ConstructorBlockSyntax>(); List<ModuleBlockSyntax> modules = new List<ModuleBlockSyntax>(); List<ClassBlockSyntax> classes = new List<ClassBlockSyntax>(); List<NamespaceBlockSyntax> namespaces = new List<NamespaceBlockSyntax>(); foreach (SyntaxNode sn in nds.ChildNodes()) { if (sn is DelegateStatementSyntax) { delegates.Add(sn as DelegateStatementSyntax); } if (sn is EventBlockSyntax) { delegates2.Add(sn as EventBlockSyntax); } else if (sn is InterfaceBlockSyntax) { interfaces.Add(sn as InterfaceBlockSyntax); } if (sn is EnumBlockSyntax) { enums.Add(sn as EnumBlockSyntax); } else if (sn is StructureBlockSyntax) { structs.Add(sn as StructureBlockSyntax); } else if (sn is MethodBlockSyntax) { methods.Add(sn as MethodBlockSyntax); } else if (sn is ConstructorBlockSyntax) { constructors.Add(sn as ConstructorBlockSyntax); } else if (sn is ModuleBlockSyntax) { modules.Add(sn as ModuleBlockSyntax); } else if (sn is ClassBlockSyntax) { classes.Add(sn as ClassBlockSyntax); } else if (sn is NamespaceBlockSyntax) { namespaces.Add(sn as NamespaceBlockSyntax); } } foreach (EnumBlockSyntax ebs in enums) { //traverse enums retNS.Enums.Add(TraverseEnum(ebs)); } foreach (StructureBlockSyntax sbs in structs) { retNS.Structs.Add(TraverseStruct(sbs)); } foreach (MethodBlockSyntax mbs in methods) { bool isConstructor = false; Method tempMethod = TraverseMethod(mbs, ref isConstructor); if (isConstructor) { retNS.Constructors.Add(tempMethod as Constructor); } else { retNS.Methods.Add(tempMethod); } } foreach (ConstructorBlockSyntax css in constructors) { retNS.Constructors.Add(TraverseConstructor(css)); } foreach (ModuleBlockSyntax mbs in modules) { retNS.Modules.Add(TraverseModule(mbs)); } foreach (ClassBlockSyntax cbs2 in classes) { retNS.Classes.Add(TraverseClass(cbs2)); } foreach (DelegateStatementSyntax dds in delegates) { //TraverseDelegate retNS.Delegates.Add(TraverseDelegate(dds)); } foreach (EventBlockSyntax ebs in delegates2) { //TraverseDelegate retNS.Delegates.Add(TraverseDelegate(ebs)); } //Next, traverse any classes foreach (ClassBlockSyntax cds in classes) { TraverseClass(cds); } foreach (InterfaceBlockSyntax ids in interfaces) { //TraverseInterface } foreach (NamespaceBlockSyntax nbs2 in namespaces) { retNS.Namespaces.Add(TraverseNamespace(nbs2)); } return retNS; }