|
From: <net...@us...> - 2003-12-16 13:26:16
|
Update of /cvsroot/cpptool/rfta/src/rfta
In directory sc8-pr-cvs1:/tmp/cvs-serv25341/rfta/src/rfta
Modified Files:
RenameTempRefactoring.cpp RenameTempRefactoringTest.cpp
Log Message:
-- added preprocessor implementation
-- tests Macro usage
Index: RenameTempRefactoring.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/RenameTempRefactoring.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** RenameTempRefactoring.cpp 24 Aug 2003 21:00:37 -0000 1.17
--- RenameTempRefactoring.cpp 16 Dec 2003 13:26:10 -0000 1.18
***************
*** 10,16 ****
#include "IdentifierResolverContext.h"
#include "ReplaceTextTransform.h"
! #include "TransformList.h"
#include <rfta/parser/MaxLODMutator.h>
! #include <rfta/parser/NonSemanticBlanker.h>
#include <rfta/parser/ParseContext.h>
#include <rfta/parser/ParserError.h>
--- 10,16 ----
#include "IdentifierResolverContext.h"
#include "ReplaceTextTransform.h"
! #include "PreProcessTransform.h"
#include <rfta/parser/MaxLODMutator.h>
! #include <rfta/parser/PreProcessor.h>
#include <rfta/parser/ParseContext.h>
#include <rfta/parser/ParserError.h>
***************
*** 21,24 ****
--- 21,25 ----
#include <rfta/refactoring/RefactoringError.h>
#include <rfta/refactoring/TextDocument.h>
+ #include <rfta/parser/MacroReplaceRegistration.h>
***************
*** 66,74 ****
if ( temporaryLocation_ >= source.length() )
throw RefactoringError( RefactoringError::selectionNotInSource );
! NullPPDirectiveListener nullListener;
! std::string blankedSource;
! NonSemanticBlanker blanker( source, blankedSource, nullListener );
! blanker.blank();
int start_at = temporaryLocation_;
--- 67,85 ----
if ( temporaryLocation_ >= source.length() )
throw RefactoringError( RefactoringError::selectionNotInSource );
+
+ PreProcessor proc( source );
+ MacroReplaceRegistration registration;
+ std::string blankedSource = proc.process(registration);
+ registration.finishUpData();
! // fix source offset after preprocessing (macros might have moved the position)
! temporaryLocation_ -= registration.getReplacementDeltaBefore(SourceRange( temporaryLocation_, 1 ));
!
! int idx;
! for (idx=0; idx < registration.getSize(); idx++)
! {
! MacroReplaceRegistration::MacroReplacement entry = registration.getEntry(idx);
! transforms_.add( *new PreProcessTransform( entry.position_, entry.macroText_.size() - entry.replacement_.size() ) );
! }
int start_at = temporaryLocation_;
***************
*** 130,134 ****
RenameTempRefactoring::apply( const std::string &newTemporaryName )
{
- TransformList transforms;
for ( ToolsBox::ASTNodes::const_iterator it = occurrences_.begin();
it != occurrences_.end();
--- 141,144 ----
***************
*** 136,144 ****
{
SourceRange range = (*it)->getRange();
! transforms.add( *new ReplaceTextTransform( range,
newTemporaryName ) );
}
! transforms.apply( getDocument() );
}
--- 146,154 ----
{
SourceRange range = (*it)->getRange();
! transforms_.add( *new ReplaceTextTransform( range,
newTemporaryName ) );
}
! transforms_.apply( getDocument() );
}
***************
*** 168,171 ****
--- 178,190 ----
context,
occurrences_ );
+ // check all text replacements for overlapping with MACRO replacements:
+ for ( ToolsBox::ASTNodes::const_iterator it = occurrences_.begin();
+ it != occurrences_.end();
+ ++it )
+ {
+ const SourceRange& range = (*it)->getRange();
+ if (transforms_.hasOverlapping(range))
+ throw RefactoringError( RefactoringError::unableToRefactoreBecauseOfMacros );
+ }
}
catch ( NotLocalVariableIdentifierError & )
Index: RenameTempRefactoringTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/RenameTempRefactoringTest.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** RenameTempRefactoringTest.cpp 10 May 2003 10:55:14 -0000 1.16
--- RenameTempRefactoringTest.cpp 16 Dec 2003 13:26:10 -0000 1.17
***************
*** 59,64 ****
{
builder_->add(
"{"
! " double x = getPrice();" );
builder_->addKeyingMid( " ", "x", " += x * rate;", "selection" );
builder_->add(
--- 59,65 ----
{
builder_->add(
+ "#define DBL double\n"
"{"
! " DBL x = getPrice();" );
builder_->addKeyingMid( " ", "x", " += x * rate;", "selection" );
builder_->add(
***************
*** 69,74 ****
std::string expectedSource(
"{"
! " double price = getPrice();"
" price += price * rate;"
" return price * getQuantity();"
--- 70,76 ----
std::string expectedSource(
+ "#define DBL double\n"
"{"
! " DBL price = getPrice();"
" price += price * rate;"
" return price * getQuantity();"
|