Author: fejj
Date: 2007-05-15 13:00:57 -0400 (Tue, 15 May 2007)
New Revision: 77422

Modified:
   trunk/monodevelop/Extras/CSharpBinding/ChangeLog
   trunk/monodevelop/Extras/CSharpBinding/Parser/CodeGenerator.cs
Log:
2007-05-14  Jeffrey Stedfast  <[EMAIL PROTECTED]>

        * Parser/CodeGenerator.cs (RenameClass): Handle renaming of structs,
        enums, and interfaces too.



Modified: trunk/monodevelop/Extras/CSharpBinding/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/CSharpBinding/ChangeLog    2007-05-15 16:59:13 UTC 
(rev 77421)
+++ trunk/monodevelop/Extras/CSharpBinding/ChangeLog    2007-05-15 17:00:57 UTC 
(rev 77422)
@@ -1,3 +1,8 @@
+2007-05-14  Jeffrey Stedfast  <[EMAIL PROTECTED]>
+
+       * Parser/CodeGenerator.cs (RenameClass): Handle renaming of structs,
+       enums, and interfaces too.
+
 2007-05-15  Lluis Sanchez Gual <[EMAIL PROTECTED]> 
 
        * Parser/Resolver.cs: Include const fields in the static field list.

Modified: trunk/monodevelop/Extras/CSharpBinding/Parser/CodeGenerator.cs
===================================================================
--- trunk/monodevelop/Extras/CSharpBinding/Parser/CodeGenerator.cs      
2007-05-15 16:59:13 UTC (rev 77421)
+++ trunk/monodevelop/Extras/CSharpBinding/Parser/CodeGenerator.cs      
2007-05-15 17:00:57 UTC (rev 77422)
@@ -40,6 +40,8 @@
 using System.Text.RegularExpressions;
 using CSharpBinding.Parser.SharpDevelopTree;
 
+using ClassType = MonoDevelop.Projects.Parser.ClassType;
+
 namespace CSharpBinding.Parser
 {
        class CSharpRefactorer: BaseRefactorer
@@ -76,7 +78,21 @@
                                
                                txt = file.GetText (begin, end);
                                
-                               expr = new Regex (@"\sclass\s*(" + cls.Name + 
@")\s", RegexOptions.Multiline);
+                               switch (cls.ClassType) {
+                               case ClassType.Interface:
+                                       expr = new Regex (@"\sinterface\s*(" + 
cls.Name + @")\s", RegexOptions.Multiline);
+                                       break;
+                               case ClassType.Struct:
+                                       expr = new Regex (@"\sstruct\s*(" + 
cls.Name + @")\s", RegexOptions.Multiline);
+                                       break;
+                               case ClassType.Enum:
+                                       expr = new Regex (@"\senum\s*(" + 
cls.Name + @")\s", RegexOptions.Multiline);
+                                       break;
+                               default:
+                                       expr = new Regex (@"\sclass\s*(" + 
cls.Name + @")\s", RegexOptions.Multiline);
+                                       break;
+                               }
+                               
                                match = expr.Match (" " + txt + " ");
                                
                                if (!match.Success)
@@ -293,7 +309,7 @@
                {
                        if (type.FullyQualifiedName == 
declaringType.FullyQualifiedName)
                                return true;
-                               
+                       
                        if (type.BaseTypes != null) {
                                foreach (IReturnType bc in type.BaseTypes) {
                                        IClass bcls = 
ctx.ParserContext.GetClass (bc.FullyQualifiedName, bc.GenericArguments, true, 
true);
@@ -335,7 +351,7 @@
                                        int pos = 
file.GetPositionFromLineColumn (fieldExp.StartLocation.Y, 
fieldExp.StartLocation.X);
                                        string txt = file.GetText (pos, pos + 
member.Name.Length);
                                        if (txt == member.Name) {
-                                               //Console.WriteLine ("adding 
FieldDeclarationExpression reference {0}", member.Name);
+                                               //Console.WriteLine ("adding 
FieldReferenceExpression reference {0}", member.Name);
                                                references.Add (CreateReference 
(fieldExp.StartLocation.Y, fieldExp.StartLocation.X, member.Name));
                                        }
                                }
@@ -373,9 +389,11 @@
                                                //Console.WriteLine ("adding 
IdentifierExpression member reference {0}", member.Name);
                                                references.Add (CreateReference 
(idExp.StartLocation.Y, idExp.StartLocation.X, member.Name));
                                        }
-                               } else if (member is IClass && item is IClass 
&& (((IClass)member).FullyQualifiedName ==  ((IClass)item).FullyQualifiedName)) 
{
-                                       //Console.WriteLine ("adding 
IdentifierExpression class reference {0}", idExp.Identifier);
-                                       references.Add (CreateReference 
(idExp.StartLocation.Y, idExp.StartLocation.X, idExp.Identifier));
+                               } else if (member is IClass) {
+                                       if (item is IClass && ((IClass) 
item).FullyQualifiedName == declaringType.FullyQualifiedName) {
+                                               //Console.WriteLine ("adding 
IdentifierExpression class reference {0}", idExp.Identifier);
+                                               references.Add (CreateReference 
(idExp.StartLocation.Y, idExp.StartLocation.X, idExp.Identifier));
+                                       }
                                } else if (member is LocalVariable) {
                                        LocalVariable avar = member as 
LocalVariable;
                                        LocalVariable var = item as 
LocalVariable;
@@ -405,7 +423,7 @@
                                foreach (TypeReference bc in 
typeDeclaration.BaseTypes) {
                                        IClass bclass = 
resolver.ResolveIdentifier (fileCompilationUnit, bc.Type, 
typeDeclaration.StartLocation.Y, typeDeclaration.StartLocation.X) as IClass;
                                        if (bclass != null && 
bclass.FullyQualifiedName == fname) {
-                                               Console.WriteLine ("adding 
TypeDeclaration reference {0}", bc.Type);
+                                               //Console.WriteLine ("adding 
TypeDeclaration reference {0}", bc.Type);
                                                references.Add (CreateReference 
(typeDeclaration.StartLocation.Y, typeDeclaration.StartLocation.X, bc.Type));
                                        }
                                }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to