2004-08-03 Martin Baulig <martin@ximian.com>
[mono.git] / mcs / mbas / namespace.cs
index 0a3aeea93d08caec01a9c222c3ae5082ca631afe..6cb6b3c5908d75a183494d30509063a82bd91dbc 100644 (file)
@@ -20,31 +20,7 @@ namespace Mono.MonoBASIC {
                
                Namespace parent;
                string name;
-               Hashtable using_clauses;
-               Hashtable aliases;
-               
-               public bool DeclarationFound = false;
-
-               //
-               // This class holds the location where a using definition is
-               // done, and whether it has been used by the program or not.
-               //
-               // We use this to flag using clauses for namespaces that do not
-               // exist.
-               //
-               public class UsingEntry {
-                       public string Name;
-                       public bool Used;
-                       public Location Location;
-                       
-                       public UsingEntry (string name, Location loc)
-                       {
-                               Name = name;
-                               Location = loc;
-                               Used = false;
-                       }
-               }
-               
+                               
                /// <summary>
                ///   Constructor Takes the current namespace and the
                ///   name.  This is bootstrapped with parent == null
@@ -81,96 +57,13 @@ namespace Mono.MonoBASIC {
                                return parent;
                        }
                }
-
-               /// <summary>
-               ///   Records a new namespace for resolving name references
-               /// </summary>
-               public void Using (string ns, Location loc)
-               {
-                       if (DeclarationFound){
-                               Report.Error (1529, loc, "A using clause must precede all other namespace elements");
-                               return;
-                       }
-
-                       if (using_clauses == null)
-                               using_clauses = new CaseInsensitiveHashtable ();
-
-                       UsingEntry ue = new UsingEntry (ns, loc);
-                       using_clauses [ns] = ue;
-               }
-
-               public ICollection UsingTable {
-                       get {
-                               return using_clauses.Values;
-                       }
-               }
-
-               public void UsingAlias (string alias, string namespace_or_type, Location loc)
-               {
-                       if (aliases == null)
-                               aliases = new CaseInsensitiveHashtable ();
-                       
-                       if (aliases.Contains (alias)){
-                               Report.Error (1537, loc, "The using alias `" + alias +
-                                             "' appeared previously in this namespace");
-                               return;
-                       }
-                                       
-                       aliases [alias] = namespace_or_type;
-               }
-
-               public string LookupAlias (string alias)
-               {
-                       string value = null;
-
-                       // System.Console.WriteLine ("Lookup " + alias + " in " + name);
-
-                       if (aliases != null)
-                               value = (string) (aliases [alias]);
-                       if (value == null && Parent != null)
-                               value = Parent.LookupAlias (alias);
-
-                       return value;
-               }
-
+               
                /// <summary>
-               ///   Used to validate that all the using clauses are correct
-               ///   after we are finished parsing all the files.  
+               ///   Show the qualified name of the namespace contained here
                /// </summary>
-               public static bool VerifyUsing ()
-               {
-                       ArrayList unused = new ArrayList ();
-                       int errors = 0;
-                       
-                       foreach (Namespace ns in all_namespaces){
-                               foreach (UsingEntry ue in ns.UsingTable){
-                                       if (ue.Used)
-                                               continue;
-                                       unused.Add (ue);
-                               }
-                       }
-
-                       //
-                       // If we have unused using aliases, load all namespaces and check
-                       // whether it is unused, or it was missing
-                       //
-                       if (unused.Count > 0){
-                               CaseInsensitiveHashtable namespaces = TypeManager.GetNamespaces ();
-
-                               foreach (UsingEntry ue in unused){
-                                       if (namespaces.Contains (ue.Name)){
-                                               Report.Warning (6024, ue.Location, "Unused namespace in `using' declaration");
-                                               continue;
-                                       }
-
-                                       errors++;
-                                       Report.Error (246, ue.Location, "The namespace `" + ue.Name +
-                                                     "' can not be found (missing assembly reference?)");
-                               }
-                       }
-                       
-                       return errors == 0;
+               public override string ToString() {
+                       return Name;
                }
-
+               
        }
 }