API needed to capture an entire type\'s declaration
Status: Beta
Brought to you by:
bernhardbrem
The parser currently marks the starting offset of a variable (and possibly all fields?) right at the beginning of its name. This is not very useful when one has to perform changes to the declaration as a whole.
One needed use case would be a quick fix for removing an unused variable. The entire declaration's offset and length is needed to be used with IDocument's replace(int, int, String) method.
Logged In: YES
user_id=1245734
Originator: NO
That must be fixed (should not be too hard). But there are other some odther probs if You want to write such a quick fix: At the moment, the length of the var describes how far this var is valid. This behavour is used at least in the command line completion. So You have to determine the region which has to be replaced You can't use this information.
In any case:
I would wait with writing the quick fix until we have the "search references" function: Then a unused var is simple one with no references.......
Logged In: YES
user_id=1245734
Originator: NO
"In any case:
I would wait with writing the quick fix until we have the "search
references" function: Then a unused var is simple one with no
references": That is naturly nonsense: You will use the compiler messages for the quick fix, not the own search function............
Logged In: YES
user_id=1245734
Originator: NO
Should do it now. Please let me know if not.
Logged In: YES
user_id=1299552
Originator: YES
Did you mean you'd like me to work on this now? I don't have the time for such major changes and I'm not familiar enough with the CSharpCodeParser code to take this on, I'm afraid. :/ There are also no unit tests for me to use to ensure that I haven't broken anything.
If you mean you'd like to work on this now instead of later, then yes, I agree that we should get this implemented ASAP if time allows.
Logged In: YES
user_id=1299552
Originator: YES
Never mind. I see you've committed something to CVS and actually meant "if this doesn't work let me know". Since we don't have a declaration's length at the moment, we can't really test this.
From a very simple test case, if you look at the code element that is 'j', I noticed that getOffset() and getNameoffset() (which should be getNameOffset()) are both returning the same values.
class Test {
void x() {
int j = 0;
}
}
Logged In: YES
user_id=1245734
Originator: NO
Yes, I meant with my comment that I thought I have fixed it and You can use the functionality if You like. However, I fixed the behavour for all code elements which could be declared as orivate, protected and so on but forgot the variables. Now the correct code (incl. variable offset) is in the cvs and can be used if anyone needs this information.