Update of /cvsroot/cpptool/rfta/src/rfta
In directory sc8-pr-cvs1:/tmp/cvs-serv10043/rfta
Modified Files:
ReduceTempScopeRefactoringTest.h Transform.h
ReduceTempScopeRefactoringTest.cpp SplitTempRefactoringTest.h
InlineTempRefactoringTest.h ReduceTempScopeRefactoring.cpp
RefactoringBase.cpp SplitDeclarationRefactoringTest.cpp
SplitDeclarationRefactoringTest.h SplitTempRefactoringTest.cpp
CodeWriterTestBase.h InlineTempRefactoringTest.cpp
TransformListTest.h ReplaceTextTransform.cpp
ReplaceTextTransform.h MockTextDocument.h TransformList.cpp
IndentLevelManager.cpp SourceBasedTestBase.h
CodeWriterTestBase.cpp RenameTempRefactoringTest.h
SplitTempRefactoring.cpp InlineTempRefactoring.cpp
IndentLevelManager.h RenameTempRefactoringTest.cpp
RenameTempRefactoring.cpp CodeWriterTest.cpp CodeRewriter.cpp
Log Message:
-- integrated preprocessor (replaced all NonSemanticBlanker)
Index: ReduceTempScopeRefactoringTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/ReduceTempScopeRefactoringTest.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ReduceTempScopeRefactoringTest.h 21 Dec 2002 14:40:41 -0000 1.1
--- ReduceTempScopeRefactoringTest.h 13 Jan 2004 22:27:35 -0000 1.2
***************
*** 7,11 ****
#include "SourceBasedTestBase.h"
!
namespace Refactoring
--- 7,11 ----
#include "SourceBasedTestBase.h"
! #include <rfta/test/SourceManagerMock.h>
namespace Refactoring
***************
*** 37,41 ****
void applyRefactoring();
! boost::shared_ptr<PlainTextDocument> document_;
};
--- 37,42 ----
void applyRefactoring();
! Testing::SourceManagerMock sourceMngMock_;
! SourcePtr sourceDoc_;
};
Index: Transform.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/Transform.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Transform.h 16 Dec 2003 13:47:00 -0000 1.1
--- Transform.h 13 Jan 2004 22:27:35 -0000 1.2
***************
*** 8,11 ****
--- 8,12 ----
#include <rfta/refactoring/Config.h>
+ #include <boost/shared_ptr.hpp>
namespace Refactoring
***************
*** 13,16 ****
--- 14,19 ----
class TextDocument;
+ class Source;
+ typedef boost::shared_ptr<Source> SourcePtr;
***************
*** 31,34 ****
--- 34,42 ----
virtual int apply( TextDocument &document ) const = 0;
+ /**
+ * does the text transformation and returns the delta-length
+ */
+ virtual int apply( SourcePtr pSource ) const = 0;
+
virtual void moveStartIndexBy( int delta ) = 0;
Index: ReduceTempScopeRefactoringTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/ReduceTempScopeRefactoringTest.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ReduceTempScopeRefactoringTest.cpp 22 Dec 2002 15:47:34 -0000 1.2
--- ReduceTempScopeRefactoringTest.cpp 13 Jan 2004 22:27:35 -0000 1.3
***************
*** 6,11 ****
#include "stdafx.h"
#include "ReduceTempScopeRefactoringTest.h"
! #include <rfta/refactoring/PlainTextDocument.h>
#include <rfta/refactoring/ReduceTempScopeRefactoring.h>
--- 6,12 ----
#include "stdafx.h"
#include "ReduceTempScopeRefactoringTest.h"
! #include <rfta/parser/PlainTextDocument.h>
#include <rfta/refactoring/ReduceTempScopeRefactoring.h>
+ #include <rfta/parser/Source.h>
***************
*** 43,49 ****
ReduceTempScopeRefactoringTest::applyRefactoring()
{
! document_.reset( new PlainTextDocument( source_ ) );
int selectionIndex = builder_->getStartIndex( "selection" );
! ReduceTempScopeRefactoring refactoring( *document_,
selectionIndex );
refactoring.apply();
--- 44,51 ----
ReduceTempScopeRefactoringTest::applyRefactoring()
{
! sourceDoc_ = SourcePtr( new Source( TextDocumentPtr(new PlainTextDocument( source_ ) ) ) );
int selectionIndex = builder_->getStartIndex( "selection" );
! ReduceTempScopeRefactoring refactoring( sourceDoc_,
! sourceMngMock_,
selectionIndex );
refactoring.apply();
***************
*** 71,75 ****
" }"
"}";
! std::string actualSource( document_->getAllText() );
// RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 73,77 ----
" }"
"}";
! std::string actualSource( sourceDoc_->getOriginalText() );
// RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
Index: SplitTempRefactoringTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SplitTempRefactoringTest.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SplitTempRefactoringTest.h 19 Dec 2003 20:14:39 -0000 1.2
--- SplitTempRefactoringTest.h 13 Jan 2004 22:27:35 -0000 1.3
***************
*** 7,11 ****
#include "SourceBasedTestBase.h"
!
namespace Refactoring
--- 7,11 ----
#include "SourceBasedTestBase.h"
! #include <rfta/test/SourceManagerMock.h>
namespace Refactoring
***************
*** 40,44 ****
void applyRefactoring( const std::string &newTemporaryName );
! boost::shared_ptr<PlainTextDocument> document_;
};
--- 40,44 ----
void applyRefactoring( const std::string &newTemporaryName );
! Testing::SourceManagerMock sourceMngMock_;
};
Index: InlineTempRefactoringTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/InlineTempRefactoringTest.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** InlineTempRefactoringTest.h 5 Apr 2003 12:13:36 -0000 1.3
--- InlineTempRefactoringTest.h 13 Jan 2004 22:27:35 -0000 1.4
***************
*** 8,11 ****
--- 8,12 ----
#include "SourceBasedTestBase.h"
#include <rfta/refactoring/RefactoringError.h>
+ #include <rfta/test/SourceManagerMock.h>
namespace Refactoring
***************
*** 72,76 ****
void applyRefactoringNoThrow ( const std::string &assignment , const std::string &LocaleVariableName , const CppUnit::SourceLine &sourceLine );
! boost::shared_ptr<PlainTextDocument> document_;
};
--- 73,79 ----
void applyRefactoringNoThrow ( const std::string &assignment , const std::string &LocaleVariableName , const CppUnit::SourceLine &sourceLine );
! //boost::shared_ptr<PlainTextDocument> document_;
! SourcePtr sourceDoc_;
! Testing::SourceManagerMock sourceMngMock_;
};
Index: ReduceTempScopeRefactoring.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/ReduceTempScopeRefactoring.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ReduceTempScopeRefactoring.cpp 22 Dec 2002 15:47:34 -0000 1.3
--- ReduceTempScopeRefactoring.cpp 13 Jan 2004 22:27:35 -0000 1.4
***************
*** 13,19 ****
ReduceTempScopeRefactoring::ReduceTempScopeRefactoring(
! TextDocument &document,
int localeVariableLocation )
! : RefactoringBase( document )
, localeVariableLocation_( localeVariableLocation )
{
--- 13,20 ----
ReduceTempScopeRefactoring::ReduceTempScopeRefactoring(
! SourcePtr source,
! SourceManager& manager,
int localeVariableLocation )
! : RefactoringBase( source, manager )
, localeVariableLocation_( localeVariableLocation )
{
Index: RefactoringBase.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/RefactoringBase.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** RefactoringBase.cpp 22 Dec 2002 16:03:52 -0000 1.4
--- RefactoringBase.cpp 13 Jan 2004 22:27:35 -0000 1.5
***************
*** 9,18 ****
#include <rfta/refactoring/RefactoringBase.h>
#include <rfta/parser/SourceRange.h>
namespace Refactoring{
! RefactoringBase::RefactoringBase( TextDocument& document )
! : baseDocument_( document )
{
}
--- 9,20 ----
#include <rfta/refactoring/RefactoringBase.h>
#include <rfta/parser/SourceRange.h>
+ #include <rfta/parser/Source.h>
namespace Refactoring{
! RefactoringBase::RefactoringBase( SourcePtr source, SourceManager& manager )
! : source_( source )
! , manager_( manager )
{
}
***************
*** 27,31 ****
RefactoringBase::getDocument()
{
! return baseDocument_;
}
--- 29,33 ----
RefactoringBase::getDocument()
{
! return *(source_->getTextDocument());
}
Index: SplitDeclarationRefactoringTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SplitDeclarationRefactoringTest.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SplitDeclarationRefactoringTest.cpp 19 Dec 2003 20:14:27 -0000 1.4
--- SplitDeclarationRefactoringTest.cpp 13 Jan 2004 22:27:35 -0000 1.5
***************
*** 7,11 ****
#include "SplitDeclarationRefactoringTest.h"
#include <rfta/refactoring/SplitDeclarationRefactoring.h>
! #include <rfta/refactoring/PlainTextDocument.h>
--- 7,12 ----
#include "SplitDeclarationRefactoringTest.h"
#include <rfta/refactoring/SplitDeclarationRefactoring.h>
! #include <rfta/parser/PlainTextDocument.h>
! #include <rfta/parser/Source.h>
***************
*** 36,40 ****
SplitDeclarationRefactoringTest::tearDown()
{
- document_.reset();
SourceBasedTestBase::tearDown();
}
--- 37,40 ----
***************
*** 44,50 ****
SplitDeclarationRefactoringTest::applyRefactoring( )
{
! document_.reset( new PlainTextDocument( source_ ) );
int selectionIndex = builder_->getStartIndex( "selection" );
! SplitDeclarationRefactoring refactoring( *document_,
selectionIndex );
refactoring.apply( );
--- 44,52 ----
SplitDeclarationRefactoringTest::applyRefactoring( )
{
! sourceDoc_ = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source_ ) ) ) );
!
int selectionIndex = builder_->getStartIndex( "selection" );
! SplitDeclarationRefactoring refactoring( sourceDoc_,
! sourceMngMock_,
selectionIndex );
refactoring.apply( );
***************
*** 65,69 ****
" double y;\n"
"}\n" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 67,71 ----
" double y;\n"
"}\n" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 83,87 ****
" double &z;\n"
"}\n" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 85,89 ----
" double &z;\n"
"}\n" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 101,105 ****
" double&z;\n"
"}\n" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 103,107 ----
" double&z;\n"
"}\n" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 121,125 ****
" bool n, m;\n"
"}\n");
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
--- 123,127 ----
" bool n, m;\n"
"}\n");
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
***************
*** 138,142 ****
" int y(2);\n"
"}\n");
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 140,144 ----
" int y(2);\n"
"}\n");
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 161,165 ****
" }\n"
"}\n");
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
--- 163,167 ----
" }\n"
"}\n");
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
***************
*** 181,185 ****
" ;\n"
"}\n");
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 183,187 ----
" ;\n"
"}\n");
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 202,206 ****
" double y;\n"
"}\n" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 204,208 ----
" double y;\n"
"}\n" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
Index: SplitDeclarationRefactoringTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SplitDeclarationRefactoringTest.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SplitDeclarationRefactoringTest.h 19 Dec 2003 20:14:27 -0000 1.4
--- SplitDeclarationRefactoringTest.h 13 Jan 2004 22:27:35 -0000 1.5
***************
*** 7,11 ****
#include "SourceBasedTestBase.h"
!
namespace Refactoring
--- 7,11 ----
#include "SourceBasedTestBase.h"
! #include <rfta/test/SourceManagerMock.h>
namespace Refactoring
***************
*** 52,56 ****
void applyRefactoring( );
! boost::shared_ptr<PlainTextDocument> document_;
};
--- 52,57 ----
void applyRefactoring( );
! Testing::SourceManagerMock sourceMngMock_;
! SourcePtr sourceDoc_;
};
Index: SplitTempRefactoringTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SplitTempRefactoringTest.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SplitTempRefactoringTest.cpp 19 Dec 2003 20:14:39 -0000 1.4
--- SplitTempRefactoringTest.cpp 13 Jan 2004 22:27:35 -0000 1.5
***************
*** 7,11 ****
#include "SplitTempRefactoringTest.h"
#include <rfta/refactoring/SplitTempRefactoring.h>
! #include <rfta/refactoring/PlainTextDocument.h>
--- 7,12 ----
#include "SplitTempRefactoringTest.h"
#include <rfta/refactoring/SplitTempRefactoring.h>
! #include <rfta/parser/PlainTextDocument.h>
! #include <rfta/parser/Source.h>
***************
*** 35,40 ****
void
SplitTempRefactoringTest::tearDown()
! {
! document_.reset();
SourceBasedTestBase::tearDown();
}
--- 36,40 ----
void
SplitTempRefactoringTest::tearDown()
! {
SourceBasedTestBase::tearDown();
}
***************
*** 44,50 ****
SplitTempRefactoringTest::applyRefactoring( const std::string &newTemporaryName )
{
! document_.reset( new PlainTextDocument( source_ ) );
int selectionIndex = builder_->getStartIndex( "selection" );
! SplitTempRefactoring refactoring( *document_,
selectionIndex );
refactoring.apply( newTemporaryName );
--- 44,52 ----
SplitTempRefactoringTest::applyRefactoring( const std::string &newTemporaryName )
{
! sourceDoc_ = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source_ ) ) ) );
!
int selectionIndex = builder_->getStartIndex( "selection" );
! SplitTempRefactoring refactoring( sourceDoc_,
! sourceMngMock_,
selectionIndex );
refactoring.apply( newTemporaryName );
***************
*** 73,77 ****
" doSomething( x );"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 75,79 ----
" doSomething( x );"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 102,106 ****
" doSomething( x );"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 104,108 ----
" doSomething( x );"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
Index: CodeWriterTestBase.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTestBase.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CodeWriterTestBase.h 6 Apr 2003 18:06:59 -0000 1.5
--- CodeWriterTestBase.h 13 Jan 2004 22:27:35 -0000 1.6
***************
*** 8,12 ****
#include <rfta/refactoring/CodeModelStatements.h>
#include <rfta/refactoring/CodeModelExpressions.h>
! #include <rfta/refactoring/PlainTextDocument.h>
#include "CodeRewriter.h"
#include "SourceBasedTestBase.h"
--- 8,12 ----
#include <rfta/refactoring/CodeModelStatements.h>
#include <rfta/refactoring/CodeModelExpressions.h>
! #include <rfta/parser/PlainTextDocument.h>
#include "CodeRewriter.h"
#include "SourceBasedTestBase.h"
***************
*** 42,47 ****
void generateAndCheckSource( const std::string &expectedSource );
! CodeModel::CompoundStatementPtr compound_;
! boost::shared_ptr<PlainTextDocument> document_;
boost::shared_ptr<CodeModel::CodeRewriter> writer_;
};
--- 42,46 ----
void generateAndCheckSource( const std::string &expectedSource );
! CodeModel::CompoundStatementPtr compound_;
boost::shared_ptr<CodeModel::CodeRewriter> writer_;
};
Index: InlineTempRefactoringTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/InlineTempRefactoringTest.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** InlineTempRefactoringTest.cpp 6 Apr 2003 16:17:19 -0000 1.5
--- InlineTempRefactoringTest.cpp 13 Jan 2004 22:27:35 -0000 1.6
***************
*** 7,11 ****
#include "InlineTempRefactoringTest.h"
#include <rfta/refactoring/InlineTempRefactoring.h>
! #include <rfta/refactoring/PlainTextDocument.h>
--- 7,12 ----
#include "InlineTempRefactoringTest.h"
#include <rfta/refactoring/InlineTempRefactoring.h>
! #include <rfta/parser/PlainTextDocument.h>
! #include <rfta/parser/Source.h>
***************
*** 36,40 ****
InlineTempRefactoringTest::tearDown()
{
! document_.reset();
SourceBasedTestBase::tearDown();
}
--- 37,41 ----
InlineTempRefactoringTest::tearDown()
{
! sourceDoc_->getTextDocument().reset();
SourceBasedTestBase::tearDown();
}
***************
*** 46,52 ****
InlineTempRefactoringTest::applyRefactoring( const std::string &LocaleVariableName )
{
! document_.reset( new PlainTextDocument( source_ ) );
int selectionIndex = builder_->getStartIndex( "selection" );
! InlineTempRefactoring refactoring( *document_,
selectionIndex );
refactoring.apply( refactoring.areBracesSuggested() );
--- 47,55 ----
InlineTempRefactoringTest::applyRefactoring( const std::string &LocaleVariableName )
{
! TextDocumentPtr document(new PlainTextDocument( source_ ));
! sourceDoc_ = SourcePtr( new Source(document) );
int selectionIndex = builder_->getStartIndex( "selection" );
! InlineTempRefactoring refactoring( sourceDoc_,
! sourceMngMock_,
selectionIndex );
refactoring.apply( refactoring.areBracesSuggested() );
***************
*** 65,72 ****
bool failed = true;
RefactoringError expected(_cause);
! document_.reset( new PlainTextDocument( source_ ) );
int selectionIndex = builder_->getStartIndex( "selection" );
try {
! InlineTempRefactoring refactoring( *document_,
selectionIndex );
refactoring.apply( refactoring.areBracesSuggested() );
--- 68,79 ----
bool failed = true;
RefactoringError expected(_cause);
!
! TextDocumentPtr document(new PlainTextDocument( source_ ));
! sourceDoc_ = SourcePtr( new Source(document) );
!
int selectionIndex = builder_->getStartIndex( "selection" );
try {
! InlineTempRefactoring refactoring( sourceDoc_,
! sourceMngMock_,
selectionIndex );
refactoring.apply( refactoring.areBracesSuggested() );
***************
*** 137,141 ****
" return 4 * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 144,148 ----
" return 4 * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 160,164 ****
" return 4 * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 167,171 ----
" return 4 * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 241,245 ****
" return 4 * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 248,252 ----
" return 4 * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 265,269 ****
" return 4 * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 272,276 ----
" return 4 * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 289,293 ****
" return 4 * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 296,300 ----
" return 4 * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 313,317 ****
" return ( 4 + 3 ) * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 320,324 ----
" return ( 4 + 3 ) * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 337,341 ****
" return 4 * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 344,348 ----
" return 4 * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
Index: TransformListTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/TransformListTest.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TransformListTest.h 20 Dec 2003 08:59:50 -0000 1.5
--- TransformListTest.h 13 Jan 2004 22:27:35 -0000 1.6
***************
*** 8,14 ****
#include "MockTextDocument.h"
#include "ReplaceTextTransform.h"
- #include <rfta/refactoring/TransformList.h>
#include "UnitTesting.h"
#include <boost/shared_ptr.hpp>
--- 8,14 ----
#include "MockTextDocument.h"
#include "ReplaceTextTransform.h"
#include "UnitTesting.h"
#include <boost/shared_ptr.hpp>
+ #include <rfta/refactoring/TransformList.h>
Index: ReplaceTextTransform.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/ReplaceTextTransform.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ReplaceTextTransform.cpp 16 May 2003 19:55:02 -0000 1.6
--- ReplaceTextTransform.cpp 13 Jan 2004 22:27:35 -0000 1.7
***************
*** 6,10 ****
#include "stdafx.h"
#include "ReplaceTextTransform.h"
! #include <rfta/refactoring/TextDocument.h>
--- 6,11 ----
#include "stdafx.h"
#include "ReplaceTextTransform.h"
! #include <rfta/parser/TextDocument.h>
! #include <rfta/parser/Source.h>
***************
*** 35,38 ****
--- 36,51 ----
}
+ int
+ ReplaceTextTransform::apply( SourcePtr pSource ) const
+ {
+ Source& where = pSource->getSourceOrigin(range_);
+ SourceRange r = pSource->getRangeOrigin(range_);
+
+ int lengthDelta = text_.length() - range_.getLength();
+ where.getTextDocument()->replaceTextRange( r, text_ );
+
+ return lengthDelta;
+ }
+
void
Index: ReplaceTextTransform.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/ReplaceTextTransform.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ReplaceTextTransform.h 16 Dec 2003 13:27:29 -0000 1.6
--- ReplaceTextTransform.h 13 Jan 2004 22:27:35 -0000 1.7
***************
*** 32,35 ****
--- 32,37 ----
int apply( TextDocument &document ) const;
+ int apply( SourcePtr pSource ) const;
+
void moveStartIndexBy( int delta );
Index: MockTextDocument.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/MockTextDocument.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** MockTextDocument.h 16 May 2003 19:55:02 -0000 1.7
--- MockTextDocument.h 13 Jan 2004 22:27:35 -0000 1.8
***************
*** 8,12 ****
#include <boost/utility.hpp>
#include <mock/Expectations.h>
! #include <rfta/refactoring/TextDocument.h>
#include <deque>
--- 8,12 ----
#include <boost/utility.hpp>
#include <mock/Expectations.h>
! #include <rfta/parser/TextDocument.h>
#include <deque>
Index: TransformList.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/TransformList.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** TransformList.cpp 20 Dec 2003 08:59:50 -0000 1.7
--- TransformList.cpp 13 Jan 2004 22:27:35 -0000 1.8
***************
*** 7,12 ****
#include "stdafx.h"
#include "ReplaceTextTransform.h"
- #include <rfta/refactoring/TransformList.h>
#include <rfta/parser/SourceRange.h>
#include <algorithm>
--- 7,12 ----
#include "stdafx.h"
#include "ReplaceTextTransform.h"
#include <rfta/parser/SourceRange.h>
+ #include <rfta/refactoring/TransformList.h>
#include <algorithm>
***************
*** 63,66 ****
--- 63,82 ----
}
+ void
+ TransformList::apply( SourcePtr pSource )
+ {
+ sortListByStartIndex();
+
+ int totalDelta = 0;
+ while ( !transforms_.empty() )
+ {
+ TransformPtr transform = transforms_.front();
+ transforms_.pop_front();
+
+ transform->moveStartIndexBy( totalDelta );
+ totalDelta += transform->apply( pSource );
+ }
+ }
+
struct TransformList::SortPredicate
Index: IndentLevelManager.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/IndentLevelManager.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** IndentLevelManager.cpp 18 Mar 2003 22:37:51 -0000 1.9
--- IndentLevelManager.cpp 13 Jan 2004 22:27:35 -0000 1.10
***************
*** 13,20 ****
! IndentLevelManager::IndentLevelManager( const std::string &originalSource,
int indentWidth )
! : originalSource_( originalSource )
! , indentWidth_( indentWidth )
{
}
--- 13,20 ----
! IndentLevelManager::IndentLevelManager( SourcePtr source,
int indentWidth )
! : indentWidth_( indentWidth )
! , source_( source )
{
}
***************
*** 123,128 ****
{
int indent = 0;
! while ( --pos >= 0 && originalSource_[pos] != '\n' )
++indent;
return indent;
}
--- 123,132 ----
{
int indent = 0;
! SourceRange r(pos,1);r.moveStartIndexBy(-1);
! while ( r.getStartIndex() >= 0 && source_->getOriginalText(r)[0] != '\n' )
! {
++indent;
+ r.moveStartIndexBy(-1);
+ }
return indent;
}
Index: SourceBasedTestBase.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SourceBasedTestBase.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** SourceBasedTestBase.h 16 Dec 2003 13:32:45 -0000 1.9
--- SourceBasedTestBase.h 13 Jan 2004 22:27:35 -0000 1.10
***************
*** 11,17 ****
#include <rfta/parser/SourceASTNode.h>
#include <rfta/test/SourceBuilder.h>
#include <rfta/parser/ParseContext.h>
#include <rfta/parser/MaxLODMutator.h>
! #include <rfta/parser/NonSemanticBlanker.h>
namespace Refactoring
--- 11,19 ----
#include <rfta/parser/SourceASTNode.h>
#include <rfta/test/SourceBuilder.h>
+ #include <rfta/test/SourceManagerMock.h>
#include <rfta/parser/ParseContext.h>
#include <rfta/parser/MaxLODMutator.h>
! #include <rfta/parser/Preprocessor.h>
! #include <rfta/parser/PreprocessorContext.h>
namespace Refactoring
***************
*** 39,42 ****
--- 41,46 ----
ASTNodePtr getVariableNode( const std::string &variableRangeKey );
+ SourcePtr sourceDoc_;
+ Testing::SourceManagerMock sourceMngMock_;
std::string source_;
SourceASTNodePtr sourceNode_;
***************
*** 46,50 ****
void parse(ParserType*)
{
! sourceNode_ = SourceASTNode::create( source_, source_ );
ParseContext context( sourceNode_ );
ParserType parser( context,
--- 50,54 ----
void parse(ParserType*)
{
! sourceNode_ = SourceASTNode::create( source_, source_, sourceDoc_ );
ParseContext context( sourceNode_ );
ParserType parser( context,
***************
*** 61,70 ****
void blankAndParse(ParserType*)
{
! std::string blankedSource;
! PPDirectiveListenerPtr nullListener(new NullPPDirectiveListener());
! NonSemanticBlanker blanker( source_, blankedSource, nullListener );
! blanker.blank();
! sourceNode_ = SourceASTNode::create( blankedSource, source_ );
ParseContext context( sourceNode_ );
ParserType parser( context,
--- 65,77 ----
void blankAndParse(ParserType*)
{
! if (sourceDoc_ == SourcePtr() )
! sourceDoc_ = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source_ ) ) ) );
! PreProcessorContext ppcontext( sourceMngMock_ );
! PreProcessor proc( sourceDoc_, ppcontext);
! proc.setOption(PreProcessor::skipIncludes); // TODO: disable this if preprocessor features can handle all system headers
! std::string blankedSource = proc.process();
!
! sourceNode_ = SourceASTNode::create( blankedSource, source_, sourceDoc_ );
ParseContext context( sourceNode_ );
ParserType parser( context,
Index: CodeWriterTestBase.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTestBase.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** CodeWriterTestBase.cpp 19 Dec 2003 20:12:05 -0000 1.10
--- CodeWriterTestBase.cpp 13 Jan 2004 22:27:35 -0000 1.11
***************
*** 8,11 ****
--- 8,12 ----
#include <rfta/refactoring/CodeModelGenerator.h>
#include <rfta/Parser/StatementsParser.h>
+ #include <rfta/parser/Source.h>
namespace Refactoring
***************
*** 17,21 ****
SourceBasedTestBase::setUp();
compound_.reset();
! document_.reset();
writer_.reset();
}
--- 18,22 ----
SourceBasedTestBase::setUp();
compound_.reset();
! sourceDoc_ = SourcePtr();
writer_.reset();
}
***************
*** 26,30 ****
{
writer_.reset();
! document_.reset();
compound_.reset();
SourceBasedTestBase::tearDown();
--- 27,31 ----
{
writer_.reset();
! sourceDoc_ = SourcePtr();
compound_.reset();
SourceBasedTestBase::tearDown();
***************
*** 41,45 ****
compound_ = generator.generateCompound( compoundNode );
- document_.reset( new PlainTextDocument( source_ ) );
}
--- 42,45 ----
***************
*** 48,53 ****
CodeWriterTestBase::rewriteSource()
{
! writer_.reset( new CodeModel::CodeRewriter( source_, 2 ) );
! writer_->rewrite( compound_, TransformList(), *document_ );
}
--- 48,53 ----
CodeWriterTestBase::rewriteSource()
{
! writer_.reset( new CodeModel::CodeRewriter( sourceDoc_, 2 ) );
! writer_->rewrite( compound_ );
}
***************
*** 99,103 ****
{
rewriteSource();
! RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() );
}
--- 99,103 ----
{
rewriteSource();
! RFTA_ASSERT_EQUAL( expectedSource, sourceDoc_->getOriginalText() );
}
Index: RenameTempRefactoringTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/RenameTempRefactoringTest.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** RenameTempRefactoringTest.h 10 May 2003 10:55:14 -0000 1.10
--- RenameTempRefactoringTest.h 13 Jan 2004 22:27:35 -0000 1.11
***************
*** 7,11 ****
#include "SourceBasedTestBase.h"
!
namespace Refactoring
--- 7,11 ----
#include "SourceBasedTestBase.h"
! #include <rfta/test/SourceManagerMock.h>
namespace Refactoring
***************
*** 55,59 ****
const std::string &oldLocaleVariableName );
! boost::shared_ptr<PlainTextDocument> document_;
};
--- 55,60 ----
const std::string &oldLocaleVariableName );
! Testing::SourceManagerMock sourceMngMock_;
! SourcePtr sourceDoc_;
};
Index: SplitTempRefactoring.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SplitTempRefactoring.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** SplitTempRefactoring.cpp 19 Dec 2003 20:14:39 -0000 1.10
--- SplitTempRefactoring.cpp 13 Jan 2004 22:27:35 -0000 1.11
***************
*** 10,15 ****
#include "IdentifierResolverContext.h"
#include "ReplaceTextTransform.h"
- #include "PreProcessTransform.h"
- #include <rfta/parser/MacroReplaceRegistration.h>
#include <rfta/parser/MaxLODMutator.h>
#include <rfta/parser/PreProcessor.h>
--- 10,13 ----
***************
*** 21,25 ****
#include <rfta/parser/ASTNodes.h>
#include <rfta/refactoring/RefactoringError.h>
! #include <rfta/refactoring/TextDocument.h>
--- 19,24 ----
#include <rfta/parser/ASTNodes.h>
#include <rfta/refactoring/RefactoringError.h>
! #include <rfta/parser/TextDocument.h>
! #include <rfta/parser/Source.h>
***************
*** 28,34 ****
! SplitTempRefactoring::SplitTempRefactoring( TextDocument &document,
int temporaryLocation )
! : RefactoringBase( document )
, temporaryLocation_( temporaryLocation )
{
--- 27,34 ----
! SplitTempRefactoring::SplitTempRefactoring( SourcePtr source,
! SourceManager &manager,
int temporaryLocation )
! : RefactoringBase( source, manager )
, temporaryLocation_( temporaryLocation )
{
***************
*** 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 =
--- 49,61 ----
throw RefactoringError( RefactoringError::selectionNotInSource );
! // preprocess
! PreProcessorContext preproc_context( getSourceManager() );
! PreProcessor proc( getSource(), preproc_context );
! proc.setOption(PreProcessor::skipIncludes); // TODO: disable this if preprocessor features can handle all system headers
! std::string blankedSource = proc.process();
! // correct pointer to location after preprocessing
! temporaryLocation_ = getSource()->getRangePreProcessed(SourceRange( temporaryLocation_, 1 )).getStartIndex();
int compoundStartIndex =
***************
*** 72,76 ****
! sourceNode_ = SourceASTNode::create( blankedSource, source );
ParseContext context( sourceNode_ );
StatementParser parser( context,
--- 65,69 ----
! sourceNode_ = SourceASTNode::create( blankedSource, source, getSource() );
ParseContext context( sourceNode_ );
StatementParser parser( context,
***************
*** 139,143 ****
}
! transforms_.apply( getDocument() );
}
--- 132,136 ----
}
! transforms_.apply( getSource() );
}
Index: InlineTempRefactoring.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/InlineTempRefactoring.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** InlineTempRefactoring.cpp 20 Dec 2003 08:59:50 -0000 1.11
--- InlineTempRefactoring.cpp 13 Jan 2004 22:27:35 -0000 1.12
***************
*** 7,12 ****
#include <rfta/refactoring/InlineTempRefactoring.h>
#include <rfta/refactoring/RefactoringError.h>
! #include <rfta/refactoring/TextDocument.h>
! #include <rfta/parser/NonSemanticBlanker.h>
#include <rfta/parser/ParseContext.h>
#include <rfta/parser/StatementParser.h>
--- 7,13 ----
#include <rfta/refactoring/InlineTempRefactoring.h>
#include <rfta/refactoring/RefactoringError.h>
! #include <rfta/parser/TextDocument.h>
! #include <rfta/parser/PreProcessor.h>
! #include <rfta/parser/Source.h>
#include <rfta/parser/ParseContext.h>
#include <rfta/parser/StatementParser.h>
***************
*** 24,30 ****
! InlineTempRefactoring::InlineTempRefactoring( TextDocument &document,
int temporaryLocation )
! : RefactoringBase( document )
, temporaryLocation_( temporaryLocation )
{
--- 25,32 ----
! InlineTempRefactoring::InlineTempRefactoring( SourcePtr source,
! SourceManager& manager,
int temporaryLocation )
! : RefactoringBase( source, manager )
, temporaryLocation_( temporaryLocation )
{
***************
*** 66,74 ****
throw RefactoringError( RefactoringError::selectionNotInSource );
! // blank the source code
! PPDirectiveListenerPtr nullListener(new NullPPDirectiveListener());
! std::string blankedSource;
! NonSemanticBlanker blanker( source, blankedSource, nullListener );
! blanker.blank();
int start_at = temporaryLocation_;
--- 68,79 ----
throw RefactoringError( RefactoringError::selectionNotInSource );
! // preprocess
! PreProcessorContext preproc_context( getSourceManager() );
! PreProcessor proc( getSource(), preproc_context );
! proc.setOption(PreProcessor::skipIncludes); // TODO: disable this if preprocessor features can handle all system headers
! std::string blankedSource = proc.process();
!
! // correct pointer to location after preprocessing
! temporaryLocation_ = getSource()->getRangePreProcessed(SourceRange( temporaryLocation_, 1 )).getStartIndex();
int start_at = temporaryLocation_;
***************
*** 84,88 ****
// 'lazy' parse the source
! sourceNode_ = SourceASTNode::create( blankedSource, source );
ParseContext context( sourceNode_ );
StatementParser parser( context,
--- 89,93 ----
// 'lazy' parse the source
! sourceNode_ = SourceASTNode::create( blankedSource, source, getSource() );
ParseContext context( sourceNode_ );
StatementParser parser( context,
***************
*** 377,381 ****
! transforms.apply( getDocument() );
}
--- 382,386 ----
! transforms.apply( getSource() );
}
Index: IndentLevelManager.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/IndentLevelManager.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** IndentLevelManager.h 22 Apr 2003 19:18:16 -0000 1.12
--- IndentLevelManager.h 13 Jan 2004 22:27:35 -0000 1.13
***************
*** 7,10 ****
--- 7,11 ----
#include <rfta/refactoring/CodeModelForward.h>
+ #include <rfta/parser/Source.h>
#include <deque>
#include <string>
***************
*** 51,55 ****
/*! Constructs a IndentLevelManager object.
*/
! IndentLevelManager( const std::string &originalSource,
int indentWidth = 2 );
--- 52,56 ----
/*! Constructs a IndentLevelManager object.
*/
! IndentLevelManager( SourcePtr source,
int indentWidth = 2 );
***************
*** 97,101 ****
Indents indents_;
! const std::string originalSource_;
int indentWidth_;
};
--- 98,102 ----
Indents indents_;
! SourcePtr source_;
int indentWidth_;
};
Index: RenameTempRefactoringTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/RenameTempRefactoringTest.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** RenameTempRefactoringTest.cpp 16 Dec 2003 13:26:10 -0000 1.17
--- RenameTempRefactoringTest.cpp 13 Jan 2004 22:27:35 -0000 1.18
***************
*** 7,12 ****
#include "RenameTempRefactoringTest.h"
#include <rfta/refactoring/RenameTempRefactoring.h>
! #include <rfta/refactoring/PlainTextDocument.h>
#include <rfta/refactoring/RefactoringError.h>
--- 7,13 ----
#include "RenameTempRefactoringTest.h"
#include <rfta/refactoring/RenameTempRefactoring.h>
! #include <rfta/parser/PlainTextDocument.h>
#include <rfta/refactoring/RefactoringError.h>
+ #include <rfta/parser/Source.h>
***************
*** 37,41 ****
RenameTempRefactoringTest::tearDown()
{
- document_.reset();
SourceBasedTestBase::tearDown();
}
--- 38,41 ----
***************
*** 46,52 ****
const std::string &oldLocaleVariableName )
{
! document_.reset( new PlainTextDocument( source_ ) );
int selectionIndex = builder_->getStartIndex( "selection" );
! RenameTempRefactoring refactoring( *document_,
selectionIndex );
refactoring.apply( newTemporaryName );
--- 46,54 ----
const std::string &oldLocaleVariableName )
{
! sourceDoc_ = SourcePtr( new Source( TextDocumentPtr( new PlainTextDocument( source_ ) ) ) );
!
int selectionIndex = builder_->getStartIndex( "selection" );
! RenameTempRefactoring refactoring( sourceDoc_,
! sourceMngMock_,
selectionIndex );
refactoring.apply( newTemporaryName );
***************
*** 76,80 ****
" return price * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 78,82 ----
" return price * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 100,104 ****
" return price * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 102,106 ----
" return price * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 126,130 ****
" return price * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 128,132 ----
" return price * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 152,156 ****
" return price * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 154,158 ----
" return price * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 186,190 ****
" return price * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 188,192 ----
" return price * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 207,211 ****
" CppUnit::XmlOutputter xmlOutputter( &resultCollector, xmlFile );"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 209,213 ----
" CppUnit::XmlOutputter xmlOutputter( &resultCollector, xmlFile );"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
***************
*** 242,246 ****
" return price * getQuantity();"
"}" );
! std::string actualSource( document_->getAllText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
--- 244,248 ----
" return price * getQuantity();"
"}" );
! std::string actualSource( sourceDoc_->getOriginalText() );
RFTA_ASSERT_EQUAL( expectedSource, actualSource );
}
Index: RenameTempRefactoring.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/RenameTempRefactoring.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** RenameTempRefactoring.cpp 16 Dec 2003 13:26:10 -0000 1.18
--- RenameTempRefactoring.cpp 13 Jan 2004 22:27:35 -0000 1.19
***************
*** 10,14 ****
#include "IdentifierResolverContext.h"
#include "ReplaceTextTransform.h"
- #include "PreProcessTransform.h"
#include <rfta/parser/MaxLODMutator.h>
#include <rfta/parser/PreProcessor.h>
--- 10,13 ----
***************
*** 20,25 ****
#include <rfta/parser/ASTNodes.h>
#include <rfta/refactoring/RefactoringError.h>
! #include <rfta/refactoring/TextDocument.h>
! #include <rfta/parser/MacroReplaceRegistration.h>
--- 19,24 ----
#include <rfta/parser/ASTNodes.h>
#include <rfta/refactoring/RefactoringError.h>
! #include <rfta/parser/TextDocument.h>
! #include <rfta/parser/Source.h>
***************
*** 27,34 ****
{
! RenameTempRefactoring::RenameTempRefactoring( TextDocument &document,
int temporaryLocation )
! : RefactoringBase( document )
! , temporaryLocation_( temporaryLocation )
{
prepare();
--- 26,34 ----
{
! RenameTempRefactoring::RenameTempRefactoring( SourcePtr source,
! SourceManager& manager,
int temporaryLocation )
! : RefactoringBase( source, manager )
! , temporaryLocation_( temporaryLocation )
{
prepare();
***************
*** 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_;
--- 67,79 ----
if ( temporaryLocation_ >= source.length() )
throw RefactoringError( RefactoringError::selectionNotInSource );
! PreProcessorContext context( getSourceManager() );
! PreProcessor proc( getSource(), context);
! proc.setOption(PreProcessor::skipIncludes); // TODO: disable this if preprocessor features can handle all system headers
! std::string blankedSource = proc.process();
!
! // fix source offset after preprocessing (macros might have moved the position)
! temporaryLocation_ = getSource()->getRangePreProcessed(SourceRange( temporaryLocation_, 1 )).getStartIndex();
int start_at = temporaryLocation_;
***************
*** 95,99 ****
// 'lazy' parse the source
! sourceNode_ = SourceASTNode::create( blankedSource, source );
ParseContext context( sourceNode_ );
StatementParser parser( context,
--- 89,93 ----
// 'lazy' parse the source
! sourceNode_ = SourceASTNode::create( blankedSource, source, getSource() );
ParseContext context( sourceNode_ );
StatementParser parser( context,
***************
*** 150,154 ****
}
! transforms_.apply( getDocument() );
}
--- 144,148 ----
}
! transforms_.apply( getSource() );
}
Index: CodeWriterTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** CodeWriterTest.cpp 24 Apr 2003 16:28:30 -0000 1.36
--- CodeWriterTest.cpp 13 Jan 2004 22:27:35 -0000 1.37
***************
*** 6,9 ****
--- 6,10 ----
#include "stdafx.h"
#include "CodeWriterTest.h"
+ #include <rfta/parser/Source.h>
***************
*** 52,56 ****
rewriteSource();
! RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() );
}
--- 53,57 ----
rewriteSource();
! RFTA_ASSERT_EQUAL( expectedSource, sourceDoc_->getOriginalText() );
}
***************
*** 80,84 ****
" return;\n"
"}";
! RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() );
}
--- 81,85 ----
" return;\n"
"}";
! RFTA_ASSERT_EQUAL( expectedSource, sourceDoc_->getOriginalText() );
}
***************
*** 100,104 ****
" return true;\n"
" }";
! RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() );
}
--- 101,105 ----
" return true;\n"
" }";
! RFTA_ASSERT_EQUAL( expectedSource, sourceDoc_->getOriginalText() );
}
***************
*** 123,127 ****
" return 6;\n"
"}";
! RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() );
}
--- 124,128 ----
" return 6;\n"
"}";
! RFTA_ASSERT_EQUAL( expectedSource, sourceDoc_->getOriginalText() );
}
***************
*** 162,166 ****
" return 3;\n"
"}";
! RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() );
}
--- 163,167 ----
" return 3;\n"
"}";
! RFTA_ASSERT_EQUAL( expectedSource, sourceDoc_->getOriginalText() );
}
Index: CodeRewriter.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** CodeRewriter.cpp 19 Dec 2003 20:11:36 -0000 1.46
--- CodeRewriter.cpp 13 Jan 2004 22:27:35 -0000 1.47
***************
*** 7,11 ****
#include "CodeRewriter.h"
#include "ReplaceTextTransform.h"
! #include <rfta/refactoring/TextDocument.h>
#include <rfta/refactoring/CodeModelExpressions.h>
#include <rfta/refactoring/CodeModelStatements.h>
--- 7,11 ----
#include "CodeRewriter.h"
#include "ReplaceTextTransform.h"
! #include <rfta/parser/Source.h>
#include <rfta/refactoring/CodeModelExpressions.h>
#include <rfta/refactoring/CodeModelStatements.h>
***************
*** 15,24 ****
! CodeRewriter::CodeRewriter( const std::string &originalSource,
int indentWidth )
! : originalSource_( originalSource )
, indentWidth_( indentWidth )
, currentInsertionPos_( 0 )
! , indentManager_( originalSource )
, mode_( updating )
{
--- 15,24 ----
! CodeRewriter::CodeRewriter( const SourcePtr source,
int indentWidth )
! : source_( source )
, indentWidth_( indentWidth )
, currentInsertionPos_( 0 )
! , indentManager_( source )
, mode_( updating )
{
***************
*** 32,43 ****
void
! CodeRewriter::rewrite( const StatementPtr &statement,
! TransformList& preprocesstransforms,
! TextDocument &document )
{
statement->accept( *this );
! // @TODO(Andre): Check conflics between statement transforms and preprocessing...
! transforms_.add(preprocesstransforms);
! transforms_.apply( document );
}
--- 32,39 ----
void
! CodeRewriter::rewrite( const StatementPtr &statement )
{
statement->accept( *this );
! transforms_.apply( source_ );
}
***************
*** 110,120 ****
CodeRewriter::deleteStatement( const SourceRange &range )
{
! int startIndex = range.getStartIndex();
! while ( startIndex > 0 && isSpace( originalSource_.at( startIndex-1 ) ) )
! --startIndex;
! while ( startIndex > 0 && isNewLine( originalSource_.at( startIndex-1 ) ) )
! --startIndex;
!
! deleteText( SourceRange( startIndex, range.getEndIndex() - startIndex ) );
}
--- 106,117 ----
CodeRewriter::deleteStatement( const SourceRange &range )
{
! SourceRange r = range; r.setLength(1);r.moveStartIndexBy(-1);
! while ( r.getStartIndex() >= 0 && isSpace( source_->getOriginalText(r)[0] ) )
! r.moveStartIndexBy(-1);
! while ( r.getStartIndex() >= 0 && isNewLine( source_->getOriginalText(r)[0] ) )
! r.moveStartIndexBy(-1);
! r.moveStartIndexBy(1);
! r.setEndIndex(range.getEndIndex());
! deleteText( r );
}
***************
*** 123,131 ****
CodeRewriter::deleteTrailingExpression( const SourceRange &range )
{
! int startIndex = range.getStartIndex();
! while ( startIndex > 0 && isSpace( originalSource_.at( startIndex-1 ) ) )
! --startIndex;
!
! deleteText( SourceRange( startIndex, range.getEndIndex() - startIndex ) );
}
--- 120,129 ----
CodeRewriter::deleteTrailingExpression( const SourceRange &range )
{
! SourceRange r = range; r.setLength(1);r.moveStartIndexBy(-1);
! while ( r.getStartIndex() >= 0 && isSpace( source_->getOriginalText(r)[0] ) )
! r.moveStartIndexBy(-1);
! r.moveStartIndexBy(1);
! r.setEndIndex(range.getEndIndex());
! deleteText( r );
}
***************
*** 134,146 ****
CodeRewriter::deleteBracedExpression( const SourceRange &range )
{
! int startIndex = range.getStartIndex();
! while ( startIndex > 0 && isSpace( originalSource_.at( startIndex-1 ) ) )
! --startIndex;
!
! int endIndex = range.getEndIndex();
! while ( endIndex < originalSource_.length() && isSpace( originalSource_.at( endIndex ) ) )
! ++endIndex;
! deleteText( SourceRange( startIndex, endIndex - startIndex ) );
}
--- 132,146 ----
CodeRewriter::deleteBracedExpression( const SourceRange &range )
{
! SourceRange r = range; r.setLength(1);r.moveStartIndexBy(-1);
! while ( r.getStartIndex() >= 0 && isSpace( source_->getOriginalText(r)[0] ) )
! r.moveStartIndexBy(-1);
! r.moveStartIndexBy(1);
!
! SourceRange end = range; end.moveStartIndexBy(range.getLength());end.setLength(1);
! while ( !source_->getOriginalText(end).empty() && isSpace( source_->getOriginalText(end)[0] ) )
! end.moveStartIndexBy(1);
! r.setEndIndex(end.getStartIndex() );
! deleteText( r );
}
***************
*** 434,438 ****
{
insertText( ")" );
! indentManager_.enterNewWhileStatement( iteratedStatement );
}
else
--- 434,438 ----
{
insertText( ")" );
! indentManager_.enterNewForStatement( iteratedStatement );
}
else
|