Document header , footer question

SyntaxEditor for Windows Forms Forum

Posted 17 years ago by Ricardo Goncalves
Version: 4.0.0259
Avatar
Hi, Can someone help on a problem...

I have a class :

public class AAA
{
string b;

public void myMethod(string c)
{
if( c == b)
{
c = null;
}
}
}

I wnat to separate this class to only allow the user to edit the code inside method myMethod. What is the correct way to verify where the method starts and where it ends.

Thanks

PS:I have the C# Addon.

Comments (3)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Put this in the header text:
public class AAA 
{ 
string b; 

public void myMethod(string c) 
{
And this in the footer text:

} 
}
Note that there is a line feed at the start of the footer text so that in case the last line in the document is a single line comment, it doesn't wipe out the first }.


Actipro Software Support

Posted 17 years ago by Ricardo Goncalves
Avatar
Thanks for your fast response, but it wasn´t in that I need help.

I need help in find the start and end of the method. I can do a search in the string to find the method name and then count the { and } of the close of the method, but that don't seem the correct way... Does the syntax editor provide any classes to work with the code of the class AAA, something like codeDom to detect where the myMtehod starts and where it ends.

Thanks.
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Yes the CompilationUnit (once parsed in a worker thread) will be in Document.SemanticParseData. You can see in the sample project that its contents are rendered to a TreeView in the SDI Editor. In your case you will have a CompilationUnit where some offsets of items in the header will be negative numbers since the document starts is considered offset 0. But you can walk the CompilationUnit to read everything in the document via the AST.


Actipro Software Support

The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.