Author: fejj
Date: 2007-05-02 12:13:23 -0400 (Wed, 02 May 2007)
New Revision: 76578
Modified:
trunk/monodevelop/Extras/CSharpBinding/ChangeLog
trunk/monodevelop/Extras/CSharpBinding/Parser/CodeGenerator.cs
Log:
2007-05-02 Jeffrey Stedfast <[EMAIL PROTECTED]>
* Parser/CodeGenerator.cs (RenameClass): Rename all parts of the class
(in case the class is a partial class).
Modified: trunk/monodevelop/Extras/CSharpBinding/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/CSharpBinding/ChangeLog 2007-05-02 16:12:35 UTC
(rev 76577)
+++ trunk/monodevelop/Extras/CSharpBinding/ChangeLog 2007-05-02 16:13:23 UTC
(rev 76578)
@@ -1,3 +1,8 @@
+2007-05-02 Jeffrey Stedfast <[EMAIL PROTECTED]>
+
+ * Parser/CodeGenerator.cs (RenameClass): Rename all parts of the class
+ (in case the class is a partial class).
+
2007-05-01 Jeffrey Stedfast <[EMAIL PROTECTED]>
* Parser/CodeGenerator.cs (CreateReference): Trim the name to the
Modified: trunk/monodevelop/Extras/CSharpBinding/Parser/CodeGenerator.cs
===================================================================
--- trunk/monodevelop/Extras/CSharpBinding/Parser/CodeGenerator.cs
2007-05-02 16:12:35 UTC (rev 76577)
+++ trunk/monodevelop/Extras/CSharpBinding/Parser/CodeGenerator.cs
2007-05-02 16:13:23 UTC (rev 76578)
@@ -57,23 +57,38 @@
public override IClass RenameClass (RefactorerContext ctx,
IClass cls, string newName)
{
- IEditableTextFile file = ctx.GetFile
(cls.Region.FileName);
- if (file == null)
- return null;
-
- int pos1 = file.GetPositionFromLineColumn
(cls.Region.BeginLine, cls.Region.BeginColumn);
- int pos2 = file.GetPositionFromLineColumn
(cls.Region.EndLine, cls.Region.EndColumn);
- string txt = file.GetText (pos1, pos2);
+ IEditableTextFile file;
+ int pos, begin, end;
+ IClass []classes;
+ Match match;
+ Regex expr;
+ string txt;
- Regex targetExp = new Regex(@"\sclass\s*(" + cls.Name +
@")\s", RegexOptions.Multiline);
- Match match = targetExp.Match (" " + txt + " ");
- if (!match.Success)
+ if ((classes = cls.Parts) == null)
return null;
- int pos = pos1 + match.Groups [1].Index - 1;
- file.DeleteText (pos, cls.Name.Length);
- file.InsertText (pos, newName);
+ for (int i = 0; i < classes.Length; i++) {
+ if ((file = ctx.GetFile
(classes[i].Region.FileName)) == null)
+ continue;
+
+ begin = file.GetPositionFromLineColumn
(cls.Region.BeginLine, cls.Region.BeginColumn);
+ end = file.GetPositionFromLineColumn
(cls.Region.EndLine, cls.Region.EndColumn);
+
+ txt = file.GetText (begin, end);
+
+ expr = new Regex (@"\sclass\s*(" + cls.Name +
@")\s", RegexOptions.Multiline);
+ match = expr.Match (" " + txt + " ");
+
+ if (!match.Success)
+ continue;
+
+ pos = begin + match.Groups [1].Index - 1;
+ file.DeleteText (pos, cls.Name.Length);
+ file.InsertText (pos, newName);
+ }
+ file = ctx.GetFile (cls.Region.FileName);
+
return GetGeneratedClass (ctx, file, cls);
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches