Author |
Topic  |
|
andre.horst
Tomato Guru
    
Germany
150 Posts |
Posted - Jun 13 2012 : 10:07:25 AM
|
Latest VAX, Win7, VC2008.
"Document Method" refactoring inserts the documentation on the wrong position if "::" operator is used in return type. See following example
typedef int foo ;
::foo bar( void ){return 0;} // Use "Document Method" on "bar"
|
|
accord
Whole Tomato Software
    
United Kingdom
3287 Posts |
Posted - Jun 13 2012 : 8:00:02 PM
|
I am seeing the same effect here. Thank you for the clear description.
case=67249 |
 |
|
andre.horst
Tomato Guru
    
Germany
150 Posts |
Posted - Jun 14 2012 : 08:06:30 AM
|
I just wanted to document a function and found the following problem with "Document Method"
#define test
test
template< typename T >
T foo( T p ){ return T ;}
Without the define and "test" "Document Method" works fine. |
 |
|
feline
Whole Tomato Software
    
United Kingdom
19179 Posts |
Posted - Jun 14 2012 : 4:32:20 PM
|
Convert the line "test" into "test;", and Document Method works correctly. The invalid code further up is confusing our parser. This happens occasionally, and once you recognise the pattern, looking for a missing semi-colon normally helps. |
zen is the art of being at one with the two'ness |
 |
|
andre.horst
Tomato Guru
    
Germany
150 Posts |
Posted - Jun 15 2012 : 03:33:11 AM
|
There is no invalid code. You can have a ";" in a define or not. I know macro parsing is difficult, but at least this should be possible
#define test1
#define test2 ;
test1 ;
test2
test2 ;
;;;;
#define begin {
#define nothing
#define empty ;
#define end }
begin
nothing
empty
end
begin ;
nothing ;
empty ;
end ;
|
 |
|
accord
Whole Tomato Software
    
United Kingdom
3287 Posts |
Posted - Jun 15 2012 : 11:29:05 AM
|
In theory, you are right.
In C++, every statement is closed by ;. You can ignore this or any other rule via using macros since the preprocessor replaces the actual code. But we don't run the refactoring on pre-processed code, since we need to put the result in the source code, not the intermediate one. Using macros, you can merge codes in any way, you can even split symbols or keywords in two... User does some weird things in real life.
My personal opinion: As far as I know, macros were designed in 1973 and they were improved in 1974. Bjarne Stroustrup the main designer of C++ said that they intentionally didn't improve macros when they designed C++ because they are obsolete and should not be used. (They're kept for backward compatibility.) I'm limiting macro usage and try to keep them as simple as possible. Inline and template functions, typedefs are the new way (and usage keyword was also improved in C++ 11 to include typedef-like usage). They are much more limited than macros, but limits are not always a bad thing: a lot of new programming languages are limit things compared to C++ on purpose. But I would like to reiterate that this is solely my personal opinion. My point was that macros are hard to handle when it comes to refactoring because the way (which is kind of old-school) that they can replace literally any part of the code. 
Regarding the example in the first topic:
quote: You can have a ";" in a define or not.
We meant ; in the actual usage, not in the macro itself:
#define test
test;
template< typename T >
T foo( T p ){ return T ;}
This way it will be C++-like, so VA can clearly see where one part ends and where the another begins. Sorry for this inconvenience. Personally, I always use a ; at the end of my macros so they're "refactoring compatible". |
Edited by - accord on Jun 15 2012 11:34:47 AM |
 |
|
|
Topic  |
|