예제 #1
0
            public override object VisitNamespaceDeclaration(ICSharpCode.NRefactory.Ast.NamespaceDeclaration namespaceDeclaration, object data)
            {
                var visitorData = (VisitorData)data;

                visitorData.CurrentNamespaces.Push(namespaceDeclaration.Name);
                // Visit children (E.g. TypeDcelarion objects)
                namespaceDeclaration.AcceptChildren(this, visitorData);
                visitorData.CurrentNamespaces.Pop();
                return(null);
            }
예제 #2
0
//			public override object VisitUsing(ICSharpCode.NRefactory.Ast.Using usingDeclaration, object data)
//			{
//				DefaultUsing u = new DefaultUsing();
//				if (usingDeclaration.IsAlias)
//					u.Aliases[usingDeclaration.Name] = new ReturnType (usingDeclaration.Alias.Type);
//				else
//					u.Usings.Add(usingDeclaration.Name);
//				cu.Usings.Add(u);
//				return data;
//			}

//		ModifierEnum VisitModifier(ICSharpCode.SharpRefactory.Parser.Modifier m)
//		{
//			return (ModifierEnum)m;
//		}

            public override object VisitNamespaceDeclaration(ICSharpCode.NRefactory.Ast.NamespaceDeclaration namespaceDeclaration, object data)
            {
                string name;

                if (currentNamespace.Count == 0)
                {
                    name = namespaceDeclaration.Name;
                }
                else
                {
                    name = String.Concat((string)currentNamespace.Peek(), '.', namespaceDeclaration.Name);
                }
                currentNamespace.Push(name);
                object ret = namespaceDeclaration.AcceptChildren(this, data);

                currentNamespace.Pop();
                return(ret);
            }
			public override object VisitNamespaceDeclaration (ICSharpCode.NRefactory.Ast.NamespaceDeclaration namespaceDeclaration, object data)
			{
				string[] splittedNamespace = namespaceDeclaration.Name.Split ('.');
				for (int i = splittedNamespace.Length; i > 0; i--) {
					DomUsing domUsing = new DomUsing ();
					domUsing.IsFromNamespace = true;
					domUsing.Region = ConvertRegion (namespaceDeclaration.StartLocation, namespaceDeclaration.EndLocation);
					domUsing.ValidRegion = domUsing.Region;
					domUsing.Add (String.Join (".", splittedNamespace, 0, i));
					((CompilationUnit)result.CompilationUnit).Add (domUsing);
				}
				namespaceEndLocationStack.Push (namespaceDeclaration.EndLocation);
				namespaceStack.Push (namespaceStack.Count == 0 ? namespaceDeclaration.Name : namespaceStack.Peek () + "." + namespaceDeclaration.Name);
				namespaceDeclaration.AcceptChildren (this, data);
				namespaceStack.Pop ();
				namespaceEndLocationStack.Pop ();
				return null;
			}