void Refactor(CompilationUnit compilationUnit, NamespaceDeclaration nsd)
 {
     for (int i = 0; i < nsd.Children.Count; ++i) {
         object o = nsd.Children[i];
         if (o is UsingDeclaration) {
             UsingDeclaration  ud = (UsingDeclaration) o;
             if (namespaces[ud.Namespace] == null) {
                 namespaces[ud.Namespace] = "";
                 compilationUnit.Children.Insert(0, ud);
             }
             nsd.Children.RemoveAt(i);
             i = -1;
         } else if (o is UsingAliasDeclaration) {
             compilationUnit.Children.Insert(0, o);
             nsd.Children.RemoveAt(i);
             i = -1;
         }
     }
 }
        public override object Visit(NamespaceDeclaration namespaceDeclaration, object data)
        {
            ProcessSpecials(namespaceDeclaration.Specials);

            CodeNamespace currentNamespace = new CodeNamespace(namespaceDeclaration.NameSpace);
            namespaces.Add(currentNamespace);
            // add imports from mother namespace
            foreach (CodeNamespaceImport import in ((CodeNamespace)namespaceDeclarations.Peek()).Imports) {
                currentNamespace.Imports.Add(import);
            }
            namespaceDeclarations.Push(currentNamespace);
            namespaceDeclaration.AcceptChildren(this, data);
            namespaceDeclarations.Pop();
            codeCompileUnit.Namespaces.Add(currentNamespace);

            // TODO : Nested namespaces allowed in CodeDOM ? Doesn't seem so :(
            return null;
        }
 public override object Visit(NamespaceDeclaration namespaceDeclaration, object data)
 {
     DebugOutput(namespaceDeclaration);
     AppendIndentation();sourceText.Append("Namespace ");
     sourceText.Append(namespaceDeclaration.NameSpace);
     AppendNewLine();
     ++indentLevel;
     namespaceDeclaration.AcceptChildren(this, data);
     --indentLevel;
     AppendIndentation();sourceText.Append("End Namespace");
     AppendNewLine();
     return null;
 }
 public override object Visit(NamespaceDeclaration namespaceDeclaration, object data)
 {
     Console.WriteLine(namespaceDeclaration.ToString());
     return namespaceDeclaration.AcceptChildren(this, data);
 }
 public virtual object Visit(NamespaceDeclaration namespaceDeclaration, object data)
 {
     return namespaceDeclaration.AcceptChildren(this, data);
 }
Esempio n. 6
0
	void NamespaceMemberDecl() {

#line  664 "cs.ATG" 
		AttributeSection section;
		ArrayList attributes = new ArrayList();
		Modifiers m = new Modifiers(this);
		string qualident;
		
		if (la.kind == 87) {
			lexer.NextToken();

#line  670 "cs.ATG" 
			Point startPos = t.Location; 
			Qualident(
#line  671 "cs.ATG" 
out qualident);

#line  671 "cs.ATG" 
			INode node =  new NamespaceDeclaration(qualident);
			node.StartLocation = startPos;
			compilationUnit.AddChild(node);
			compilationUnit.BlockStart(node);
			
			Expect(14);
			while (la.kind == 120) {
				UsingDirective();
			}
			while (StartOf(1)) {
				NamespaceMemberDecl();
			}
			Expect(15);
			if (la.kind == 10) {
				lexer.NextToken();
			}

#line  680 "cs.ATG" 
			node.EndLocation   = t.EndLocation;
			compilationUnit.BlockEnd();
			
		} else if (StartOf(2)) {
			while (la.kind == 16) {
				AttributeSection(
#line  684 "cs.ATG" 
out section);

#line  684 "cs.ATG" 
				attributes.Add(section); 
			}
			while (StartOf(3)) {
				TypeModifier(
#line  685 "cs.ATG" 
m);
			}

#line  686 "cs.ATG" 
			bool partial = false; 
			if (
#line  687 "cs.ATG" 
IdentIsPartial ()) {
				lexer.NextToken();

#line  687 "cs.ATG" 
				partial = true; 
			}
			TypeDecl(
#line  688 "cs.ATG" 
m, attributes, partial);
		} else SynErr(126);
	}
        public override object Visit(NamespaceDeclaration namespaceDeclaration, object data)
        {
            outputFormatter.NewLine ();
            outputFormatter.Indent();
            outputFormatter.PrintToken(Tokens.Namespace);
            outputFormatter.Space();
            outputFormatter.PrintIdentifier(namespaceDeclaration.NameSpace);

            outputFormatter.BeginBrace(this.prettyPrintOptions.NameSpaceBraceStyle);

            namespaceDeclaration.AcceptChildren(this, data);

            outputFormatter.EndBrace();

            return null;
        }