|
From: <net...@us...> - 2003-12-19 20:14:43
|
Update of /cvsroot/cpptool/rfta/src/rfta
In directory sc8-pr-cvs1:/tmp/cvs-serv28910/rfta/src/rfta
Modified Files:
SplitTempRefactoring.cpp SplitTempRefactoringTest.cpp
SplitTempRefactoringTest.h
Log Message:
-- added preprocessor support + test
Index: SplitTempRefactoring.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SplitTempRefactoring.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** SplitTempRefactoring.cpp 16 Dec 2003 13:43:34 -0000 1.9
--- SplitTempRefactoring.cpp 19 Dec 2003 20:14:39 -0000 1.10
***************
*** 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,17 ----
#include "IdentifierResolverContext.h"
#include "ReplaceTextTransform.h"
! #include "PreProcessTransform.h"
! #include <rfta/parser/MacroReplaceRegistration.h>
#include <rfta/parser/MaxLODMutator.h>
! #include <rfta/parser/PreProcessor.h>
#include <rfta/parser/ParseContext.h>
#include <rfta/parser/ParserError.h>
***************
*** 48,55 ****
throw RefactoringError( RefactoringError::selectionNotInSource );
! PPDirectiveListenerPtr nullListener(new NullPPDirectiveListener());
! std::string blankedSource;
! NonSemanticBlanker blanker( source, blankedSource, nullListener );
! blanker.blank();
int compoundStartIndex =
--- 49,68 ----
throw RefactoringError( RefactoringError::selectionNotInSource );
! // preprocess
! PreProcessor proc( source );
! MacroReplaceRegistration registration;
! std::string blankedSource = proc.process(registration);
! registration.finishUpData();
!
! // correct pointer to location after preprocessing
! temporaryLocation_ -= registration.getReplacementDeltaBefore(SourceRange( temporaryLocation_, 1 ));
!
! // store macro replacement information
! 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 compoundStartIndex =
***************
*** 87,91 ****
const std::string &newTemporaryName )
{
- TransformList transforms;
/*ScopesHolder scopes( sourceNode_ );
--- 100,103 ----
***************
*** 117,121 ****
sourceNode_->getBlankedTextFor(variableTypePtr->getRange());
SourceRange nullRange(range.getStartIndex(), 0);
! transforms.add( *new ReplaceTextTransform( nullRange,
variableType ) );
break;
--- 129,133 ----
sourceNode_->getBlankedTextFor(variableTypePtr->getRange());
SourceRange nullRange(range.getStartIndex(), 0);
! transforms_.add( *new ReplaceTextTransform( nullRange,
variableType ) );
break;
***************
*** 123,131 ****
}
! transforms.add( *new ReplaceTextTransform( range,
newTemporaryName ) );
}
! transforms.apply( getDocument() );
}
--- 135,143 ----
}
! transforms_.add( *new ReplaceTextTransform( range,
newTemporaryName ) );
}
! transforms_.apply( getDocument() );
}
Index: SplitTempRefactoringTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SplitTempRefactoringTest.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SplitTempRefactoringTest.cpp 22 Dec 2002 15:47:34 -0000 1.3
--- SplitTempRefactoringTest.cpp 19 Dec 2003 20:14:39 -0000 1.4
***************
*** 77,80 ****
--- 77,109 ----
}
+ void
+ SplitTempRefactoringTest::testMacroAppearance()
+ {
+ builder_->add(
+ "#define TEXT int y=1;\n"
+ "{"
+ " TEXT\n"
+ " double x = getPrice();" );
+ builder_->addKeyingMid( " doSomething( ", "x", " );", "selection" );
+ builder_->add(
+ " x = getNewPrice();"
+ " doSomething( x );"
+ "}" );
+
+ applyRefactoring( "price" );
+
+ std::string expectedSource(
+ "#define TEXT int y=1;\n"
+ "{"
+ " TEXT\n"
+ " double price = getPrice();"
+ " doSomething( price );"
+ " double x = getNewPrice();"
+ " doSomething( x );"
+ "}" );
+ std::string actualSource( document_->getAllText() );
+ RFTA_ASSERT_EQUAL( expectedSource, actualSource );
+ }
+
Index: SplitTempRefactoringTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SplitTempRefactoringTest.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SplitTempRefactoringTest.h 13 Dec 2002 15:28:23 -0000 1.1
--- SplitTempRefactoringTest.h 19 Dec 2003 20:14:39 -0000 1.2
***************
*** 20,23 ****
--- 20,24 ----
CPPUNIT_TEST_SUITE( SplitTempRefactoringTest );
CPPUNIT_TEST( testEasiestCase );
+ CPPUNIT_TEST( testMacroAppearance );
CPPUNIT_TEST_SUITE_END();
***************
*** 34,37 ****
--- 35,39 ----
void testEasiestCase();
+ void testMacroAppearance();
private:
|