[csdoc-patches] CVS: csdoc/src/csdoc AssemblyObjectNames.cs,1.1,1.2 ChangeLog,1.23,1.24 decl.cs,1.2,
Status: Planning
Brought to you by:
mastergaurav
|
From: Gaurav V. <mas...@us...> - 2003-04-10 07:10:41
|
Update of /cvsroot/csdoc/csdoc/src/csdoc
In directory sc8-pr-cvs1:/tmp/cvs-serv19011
Modified Files:
AssemblyObjectNames.cs ChangeLog decl.cs namespace.cs
Log Message:
2003-04-10 Gaurav Vaish <mastergaurav AT users DOT sf DOT net>
* decl.cs,
* namespace.cs : Added more support for CS0101 bug.
Can now report an error is a class
One::Two exists when namespace One.Two
is already defined and vice-versa.
Index: AssemblyObjectNames.cs
===================================================================
RCS file: /cvsroot/csdoc/csdoc/src/csdoc/AssemblyObjectNames.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AssemblyObjectNames.cs 10 Apr 2003 05:14:44 -0000 1.1
+++ AssemblyObjectNames.cs 10 Apr 2003 07:10:36 -0000 1.2
@@ -1,142 +1,158 @@
-/**
- *
- * Project : Master C# Documentation Generator
- * URL : http://csdoc.sourceforge.net
- * Namespace : Mono.CSharp
- * Class : AssemblyObjectNames
- * Author : Gaurav Vaish
- *
- * Copyright : (C) 2002-2003, with Gaurav Vaish
- */
-
-using System;
-using System.Collections;
-
-namespace Mono.CSharp
-{
- public class AssemblyObjectNames
- {
- private static AssemblyObjectNames root =
- new AssemblyObjectNames();
- private string thisName;
- private AssemblyObjectNames[] children;
-
- private AssemblyObjectNames()
- {
- this.thisName = String.Empty;
- this.children = null;
- }
-
- private AssemblyObjectNames(string fullName)
- {
- int colon = fullName.IndexOf('.');
- string first = (colon == -1 ?
- fullName : fullName.Substring(0, colon));
- string remainder = (colon == -1 ?
- String.Empty : fullName.Substring(colon + 1));
- this.thisName = first;
- if(colon > 0)
- {
- AddChild(remainder);
- }
- }
-
- public AssemblyObjectNames Root
- {
- get
- {
- return root;
- }
- }
-
- public string Name
- {
- get
- {
- return this.thisName;
- }
- }
-
- public AssemblyObjectNames[] Children
- {
- get
- {
- return this.children;
- }
- }
-
- // false == could not add. Name already defined
- public bool AddChild(string fullName)
- {
- if(IsDefined(fullName))
- return false;
- return Root.AddChild(ref Root.children, fullName);
- }
-
- private bool AddChild(ref AssemblyObjectNames[] names,
- string subName)
- {
- int colon = subName.IndexOf('.');
- string first = (colon == -1 ?
- subName : subName.Substring(0, colon));
- string remainder = (colon == -1 ?
- String.Empty : subName.Substring(colon + 1));
- int addIndex = -1;
- bool existed = false;
- if(names == null)
- {
- names = new AssemblyObjectNames[1];
- names[0] = new AssemblyObjectNames();
- names[0].thisName = first;
- names[0].children = null;
- addIndex = 0;
- } else
- {
- for(int index = 0; index < names.Length; index++)
- {
- if(names[index].thisName == first)
- {
- addIndex = index;
- existed = true;
- break;
- }
- }
- if(!existed)
- {
- int len = names.Length;
- AssemblyObjectNames[] newNames =
- new AssemblyObjectNames[len];
- Array.Copy(names, newNames, len);
- names = new AssemblyObjectNames[len + 1];
- Array.Copy(newNames, names, len);
- names[len] = new AssemblyObjectNames();
- names[len].thisName = first;
- names[len].children = null;
- addIndex = len;
- }
- }
- if(remainder == String.Empty)
- {
- return !existed;
- }
-
- return AddChild(ref names[addIndex].children, remainder);
- }
-
- private static string GetBasename(string nsName,
- int level)
- {
- string[] split = nsName.Split(new char[] { '.' });
- if(level < split.Length)
- {
- return split[level];
- }
- return String.Empty;
- }
-
- private static bool IsDefined(string fullName)
- {
- throw new NotImplementedException();
- }
- }
-}
+/**
+ *
+ * Project : Master C# Documentation Generator
+ * URL : http://csdoc.sourceforge.net
+ * Namespace : Mono.CSharp
+ * Class : AssemblyObjectNames
+ * Author : Gaurav Vaish
+ *
+ * Copyright : (C) 2002-2003, with Gaurav Vaish
+ */
+
+using System;
+using System.Collections;
+
+namespace Mono.CSharp
+{
+ public class AssemblyObjectNames
+ {
+ private static AssemblyObjectNames root =
+ new AssemblyObjectNames();
+ private string thisName;
+ private Location location;
+ private AssemblyObjectNames[] children;
+ private bool isNamespace;
+
+ private AssemblyObjectNames()
+ {
+ this.thisName = String.Empty;
+ this.children = null;
+ }
+
+ public static AssemblyObjectNames Root
+ {
+ get
+ {
+ return root;
+ }
+ }
+
+ public bool IsNamespace
+ {
+ get
+ {
+ return this.isNamespace;
+ }
+ }
+
+ public Location Location
+ {
+ get
+ {
+ return this.location;
+ }
+ }
+
+ public string Name
+ {
+ get
+ {
+ return this.thisName;
+ }
+ }
+
+ public AssemblyObjectNames[] Children
+ {
+ get
+ {
+ return this.children;
+ }
+ }
+
+ // false == could not add. Name already defined
+ public bool AddChild(string fullName, ref Location location,
+ bool isNamespace)
+ {
+ return Root.AddChild(ref Root.children, ref location,
+ fullName, isNamespace);
+ }
+
+ private bool AddChild(ref AssemblyObjectNames[] names,
+ ref Location location,
+ string subName, bool isNamespace)
+ {
+ int colon = subName.IndexOf('.');
+ string first = (colon == -1 ?
+ subName : subName.Substring(0, colon));
+ string remainder = (colon == -1 ?
+ String.Empty : subName.Substring(colon + 1));
+ int addIndex = -1;
+ bool existed = false;
+ if(names == null)
+ {
+ names = new AssemblyObjectNames[1];
+ names[0] = new AssemblyObjectNames();
+ names[0].thisName = first;
+ names[0].children = null;
+ names[0].isNamespace = isNamespace;
+ names[0].location = location;
+ addIndex = 0;
+ } else
+ {
+ for(int index = 0; index < names.Length; index++)
+ {
+ if(names[index].thisName == first)
+ {
+ addIndex = index;
+ existed = true;
+ break;
+ }
+ }
+ if(!existed)
+ {
+ int len = names.Length;
+ AssemblyObjectNames[] newNames =
+ new AssemblyObjectNames[len];
+ Array.Copy(names, newNames, len);
+ names = new AssemblyObjectNames[len + 1];
+ Array.Copy(newNames, names, len);
+ names[len] = new AssemblyObjectNames();
+ names[len].thisName = first;
+ names[len].children = null;
+ names[len].isNamespace = isNamespace;
+ names[len].location = location;
+ addIndex = len;
+ }
+ }
+ if(remainder == String.Empty)
+ {
+ if(existed)
+ {
+ location = names[addIndex].location;
+ return (names[addIndex].isNamespace && isNamespace);
+ }
+ return true;
+ }
+
+ return AddChild(ref names[addIndex].children,
+ ref location,
+ remainder, isNamespace);
+ }
+
+ private static string GetBasename(string nsName,
+ int level)
+ {
+ string[] split = nsName.Split(new char[] { '.' });
+ if(level < split.Length)
+ {
+ return split[level];
+ }
+ return String.Empty;
+ }
+
+ private static bool IsDefined(string fullName)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
Index: ChangeLog
===================================================================
RCS file: /cvsroot/csdoc/csdoc/src/csdoc/ChangeLog,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- ChangeLog 10 Apr 2003 05:14:44 -0000 1.23
+++ ChangeLog 10 Apr 2003 07:10:36 -0000 1.24
@@ -1,6 +1,14 @@
2003-04-10 Gaurav Vaish <mastergaurav AT users DOT sf DOT net>
+ * decl.cs,
+ * namespace.cs : Added more support for CS0101 bug.
+ Can now report an error is a class
+ One::Two exists when namespace One.Two
+ is already defined and vice-versa.
+
+2003-04-10 Gaurav Vaish <mastergaurav AT users DOT sf DOT net>
+
* makefile : Modified doc target to build binary as
$(BINARY) instead of default driver.exe
: Use AssemblyObjectNames.cs
Index: decl.cs
===================================================================
RCS file: /cvsroot/csdoc/csdoc/src/csdoc/decl.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- decl.cs 24 Feb 2003 08:33:51 -0000 1.2
+++ decl.cs 10 Apr 2003 07:10:36 -0000 1.3
@@ -300,6 +300,11 @@
Basename = name.Substring (1 + name.LastIndexOf ('.'));
defined_names = new Hashtable ();
this.parent = parent;
+ if(name.Trim().Length > 0)
+ {
+ if(!AssemblyObjectNames.Root.AddChild(name, ref l, false))
+ Report.Error(101, l, "Failed to add \"" + name + "\"");
+ }
}
/// <summary>
Index: namespace.cs
===================================================================
RCS file: /cvsroot/csdoc/csdoc/src/csdoc/namespace.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- namespace.cs 8 Apr 2003 06:24:42 -0000 1.2
+++ namespace.cs 10 Apr 2003 07:10:36 -0000 1.3
@@ -72,6 +72,10 @@
this.parent = parent;
all_namespaces.Add (this);
+ Location l = new Location(-1);
+ if(!AssemblyObjectNames.Root.AddChild(name, ref l, true))
+ Report.Error(0101, l, "Failed to add namespace: " + name);
+ //Console.WriteLine("Failed to add namespace: " + name);
}
/// <summary>
|