|
From: <net...@us...> - 2003-12-19 20:14:30
|
Update of /cvsroot/cpptool/rfta/src/rfta
In directory sc8-pr-cvs1:/tmp/cvs-serv28824/rfta/src/rfta
Modified Files:
SplitDeclarationRefactoring.cpp
SplitDeclarationRefactoringTest.cpp
SplitDeclarationRefactoringTest.h
Log Message:
-- added preprocessor support + test
Index: SplitDeclarationRefactoring.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SplitDeclarationRefactoring.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SplitDeclarationRefactoring.cpp 16 Dec 2003 13:43:34 -0000 1.4
--- SplitDeclarationRefactoring.cpp 19 Dec 2003 20:14:27 -0000 1.5
***************
*** 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,18 ----
#include "IdentifierResolverContext.h"
#include "ReplaceTextTransform.h"
+ #include "PreProcessTransform.h"
#include "TransformList.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>
***************
*** 53,60 ****
throw RefactoringError( RefactoringError::selectionNotInSource );
! PPDirectiveListenerPtr nullListener(new NullPPDirectiveListener());
! std::string blankedSource;
! NonSemanticBlanker blanker( source, blankedSource, nullListener );
! blanker.blank();
int compoundStartIndex =
--- 55,74 ----
throw RefactoringError( RefactoringError::selectionNotInSource );
! // preprocess
! PreProcessor proc( source );
! MacroReplaceRegistration registration;
! std::string blankedSource = proc.process(registration);
! registration.finishUpData();
!
! // correct pointer to location after preprocessing
! declarationLocation_ -= registration.getReplacementDeltaBefore(SourceRange( declarationLocation_, 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 =
***************
*** 139,143 ****
std::string source( getDocument().getAllText());
CodeModel::CodeRewriter writer(source, 2);
! writer.rewrite(compound, getDocument());
}
--- 153,157 ----
std::string source( getDocument().getAllText());
CodeModel::CodeRewriter writer(source, 2);
! writer.rewrite(compound, transforms_, getDocument());
}
Index: SplitDeclarationRefactoringTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SplitDeclarationRefactoringTest.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SplitDeclarationRefactoringTest.cpp 25 Apr 2003 07:53:26 -0000 1.3
--- SplitDeclarationRefactoringTest.cpp 19 Dec 2003 20:14:27 -0000 1.4
***************
*** 185,188 ****
--- 185,209 ----
}
+ void
+ SplitDeclarationRefactoringTest::testMacroUse()
+ {
+ builder_->add("#define D double z;\n");
+ builder_->add("{\n");
+ builder_->add(" D\n");
+ builder_->addKeyingMid(" double ", "x", ", y;\n", "selection");
+ builder_->add("}\n");
+ applyRefactoring( );
+
+ std::string expectedSource(
+ "#define D double z;\n"
+ "{\n"
+ " D\n"
+ " double x;\n"
+ " double y;\n"
+ "}\n" );
+ std::string actualSource( document_->getAllText() );
+ RFTA_ASSERT_EQUAL( expectedSource, actualSource );
+ }
+
} // namespace Refactoring
Index: SplitDeclarationRefactoringTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SplitDeclarationRefactoringTest.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SplitDeclarationRefactoringTest.h 25 Apr 2003 07:53:26 -0000 1.3
--- SplitDeclarationRefactoringTest.h 19 Dec 2003 20:14:27 -0000 1.4
***************
*** 25,28 ****
--- 25,29 ----
CPPUNIT_TEST( testInitializers );
CPPUNIT_TEST( testSubscope );
+ CPPUNIT_TEST( testMacroUse );
// CPPUNIT_TEST( testForDeclerations );
CPPUNIT_TEST_SUITE_END();
***************
*** 46,49 ****
--- 47,51 ----
void testSubscope();
void testForDeclerations();
+ void testMacroUse();
private:
|