John,
I haven't determined how to use CodeDOM for editing an existing Class and its methods. As I see it CodeDOM is a tool that only generates code (and compiles). CodeDOM has no way to auto-populate its graph from an existing CodeModel or 'suck in' a source file to create its graph -- again, there is no mapping from the DTE's CodeModel to a CodeDom graph.
So the easiest way that I can see is to find your method, then remove it and replace it with the changes you require. Below, is the code to remove a method using CodeClass. Then you can add/insert/replace it using CodeModel (which is not language agnostic) or you can use CodeDOM to create the new method and add the new method using IVstaProjectHostItem.AddMethod(CodeMemberMethod method) as demonstrated in the VSTA SDK macro recorder samples
Checkout EnvDTE80's; CodeClass2:
Specifically: CodeClass2.RemoveMember () and AddFunction()
When the macro recording is finished in the AdvancedCSharpShapeApp sample, SaveMacro() gets the Addin Class and uses a CodeDom.CodeMemberMethod to add a method:
hostAdapter.ProjectHostItems[0].AddMethod(method);
but prior to this, the correct CodeClass is determined by name lookup
sampleEnvDTE.CodeClass hostItemClass = FindClass(hostItemClassName, hostItemProjectItem.FileCodeModel.CodeElements);
And this is a good context to illustrate the use of AddFunction and RemoveMember:
A CodeClass instance, like hostItemClass in this example, can be used to add and remove class methods as follows:
//Add
elt = (EnvDTE.CodeElement)(hostItemClass .AddFunction(defaultName,
EnvDTE.vsCMFunction.vsCMFunctionFunction,
EnvDTE.vsCMTypeRef.vsCMTypeRefInt, -1,
EnvDTE.vsCMAccess.vsCMAccessDefault, null));
//remove
hostItemClass .RemoveMember(elt);
Here's a blog that uses EnvDTE codemodel more extensively:
http://mikehadlow.blogspot.com/2006/09/how-to-examine-code-and-write-class.html