Skip to content
This repository
Browse code

Fixed assembly attribute location.

The fix isn't very clean - but the structure is built that way, would
be cleaner if it would be represented as Container.
  • Loading branch information...
commit c33bc0fd8cd727b21b1bbfcb88c85f34581ac42c 1 parent 764b8a3
Mike Krüger authored February 06, 2012
48  ICSharpCode.NRefactory.CSharp/Parser/CSharpParser.cs
@@ -68,11 +68,53 @@ public static TextLocation Convert (Mono.CSharp.Location loc)
68 68
 			
69 69
 			public override void Visit (ModuleContainer mc)
70 70
 			{
71  
-				AddAttributeSection (Unit, mc);
  71
+				bool first = true;
72 72
 				foreach (var container in mc.Containers) {
73  
-					container.Accept (this);
  73
+					var nspace = container as NamespaceContainer;
  74
+					if (nspace == null) {
  75
+						container.Accept (this);
  76
+						continue;
  77
+					}
  78
+					NamespaceDeclaration nDecl = null;
  79
+					var loc = LocationsBag.GetLocations (nspace);
  80
+					
  81
+					if (nspace.NS != null && !string.IsNullOrEmpty (nspace.NS.Name)) {
  82
+						nDecl = new NamespaceDeclaration ();
  83
+						if (loc != null)
  84
+							nDecl.AddChild (new CSharpTokenNode (Convert (loc[0]), "namespace".Length), NamespaceDeclaration.Roles.Keyword);
  85
+						ConvertNamespaceName (nspace.RealMemberName, nDecl);
  86
+						if (loc != null && loc.Count > 1)
  87
+							nDecl.AddChild (new CSharpTokenNode (Convert (loc[1]), 1), NamespaceDeclaration.Roles.LBrace);
  88
+						AddToNamespace (nDecl);
  89
+						namespaceStack.Push (nDecl);
  90
+					}
  91
+					
  92
+					if (nspace.Usings != null) {
  93
+						foreach (var us in nspace.Usings) {
  94
+							us.Accept (this);
  95
+						}
  96
+					}
  97
+					
  98
+					if (first) {
  99
+						first = false;
  100
+						AddAttributeSection (Unit, mc);
  101
+					}
  102
+					
  103
+					if (nspace.Containers != null) {
  104
+						foreach (var subContainer in nspace.Containers) {
  105
+							subContainer.Accept (this);
  106
+						}
  107
+					}
  108
+					
  109
+					if (nDecl != null) {
  110
+						if (loc != null && loc.Count > 2)
  111
+							nDecl.AddChild (new CSharpTokenNode (Convert (loc[2]), 1), NamespaceDeclaration.Roles.RBrace);
  112
+						if (loc != null && loc.Count > 3)
  113
+							nDecl.AddChild (new CSharpTokenNode (Convert (loc[3]), 1), NamespaceDeclaration.Roles.Semicolon);
  114
+						
  115
+						namespaceStack.Pop ();
  116
+					}
74 117
 				}
75  
-				
76 118
 			}
77 119
 			
78 120
 			#region Global

0 notes on commit c33bc0f

Please sign in to comment.
Something went wrong with that request. Please try again.