You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(37) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(15) |
Feb
(26) |
Mar
(97) |
Apr
(224) |
May
(226) |
Jun
|
Jul
(3) |
Aug
(22) |
Sep
(48) |
Oct
|
Nov
|
Dec
(38) |
2004 |
Jan
(28) |
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(37) |
Jul
|
Aug
(73) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <bl...@us...> - 2003-03-15 21:29:45
|
Update of /cvsroot/cpptool/rfta/src In directory sc8-pr-cvs1:/tmp/cvs-serv6289/src Modified Files: rfta.opt Log Message: * added support for inserting do/while statement. Index: rfta.opt =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta.opt,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 Binary files /tmp/cvsRSAbum and /tmp/cvsWtHDiy differ |
From: <bl...@us...> - 2003-03-15 21:18:46
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv3190/src/rfta Modified Files: CodeRewriter.cpp CodeWriterTest.cpp CodeWriterTest.h Log Message: * added support for inserting continue, break, default and case statements. Index: CodeRewriter.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CodeRewriter.cpp 15 Mar 2003 20:57:38 -0000 1.8 --- CodeRewriter.cpp 15 Mar 2003 21:18:44 -0000 1.9 *************** *** 97,100 **** --- 97,102 ---- CodeRewriter::visit( BreakStatement &statement ) { + if ( isInserting() ) + insertText( "\n" + indentManager_.getIndentSpacer() + "break;" ); } *************** *** 103,106 **** --- 105,114 ---- CodeRewriter::visit( CaseStatement &statement ) { + if ( isInserting() ) + { + insertText( "\n" + indentManager_.getIndentSpacer() + "case " ); + statement.getConditionValue()->accept( *this ); + insertText( ":" ); + } } *************** *** 159,162 **** --- 167,172 ---- CodeRewriter::visit( ContinueStatement &statement ) { + if ( isInserting() ) + insertText( "\n" + indentManager_.getIndentSpacer() + "continue;" ); } *************** *** 165,168 **** --- 175,180 ---- CodeRewriter::visit( DefaultStatement &statement ) { + if ( isInserting() ) + insertText( "\n" + indentManager_.getIndentSpacer() + "default:" ); } Index: CodeWriterTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CodeWriterTest.cpp 15 Mar 2003 20:57:38 -0000 1.10 --- CodeWriterTest.cpp 15 Mar 2003 21:18:44 -0000 1.11 *************** *** 69,73 **** CodeWriterTest::makeTrueExpression() { ! return CodeModel::ExpressionPtr( new CodeModel::GenericExpression( "true" ) ); } --- 69,80 ---- CodeWriterTest::makeTrueExpression() { ! return makeExpression( "true" ); ! } ! ! ! CodeModel::ExpressionPtr ! CodeWriterTest::makeExpression( const std::string &expression ) ! { ! return CodeModel::ExpressionPtr( new CodeModel::GenericExpression( expression ) ); } *************** *** 250,253 **** --- 257,348 ---- " ;\n" " }\n" + "}"; + RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); + } + + + void + CodeWriterTest::testInsertContinueStatement() + { + source_ = "{\n" + "}"; + + generateCompound(); + + RFTA_ASSERT_EQUAL( 0, compound_->getStatementCount() ); + + CodeModel::StatementPtr continueStatement( new CodeModel::ContinueStatement() ); + compound_->appendStatement( continueStatement ); + + rewriteSource(); + + std::string expectedSource = "{\n" + " continue;\n" + "}"; + RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); + } + + + void + CodeWriterTest::testInsertBreakStatement() + { + source_ = "{\n" + "}"; + + generateCompound(); + + RFTA_ASSERT_EQUAL( 0, compound_->getStatementCount() ); + + CodeModel::StatementPtr breakStatement( new CodeModel::BreakStatement() ); + compound_->appendStatement( breakStatement ); + + rewriteSource(); + + std::string expectedSource = "{\n" + " break;\n" + "}"; + RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); + } + + + void + CodeWriterTest::testInsertDefaultStatement() + { + source_ = "{\n" + "}"; + + generateCompound(); + + RFTA_ASSERT_EQUAL( 0, compound_->getStatementCount() ); + + CodeModel::StatementPtr defaultStatement( new CodeModel::DefaultStatement() ); + compound_->appendStatement( defaultStatement ); + + rewriteSource(); + + std::string expectedSource = "{\n" + " default:\n" + "}"; + RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); + } + + + void + CodeWriterTest::testInsertCaseStatement() + { + source_ = "{\n" + "}"; + + generateCompound(); + + RFTA_ASSERT_EQUAL( 0, compound_->getStatementCount() ); + + CodeModel::StatementPtr caseStatement( new CodeModel::CaseStatement( makeExpression( "1234" ) ) ); + compound_->appendStatement( caseStatement ); + + rewriteSource(); + + std::string expectedSource = "{\n" + " case 1234:\n" "}"; RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); Index: CodeWriterTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CodeWriterTest.h 15 Mar 2003 20:57:38 -0000 1.7 --- CodeWriterTest.h 15 Mar 2003 21:18:44 -0000 1.8 *************** *** 28,31 **** --- 28,35 ---- CPPUNIT_TEST( testInsertNullStatement ); CPPUNIT_TEST( testInsertWhileStatement ); + CPPUNIT_TEST( testInsertContinueStatement ); + CPPUNIT_TEST( testInsertBreakStatement ); + CPPUNIT_TEST( testInsertDefaultStatement ); + CPPUNIT_TEST( testInsertCaseStatement ); CPPUNIT_TEST_SUITE_END(); *************** *** 48,51 **** --- 52,59 ---- void testInsertNullStatement(); void testInsertWhileStatement(); + void testInsertContinueStatement(); + void testInsertBreakStatement(); + void testInsertDefaultStatement(); + void testInsertCaseStatement(); private: *************** *** 53,56 **** --- 61,65 ---- void rewriteSource(); CodeModel::ExpressionPtr makeTrueExpression(); + CodeModel::ExpressionPtr makeExpression( const std::string &expression ); CodeModel::CompoundStatementPtr compound_; |
From: <bl...@us...> - 2003-03-15 21:18:46
|
Update of /cvsroot/cpptool/rfta/src In directory sc8-pr-cvs1:/tmp/cvs-serv3190/src Modified Files: rfta.opt Log Message: * added support for inserting continue, break, default and case statements. Index: rfta.opt =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta.opt,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 Binary files /tmp/cvsQhcgvx and /tmp/cvsYHGhjU differ |
From: <bl...@us...> - 2003-03-15 20:58:09
|
Update of /cvsroot/cpptool/rfta/include/rfta/refactoring In directory sc8-pr-cvs1:/tmp/cvs-serv26926/include/rfta/refactoring Modified Files: CodeModelForward.h Log Message: * added support for inserting null, while and compound statements. Index: CodeModelForward.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelForward.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeModelForward.h 22 Dec 2002 15:47:00 -0000 1.3 --- CodeModelForward.h 15 Mar 2003 20:57:35 -0000 1.4 *************** *** 50,53 **** --- 50,54 ---- typedef boost::shared_ptr<DeclaratorExpression> DeclaratorExpressionPtr; typedef boost::shared_ptr<Expression> ExpressionPtr; + typedef boost::shared_ptr<WhileStatement> WhileStatementPtr; typedef boost::weak_ptr<Expression> ExpressionWeakPtr; typedef boost::shared_ptr<CompoundStatement> CompoundStatementPtr; |
From: <bl...@us...> - 2003-03-15 20:57:42
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv26926/src/rfta Modified Files: CodeRewriter.cpp CodeWriterTest.cpp CodeWriterTest.h IndentLevelManager.cpp IndentLevelManager.h Log Message: * added support for inserting null, while and compound statements. Index: CodeRewriter.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CodeRewriter.cpp 8 Mar 2003 13:11:42 -0000 1.7 --- CodeRewriter.cpp 15 Mar 2003 20:57:38 -0000 1.8 *************** *** 110,119 **** { IndentLevelManager::IndentRestorer restorer( indentManager_ ); - ModeModifier mode( mode_, updating ); ! if ( statement.getText().hasOriginalSourceRange() ) { nextStatementInsertionPos_ = statement.getText().getOriginalSourceRange().getStartIndex() + 1; ! indentManager_.enterExistingStatement( nextStatementInsertionPos_ - 1 ); } --- 110,123 ---- { IndentLevelManager::IndentRestorer restorer( indentManager_ ); ! if ( isInserting() ) ! { ! insertText( "\n" + indentManager_.getIndentSpacer() + "{" ); ! indentManager_.enterNewCompoundStatement(); ! } ! else if ( statement.getText().hasOriginalSourceRange() ) { nextStatementInsertionPos_ = statement.getText().getOriginalSourceRange().getStartIndex() + 1; ! indentManager_.enterExistingCompoundStatement( nextStatementInsertionPos_ - 1 ); } *************** *** 137,140 **** --- 141,150 ---- change.statement_->accept( *this ); } + + if ( isInserting() ) + { + restorer.restoreIndentLevel(); + insertText( "\n" + indentManager_.getIndentSpacer() + "}" ); + } } *************** *** 219,222 **** --- 229,234 ---- CodeRewriter::visit( NullStatement &statement ) { + if ( isInserting() ) + insertText( "\n" + indentManager_.getIndentSpacer() + ";" ); } *************** *** 270,273 **** --- 282,289 ---- CodeRewriter::visit( WhileStatement &statement ) { + insertText( "\n" + indentManager_.getIndentSpacer() + "while ( " ); + statement.getCondition()->accept( *this ); + insertText( " )" ); + statement.getIteratedStatement()->accept( *this ); } Index: CodeWriterTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CodeWriterTest.cpp 15 Mar 2003 16:57:39 -0000 1.9 --- CodeWriterTest.cpp 15 Mar 2003 20:57:38 -0000 1.10 *************** *** 198,202 **** std::string expectedSource = "{\n" " \n" ! " return 3;\n" // todo: there should be only one space between return and 3. "}"; RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); --- 198,253 ---- std::string expectedSource = "{\n" " \n" ! " return 3;\n" ! "}"; ! RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); ! } ! ! ! void ! CodeWriterTest::testInsertNullStatement() ! { ! source_ = "{\n" ! "}"; ! ! generateCompound(); ! ! RFTA_ASSERT_EQUAL( 0, compound_->getStatementCount() ); ! ! CodeModel::StatementPtr nullStatement( new CodeModel::NullStatement() ); ! compound_->appendStatement( nullStatement ); ! ! rewriteSource(); ! ! std::string expectedSource = "{\n" ! " ;\n" ! "}"; ! RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); ! } ! ! ! void ! CodeWriterTest::testInsertWhileStatement() ! { ! source_ = "{\n" ! "}"; ! ! generateCompound(); ! ! RFTA_ASSERT_EQUAL( 0, compound_->getStatementCount() ); ! ! CodeModel::StatementPtr nullStatement( new CodeModel::NullStatement() ); ! CodeModel::CompoundStatementPtr compoundStatement( new CodeModel::CompoundStatement() ); ! compoundStatement->appendStatement( nullStatement ); ! CodeModel::WhileStatementPtr whileStatement( ! new CodeModel::WhileStatement( makeTrueExpression(), compoundStatement ) ); ! compound_->appendStatement( whileStatement ); ! ! rewriteSource(); ! ! std::string expectedSource = "{\n" ! " while ( true )\n" ! " {\n" ! " ;\n" ! " }\n" "}"; RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); Index: CodeWriterTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CodeWriterTest.h 8 Mar 2003 13:11:42 -0000 1.6 --- CodeWriterTest.h 15 Mar 2003 20:57:38 -0000 1.7 *************** *** 26,29 **** --- 26,31 ---- CPPUNIT_TEST( testRemoveStatement ); CPPUNIT_TEST( testMoveSubExpression ); + CPPUNIT_TEST( testInsertNullStatement ); + CPPUNIT_TEST( testInsertWhileStatement ); CPPUNIT_TEST_SUITE_END(); *************** *** 44,47 **** --- 46,51 ---- void testRemoveStatement(); void testMoveSubExpression(); + void testInsertNullStatement(); + void testInsertWhileStatement(); private: Index: IndentLevelManager.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IndentLevelManager.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IndentLevelManager.cpp 7 Mar 2003 07:58:31 -0000 1.2 --- IndentLevelManager.cpp 15 Mar 2003 20:57:38 -0000 1.3 *************** *** 26,32 **** void ! IndentLevelManager::enterExistingStatement( int startingPos ) { pushIndent( findIndentLevelOf( startingPos ) + indentWidth_ ); } --- 26,39 ---- void ! IndentLevelManager::enterExistingCompoundStatement( int startingPos ) { pushIndent( findIndentLevelOf( startingPos ) + indentWidth_ ); + } + + + void + IndentLevelManager::enterNewCompoundStatement() + { + pushIndent( getIndentLevel() + indentWidth_ ); } Index: IndentLevelManager.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IndentLevelManager.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IndentLevelManager.h 7 Mar 2003 09:41:11 -0000 1.3 --- IndentLevelManager.h 15 Mar 2003 20:57:38 -0000 1.4 *************** *** 23,26 **** --- 23,27 ---- : manager_( manager ) , count_( manager.indents_.size() ) + , shouldRestore_( true ) { } *************** *** 28,36 **** --- 29,47 ---- ~IndentRestorer() { + restoreIndentLevel(); + } + + void restoreIndentLevel() + { + if ( !shouldRestore_ ) + return; + manager_.indents_.resize( count_ ); + shouldRestore_ = false; } IndentLevelManager &manager_; int count_; + bool shouldRestore_; }; *************** *** 45,49 **** virtual ~IndentLevelManager(); ! void enterExistingStatement( int startingPos ); int getIndentLevel() const; --- 56,62 ---- virtual ~IndentLevelManager(); ! void enterExistingCompoundStatement( int startingPos ); ! ! void enterNewCompoundStatement(); int getIndentLevel() const; |
From: <bl...@us...> - 2003-03-15 20:57:42
|
Update of /cvsroot/cpptool/rfta/src In directory sc8-pr-cvs1:/tmp/cvs-serv26926/src Modified Files: rfta.opt Log Message: * added support for inserting null, while and compound statements. Index: rfta.opt =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta.opt,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 Binary files /tmp/cvsi8Bq3h and /tmp/cvsOYtZur differ |
From: <bl...@us...> - 2003-03-15 17:01:37
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv29183/src/rfta Modified Files: rfta.dsp Log Message: * stripped heading spaces of assignement value in declaration. Index: rfta.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/rfta.dsp,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** rfta.dsp 8 Mar 2003 13:11:42 -0000 1.38 --- rfta.dsp 15 Mar 2003 17:01:32 -0000 1.39 *************** *** 902,909 **** --- 902,927 ---- SOURCE=.\CodeModelGeneratorTest.cpp + + !IF "$(CFG)" == "rfta - Win32 Release" + + # PROP Exclude_From_Build 1 + + !ELSEIF "$(CFG)" == "rfta - Win32 Debug" + + !ENDIF + # End Source File # Begin Source File SOURCE=.\CodeModelGeneratorTest.h + + !IF "$(CFG)" == "rfta - Win32 Release" + + # PROP Exclude_From_Build 1 + + !ELSEIF "$(CFG)" == "rfta - Win32 Debug" + + !ENDIF + # End Source File # Begin Source File |
From: <bl...@us...> - 2003-03-15 16:57:45
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv27718/src/rftaparser Modified Files: VariableDeclMutator.cpp Log Message: * stripped heading spaces of assignement value in declaration. Index: VariableDeclMutator.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/VariableDeclMutator.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** VariableDeclMutator.cpp 30 Dec 2002 15:02:28 -0000 1.14 --- VariableDeclMutator.cpp 15 Mar 2003 16:57:39 -0000 1.15 *************** *** 464,467 **** --- 464,468 ---- case '=': initializerType = ASTNodeTypes::assignVariableInitializerExpression; + skipSpaces(); initializerValueStartIndex = getCurrentIndex(); skipOverAssignmentInitializer(); /// @todo should check return value |
From: <bl...@us...> - 2003-03-15 16:57:45
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv27718/src/rfta Modified Files: CodeModelGeneratorTest.cpp CodeWriterTest.cpp InlineTempRefactoring.cpp Log Message: * stripped heading spaces of assignement value in declaration. Index: CodeModelGeneratorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelGeneratorTest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CodeModelGeneratorTest.cpp 8 Mar 2003 13:10:44 -0000 1.1 --- CodeModelGeneratorTest.cpp 15 Mar 2003 16:57:39 -0000 1.2 *************** *** 62,66 **** CodeModel::AssignInitializerExpression &initializer = dynamic_cast<CodeModel::AssignInitializerExpression &>( *declarator.getInitializer() ); ! RFTA_ASSERT_EQUAL( " 3", initializer.getValue()->getText().getOriginalText() ); } --- 62,66 ---- CodeModel::AssignInitializerExpression &initializer = dynamic_cast<CodeModel::AssignInitializerExpression &>( *declarator.getInitializer() ); ! RFTA_ASSERT_EQUAL( "3", initializer.getValue()->getText().getOriginalText() ); } Index: CodeWriterTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CodeWriterTest.cpp 8 Mar 2003 13:11:42 -0000 1.8 --- CodeWriterTest.cpp 15 Mar 2003 16:57:39 -0000 1.9 *************** *** 198,202 **** std::string expectedSource = "{\n" " \n" ! " return 3;\n" // todo: there should be only one space between return and 3. "}"; RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); --- 198,202 ---- std::string expectedSource = "{\n" " \n" ! " return 3;\n" // todo: there should be only one space between return and 3. "}"; RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); Index: InlineTempRefactoring.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/InlineTempRefactoring.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** InlineTempRefactoring.cpp 30 Dec 2002 13:59:18 -0000 1.4 --- InlineTempRefactoring.cpp 15 Mar 2003 16:57:39 -0000 1.5 *************** *** 348,352 **** } else ! newtext = std::string("(") + initValue_->getOriginalText() + " )"; for ( ToolsBox::ASTNodes::const_iterator it = occurrences_.begin(); --- 348,352 ---- } else ! newtext = std::string("( ") + initValue_->getOriginalText() + " )"; for ( ToolsBox::ASTNodes::const_iterator it = occurrences_.begin(); |
From: <bl...@us...> - 2003-03-12 07:46:42
|
Update of /cvsroot/cpptool/rfta/include/rfta/refactoring In directory sc8-pr-cvs1:/tmp/cvs-serv4963/include/rfta/refactoring Modified Files: CodeModelElement.h CodeModelExpressions.h CodeModelStatements.h Log Message: * fixed compiler internal error on VC6 Index: CodeModelElement.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelElement.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CodeModelElement.h 6 Mar 2003 22:18:42 -0000 1.4 --- CodeModelElement.h 12 Mar 2003 07:46:09 -0000 1.5 *************** *** 59,80 **** ElementText text_; - - #if 0 - void setOriginalText( const SourceRange &sourceRange ); - - void unsetSourceRange(); - - const SourceRange &getSourceRange() const; - - bool hasSourceRange() const; - - bool wasReplaced() const; - - void replace(); - - private: - SourceRange sourceRange_; - bool wasReplaced_; - #endif }; --- 59,62 ---- Index: CodeModelExpressions.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelExpressions.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CodeModelExpressions.h 6 Mar 2003 22:18:42 -0000 1.5 --- CodeModelExpressions.h 12 Mar 2003 07:46:09 -0000 1.6 *************** *** 30,34 **** public: GenericExpression( const ElementText &value ); ! // GenericExpression( const std::string &value ); // const std::string getValue() const; --- 30,34 ---- public: GenericExpression( const ElementText &value ); ! GenericExpression( const std::string &value ); // const std::string getValue() const; Index: CodeModelStatements.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelStatements.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeModelStatements.h 6 Mar 2003 22:18:42 -0000 1.3 --- CodeModelStatements.h 12 Mar 2003 07:46:09 -0000 1.4 *************** *** 89,95 **** void accept( StatementVisitor &visitor ); ! private: void originalTextSet(); ! int getActualIndex( int index ) const; --- 89,96 ---- void accept( StatementVisitor &visitor ); ! private: // overridden from CodeElement void originalTextSet(); ! ! private: int getActualIndex( int index ) const; *************** *** 303,311 **** --- 304,318 ---- void setValue( const ExpressionPtr &value ); + Change getValueChange() const; + // overriden from Statement void accept( StatementVisitor &visitor ); + private: // overridden from CodeElement + void originalTextSet(); + private: ExpressionPtr value_; + Change change_; }; |
From: <bl...@us...> - 2003-03-12 07:46:42
|
Update of /cvsroot/cpptool/rfta/bin In directory sc8-pr-cvs1:/tmp/cvs-serv4963/bin Modified Files: test.bat Log Message: * fixed compiler internal error on VC6 Index: test.bat =================================================================== RCS file: /cvsroot/cpptool/rfta/bin/test.bat,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test.bat 16 Dec 2002 21:54:47 -0000 1.5 --- test.bat 12 Mar 2003 07:46:08 -0000 1.6 *************** *** 13,15 **** astdump 89 108 HTMLWriter.cpp ast astdump 0 15 DeclarativeCondition.cpp ast - --- 13,14 ---- |
From: <bl...@us...> - 2003-03-12 07:46:16
|
Update of /cvsroot/cpptool/rfta/src In directory sc8-pr-cvs1:/tmp/cvs-serv4963/src Modified Files: rfta.opt Log Message: * fixed compiler internal error on VC6 Index: rfta.opt =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta.opt,v retrieving revision 1.69 retrieving revision 1.70 diff -C2 -d -r1.69 -r1.70 Binary files /tmp/cvsy2eF0u and /tmp/cvsi0k0aP differ |
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv17642 Modified Files: CodeModel.cpp CodeModelStatements.cpp CodeRewriter.cpp CodeRewriter.h CodeWriterTest.cpp CodeWriterTest.h UnitTesting.h rfta.dsp Log Message: * started adding possibility to move code element. Index: CodeModel.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModel.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CodeModel.cpp 6 Mar 2003 22:17:56 -0000 1.4 --- CodeModel.cpp 8 Mar 2003 13:11:42 -0000 1.5 *************** *** 71,75 **** CompoundStatementPtr compound( new CompoundStatement() ); // compound->setSourceRange( compoundNode->getRange() ); - compound->setOriginalText( ElementText( compoundNode ) ); for ( int index = 0; index < compoundNode->getChildCount(); ++index ) --- 71,74 ---- *************** *** 81,84 **** --- 80,84 ---- } + compound->setOriginalText( ElementText( compoundNode ) ); return compound; } Index: CodeModelStatements.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelStatements.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeModelStatements.cpp 6 Mar 2003 22:17:57 -0000 1.3 --- CodeModelStatements.cpp 8 Mar 2003 13:11:42 -0000 1.4 *************** *** 5,8 **** --- 5,9 ---- #include "stdafx.h" + #include <rfta/refactoring/CodeModelExpressions.h> #include <rfta/refactoring/CodeModelStatements.h> #include <rfta/refactoring/CodeModelVisitor.h> *************** *** 478,481 **** --- 479,493 ---- ReturnStatement::setValue( const ExpressionPtr &value ) { + if ( hasValue() && change_.type_ == Change::unmodified ) + { + change_.type_ = Change::replaced; + change_.oldRange_ = value_->getText().getOriginalSourceRange(); + } + else + change_.type_ = Change::added; + + if ( !value ) + change_.type_ = Change::removed; + value_ = value; } *************** *** 487,490 **** --- 499,516 ---- FlowControlStatement::accept( visitor ); visitor.visit( *this ); + } + + + void + ReturnStatement::originalTextSet() + { + change_.type_ = Change::unmodified; + } + + + Change + ReturnStatement::getValueChange() const + { + return change_; } Index: CodeRewriter.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CodeRewriter.cpp 7 Mar 2003 20:12:39 -0000 1.6 --- CodeRewriter.cpp 8 Mar 2003 13:11:42 -0000 1.7 *************** *** 21,24 **** --- 21,25 ---- , currentInsertionPos_( 0 ) , indentManager_( originalSource ) + , mode_( updating ) { } *************** *** 69,72 **** --- 70,87 ---- + bool + CodeRewriter::isInserting() const + { + return mode_ == inserting; + } + + + bool + CodeRewriter::isUpdating() const + { + return mode_ == updating; + } + + void CodeRewriter::setPreviousStatementEnd( CompoundStatement &statement, *************** *** 95,98 **** --- 110,114 ---- { IndentLevelManager::IndentRestorer restorer( indentManager_ ); + ModeModifier mode( mode_, updating ); if ( statement.getText().hasOriginalSourceRange() ) *************** *** 118,121 **** --- 134,138 ---- deleteText( change.statement_->getText().getOriginalSourceRange() ); + ModeModifier mode( mode_, change.type_ == Change::unmodified ? updating : inserting ); change.statement_->accept( *this ); } *************** *** 209,218 **** { const ElementText &text = statement.getText(); ! if ( text.isOriginalText() ) ! return; ! if ( text.isModifiedText() ) ! replaceText( text.getOriginalSourceRange(), text.getOriginalText() ); ! else if ( text.isNewText() ) { insertText( "\n" + indentManager_.getIndentSpacer() + "return" ); --- 226,246 ---- { const ElementText &text = statement.getText(); ! if ( isUpdating() ) ! { ! Change change = statement.getValueChange(); ! if ( change.type_ == Change::replaced || change.type_ == Change::removed ) ! deleteText( change.oldRange_ ); ! if ( change.type_ == Change::removed || !statement.hasValue() ) ! return; ! ! ModeModifier mode( mode_, change.type_ == Change::unmodified ? updating : inserting ); ! ! if ( mode_ == inserting ) ! currentInsertionPos_ = statement.getText().getOriginalSourceRange().getEndIndex() -1; ! ! statement.getValue()->accept( *this ); ! } ! else if ( isInserting() ) { insertText( "\n" + indentManager_.getIndentSpacer() + "return" ); *************** *** 278,281 **** --- 306,319 ---- CodeRewriter::visit( GenericExpression &expression ) { + if ( isInserting() ) + insertText( expression.getText().getOriginalText() ); + else if ( expression.getText().isModifiedText() ) + { + replaceText( expression.getText().getOriginalSourceRange(), + expression.getText().getOriginalText() ); + } + + + #if 0 if ( expression.getText().isModifiedText() ) { *************** *** 287,290 **** --- 325,329 ---- insertText( expression.getText().getOriginalText() ); } + #endif } Index: CodeRewriter.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CodeRewriter.h 7 Mar 2003 09:41:11 -0000 1.5 --- CodeRewriter.h 8 Mar 2003 13:11:42 -0000 1.6 *************** *** 70,73 **** --- 70,100 ---- private: + enum Mode + { + updating = 0, + inserting + }; + + class ModeModifier + { + public: + ModeModifier( Mode &mode, + Mode newMode ) + : oldMode_( mode ) + , mode_( mode ) + { + mode_ = newMode; + } + + ~ModeModifier() + { + mode_ = oldMode_; + } + + private: + Mode &mode_; + Mode oldMode_; + }; + SourceRange getCurrentInsertionRange() const; *************** *** 79,82 **** --- 106,113 ---- void insertText( const std::string &content ); + bool isInserting() const; + + bool isUpdating() const; + private: IndentLevelManager indentManager_; *************** *** 86,89 **** --- 117,121 ---- int currentInsertionPos_; int indentWidth_; + Mode mode_; }; Index: CodeWriterTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CodeWriterTest.cpp 7 Mar 2003 20:12:40 -0000 1.7 --- CodeWriterTest.cpp 8 Mar 2003 13:11:42 -0000 1.8 *************** *** 66,69 **** --- 66,76 ---- + CodeModel::ExpressionPtr + CodeWriterTest::makeTrueExpression() + { + return CodeModel::ExpressionPtr( new CodeModel::GenericExpression( "true" ) ); + } + + void CodeWriterTest::testRewriteStatement() *************** *** 79,85 **** CodeModel::IfStatement &ifStatement = ! static_cast<CodeModel::IfStatement &>( *compound_->getStatementAt(0) ); CodeModel::GenericExpression &condition = ! static_cast<CodeModel::GenericExpression &>( *ifStatement.getCondition() ); condition.setText( "false" ); --- 86,92 ---- CodeModel::IfStatement &ifStatement = ! dynamic_cast<CodeModel::IfStatement &>( *compound_->getStatementAt(0) ); CodeModel::GenericExpression &condition = ! dynamic_cast<CodeModel::GenericExpression &>( *ifStatement.getCondition() ); condition.setText( "false" ); *************** *** 158,165 **** ! CodeModel::ExpressionPtr ! CodeWriterTest::makeTrueExpression() { ! return CodeModel::ExpressionPtr( new CodeModel::GenericExpression( "true" ) ); } --- 165,204 ---- ! void ! CodeWriterTest::testMoveSubExpression() { ! source_ = "{\n" ! " int x = 3;\n" ! " return x;\n" ! "}"; ! ! generateCompound(); ! ! RFTA_ASSERT_EQUAL( 2, compound_->getStatementCount() ); ! ! ! CodeModel::DeclarationStatement &declStatement = ! dynamic_cast<CodeModel::DeclarationStatement &>( *compound_->getStatementAt(0) ); ! CodeModel::DeclaratorExpression &declExpression = *declStatement.getDeclaration(); ! RFTA_ASSERT_EQUAL( 1, declExpression.getDeclaratorCount() ); ! const CodeModel::Declarator &xDecl = declExpression.getDeclaratorAt(0); ! CPPUNIT_ASSERT( xDecl.hasInitializer() ); ! CodeModel::AssignInitializerExpression &xValueInitializer = ! dynamic_cast<CodeModel::AssignInitializerExpression &>( *xDecl.getInitializer() ); ! CodeModel::ExpressionPtr xValue = xValueInitializer.getValue(); ! ! compound_->removeStatementAt( 0 ); ! ! CodeModel::ReturnStatement &returnStatement = ! dynamic_cast<CodeModel::ReturnStatement &>( *compound_->getStatementAt(0) ); ! returnStatement.setValue( xValue ); ! ! rewriteSource(); ! ! std::string expectedSource = "{\n" ! " \n" ! " return 3;\n" // todo: there should be only one space between return and 3. ! "}"; ! RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); } Index: CodeWriterTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CodeWriterTest.h 7 Mar 2003 20:12:40 -0000 1.5 --- CodeWriterTest.h 8 Mar 2003 13:11:42 -0000 1.6 *************** *** 25,28 **** --- 25,29 ---- CPPUNIT_TEST( testInsertReturnValueStatement ); CPPUNIT_TEST( testRemoveStatement ); + CPPUNIT_TEST( testMoveSubExpression ); CPPUNIT_TEST_SUITE_END(); *************** *** 42,45 **** --- 43,47 ---- void testInsertReturnValueStatement(); void testRemoveStatement(); + void testMoveSubExpression(); private: Index: UnitTesting.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/UnitTesting.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** UnitTesting.h 10 Nov 2002 19:10:29 -0000 1.3 --- UnitTesting.h 8 Mar 2003 13:11:42 -0000 1.4 *************** *** 4,7 **** --- 4,8 ---- #include <cppunit/extensions/HelperMacros.h> #include <sstream> + #include <typeinfo> namespace Refactoring *************** *** 36,39 **** --- 37,59 ---- fixedMessage ); } + + + inline void checkType( const std::type_info &expectedType, + const std::type_info &actualType, + const std::string &expression, + const CppUnit::SourceLine &sourceLine ) + { + if ( expectedType == actualType ) + return; + + CppUnit::Message message( "expression is not of the expected type" ); + message.addDetail( std::string("Expected type: ") + expectedType.name() ); + message.addDetail( std::string("Actual type: ") + actualType.name() ); + if ( !expression.empty() ) + message.addDetail( "Expression: " + expression ); + + CppUnit::Asserter::fail( message, sourceLine ); + } + } } *************** *** 60,63 **** --- 80,89 ---- #define RFTA_TEST_SUITE_REGISTRATION( FixtureType ) \ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FixtureType, "Refactoring" ) + + #define RFTA_ASSERT_TYPE_IS( expectedType, expression ) \ + Refactoring::Testing::checkType( typeid(expectedType), \ + typeid(expression), \ + #expression, \ + CPPUNIT_SOURCELINE() ) #endif // RFTA_UNITTESTING_H Index: rfta.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/rfta.dsp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** rfta.dsp 7 Mar 2003 07:58:31 -0000 1.37 --- rfta.dsp 8 Mar 2003 13:11:42 -0000 1.38 *************** *** 901,904 **** --- 901,912 ---- # Begin Source File + SOURCE=.\CodeModelGeneratorTest.cpp + # End Source File + # Begin Source File + + SOURCE=.\CodeModelGeneratorTest.h + # End Source File + # Begin Source File + SOURCE=.\CodeWriterTest.cpp |
From: <bl...@us...> - 2003-03-08 13:10:47
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv17238 Added Files: CodeModelGeneratorTest.cpp CodeModelGeneratorTest.h Log Message: * added test for declarator expression generation --- NEW FILE: CodeModelGeneratorTest.cpp --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2002, Baptiste Lepilleur. // Created: 2003/03/07 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "CodeModelGeneratorTest.h" #include <rfta/refactoring/CodeModel.h> #include <rfta/refactoring/CodeModelStatements.h> #include <rfta/refactoring/CodeModelExpressions.h> namespace Refactoring { RFTA_TEST_SUITE_REGISTRATION( CodeModelGeneratorTest ); CodeModelGeneratorTest::CodeModelGeneratorTest() { } CodeModelGeneratorTest::~CodeModelGeneratorTest() { } void CodeModelGeneratorTest::setUp() { } void CodeModelGeneratorTest::tearDown() { } void CodeModelGeneratorTest::testGenerateDeclaratorExpression() { source_ = "int x = 3;"; parse(); RFTA_ASSERT_EQUAL( 1, sourceNode_->getChildCount() ); CodeModel::Generator generator; CodeModel::DeclaratorExpressionPtr &declExpression = generator.generateDeclarator( sourceNode_->getChildAt(0) ); RFTA_ASSERT_EQUAL( "int ", declExpression->getPrimaryType() ); RFTA_ASSERT_EQUAL( 1, declExpression->getDeclaratorCount() ); const CodeModel::Declarator &declarator = declExpression->getDeclaratorAt(0); RFTA_ASSERT_EQUAL( "", declarator.getType() ); RFTA_ASSERT_EQUAL( "", declarator.getTypeSuffix() ); RFTA_ASSERT_EQUAL( "x", declarator.getName() ); CPPUNIT_ASSERT( declarator.hasInitializer() ); CodeModel::AssignInitializerExpression &initializer = dynamic_cast<CodeModel::AssignInitializerExpression &>( *declarator.getInitializer() ); RFTA_ASSERT_EQUAL( " 3", initializer.getValue()->getText().getOriginalText() ); } } // namespace Refactoring --- NEW FILE: CodeModelGeneratorTest.h --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2002, Baptiste Lepilleur. // Created: 2003/03/07 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_CODEMODELGENERATORTEST_H #define RFTA_CODEMODELGENERATORTEST_H #include "SourceBasedTestBase.h" namespace Refactoring { /// Unit tests for CodeModelGeneratorTest class CodeModelGeneratorTest : public SourceBasedTestBase { CPPUNIT_TEST_SUITE( CodeModelGeneratorTest ); CPPUNIT_TEST( testGenerateDeclaratorExpression ); CPPUNIT_TEST_SUITE_END(); public: /*! Constructs a CodeModelGeneratorTest object. */ CodeModelGeneratorTest(); /// Destructor. virtual ~CodeModelGeneratorTest(); void setUp(); void tearDown(); void testGenerateDeclaratorExpression(); private: }; // Inlines methods for CodeModelGeneratorTest: // ------------------------------------------- } // namespace Refactoring #endif // RFTA_CODEMODELGENERATORTEST_H |
From: <bl...@us...> - 2003-03-08 13:09:55
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv16819 Modified Files: ReturnStatementParser.cpp rftaparser.dsp Added Files: ReturnStatementParserTest.cpp ReturnStatementParserTest.h Log Message: * fixed bug in return parser: value node source range included the ';' --- NEW FILE: ReturnStatementParserTest.cpp --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2002, Baptiste Lepilleur. // Created: 2003/03/08 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "ReturnStatementParserTest.h" #include "ReturnStatementParser.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> namespace Refactoring { RFTAPARSER_TEST_SUITE_REGISTRATION( ReturnStatementParserTest ); ReturnStatementParserTest::ReturnStatementParserTest() { } ReturnStatementParserTest::~ReturnStatementParserTest() { } void ReturnStatementParserTest::setUp() { } void ReturnStatementParserTest::tearDown() { } void ReturnStatementParserTest::testReturnValue() { std::string source( "return " ); int valueIndex = source.length(); source += "1234"; int valueEnd = source.length(); source += ";"; int startIndex = 0; int endIndex = source.length(); SourceASTNodePtr sourceNode = RFTA_ASSERT_KEYWORD_PARSER_PASS( ReturnStatementParser, source, endIndex, "return" ); RFTA_ASSERT_NODE_HAS( sourceNode->getChildAt(0), ASTNodeTypes::returnStatement, startIndex, endIndex-startIndex ); RFTA_ASSERT_NODE_PROPERTY_HAS( sourceNode->getChildAt(0), ASTNodeProperties::valueProperty, ASTNodeTypes::valueExpression, valueIndex, valueEnd - valueIndex ); } } // namespace Refactoring --- NEW FILE: ReturnStatementParserTest.h --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2002, Baptiste Lepilleur. // Created: 2003/03/08 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_RETURNSTATEMENTPARSERTEST_H #define RFTA_RETURNSTATEMENTPARSERTEST_H #include "ParserTesting.h" namespace Refactoring { /// Unit tests for ReturnStatementParserTest class ReturnStatementParserTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( ReturnStatementParserTest ); CPPUNIT_TEST( testReturnValue ); CPPUNIT_TEST_SUITE_END(); public: /*! Constructs a ReturnStatementParserTest object. */ ReturnStatementParserTest(); /// Destructor. virtual ~ReturnStatementParserTest(); void setUp(); void tearDown(); void testReturnValue(); private: /// Prevents the use of the copy constructor. ReturnStatementParserTest( const ReturnStatementParserTest &other ); /// Prevents the use of the copy operator. void operator =( const ReturnStatementParserTest &other ); private: }; // Inlines methods for ReturnStatementParserTest: // ---------------------------------------------- } // namespace Refactoring #endif // RFTA_RETURNSTATEMENTPARSERTEST_H Index: ReturnStatementParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ReturnStatementParser.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReturnStatementParser.cpp 20 Dec 2002 08:30:51 -0000 1.3 --- ReturnStatementParser.cpp 8 Mar 2003 13:09:52 -0000 1.4 *************** *** 38,42 **** int expressionIndex = getCurrentIndex(); readUntilNext( ';' ); ! int expressionLength = getCurrentIndex() - expressionIndex; ASTNodePtr statement = --- 38,42 ---- int expressionIndex = getCurrentIndex(); readUntilNext( ';' ); ! int expressionLength = getCurrentIndex() - expressionIndex -1; ASTNodePtr statement = Index: rftaparser.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/rftaparser.dsp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** rftaparser.dsp 31 Jan 2003 21:37:03 -0000 1.28 --- rftaparser.dsp 8 Mar 2003 13:09:52 -0000 1.29 *************** *** 761,764 **** --- 761,772 ---- # Begin Source File + SOURCE=.\ReturnStatementParserTest.cpp + # End Source File + # Begin Source File + + SOURCE=.\ReturnStatementParserTest.h + # End Source File + # Begin Source File + SOURCE=.\RftaParserTest.cpp |
From: <bl...@us...> - 2003-03-07 20:12:46
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv25196 Modified Files: CodeRewriter.cpp CodeWriterTest.cpp CodeWriterTest.h Log Message: * added test for statement removal Index: CodeRewriter.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CodeRewriter.cpp 7 Mar 2003 09:41:11 -0000 1.5 --- CodeRewriter.cpp 7 Mar 2003 20:12:39 -0000 1.6 *************** *** 107,111 **** if ( change.type_ == Change::removed ) { ! deleteText( change.statement_->getText().getOriginalSourceRange() ); continue; } --- 107,111 ---- if ( change.type_ == Change::removed ) { ! deleteText( change.oldRange_ ); continue; } Index: CodeWriterTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CodeWriterTest.cpp 7 Mar 2003 09:41:11 -0000 1.6 --- CodeWriterTest.cpp 7 Mar 2003 20:12:40 -0000 1.7 *************** *** 135,138 **** --- 135,161 ---- + void + CodeWriterTest::testRemoveStatement() + { + source_ = "{\n" + " int x = 3;\n" + " return 6;\n" + "}"; + + generateCompound(); + + RFTA_ASSERT_EQUAL( 2, compound_->getStatementCount() ); + compound_->removeStatementAt( 0 ); + + rewriteSource(); + + std::string expectedSource = "{\n" + " \n" + " return 6;\n" + "}"; + RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); + } + + CodeModel::ExpressionPtr CodeWriterTest::makeTrueExpression() Index: CodeWriterTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CodeWriterTest.h 7 Mar 2003 09:41:11 -0000 1.4 --- CodeWriterTest.h 7 Mar 2003 20:12:40 -0000 1.5 *************** *** 24,27 **** --- 24,28 ---- CPPUNIT_TEST( testInsertStatement ); CPPUNIT_TEST( testInsertReturnValueStatement ); + CPPUNIT_TEST( testRemoveStatement ); CPPUNIT_TEST_SUITE_END(); *************** *** 40,43 **** --- 41,45 ---- void testInsertStatement(); void testInsertReturnValueStatement(); + void testRemoveStatement(); private: |
From: <bl...@us...> - 2003-03-07 09:52:45
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv6784 Modified Files: ReplaceTextTransform.h Log Message: * removed boost::non_copyable which caused an internal compiler error with VC6 Index: ReplaceTextTransform.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/ReplaceTextTransform.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ReplaceTextTransform.h 22 Dec 2002 16:03:52 -0000 1.4 --- ReplaceTextTransform.h 7 Mar 2003 09:31:44 -0000 1.5 *************** *** 9,13 **** #include <rfta/refactoring/Config.h> #include <rfta/parser/SourceRange.h> - #include <boost/utility.hpp> #include <string> --- 9,12 ---- *************** *** 19,23 **** /// Replace a piece of text by another one. ! class ReplaceTextTransform : public boost::noncopyable { public: --- 18,22 ---- /// Replace a piece of text by another one. ! class ReplaceTextTransform { public: |
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv10111 Modified Files: CodeModelElement.cpp CodeModelExpressions.cpp CodeRewriter.cpp CodeRewriter.h CodeWriterTest.cpp CodeWriterTest.h IndentLevelManager.h Log Message: * inserted return statement may have a value. Index: CodeModelElement.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelElement.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CodeModelElement.cpp 6 Mar 2003 22:17:57 -0000 1.4 --- CodeModelElement.cpp 7 Mar 2003 09:41:11 -0000 1.5 *************** *** 129,177 **** - #if 0 - void - Element::setSourceRange( const SourceRange &sourceRange ) - { - sourceRange_ = sourceRange; - wasReplaced_ = false; - } - - - void - Element::unsetSourceRange() - { - sourceRange_ = SourceRange( -1, 0 ); - } - - - const SourceRange & - Element::getSourceRange() const - { - return sourceRange_; - } - - - bool - Element::hasSourceRange() const - { - return sourceRange_.getStartIndex() != -1; - } - - - bool - Element::wasReplaced() const - { - return wasReplaced_; - } - - - void - Element::replace() - { - wasReplaced_ = true; - } - #endif - - } // namespace CodeModel } // namespace Refactoring --- 129,132 ---- Index: CodeModelExpressions.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelExpressions.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CodeModelExpressions.cpp 6 Mar 2003 22:17:57 -0000 1.4 --- CodeModelExpressions.cpp 7 Mar 2003 09:41:11 -0000 1.5 *************** *** 21,31 **** } ! /* GenericExpression::GenericExpression( const std::string &value ) - : value_( value ) { } ! const std::string GenericExpression::getValue() const --- 21,31 ---- } ! GenericExpression::GenericExpression( const std::string &value ) { + setText( value ); } ! /* const std::string GenericExpression::getValue() const Index: CodeRewriter.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CodeRewriter.cpp 7 Mar 2003 07:58:31 -0000 1.4 --- CodeRewriter.cpp 7 Mar 2003 09:41:11 -0000 1.5 *************** *** 11,15 **** #include <rfta/refactoring/CodeModelStatements.h> - namespace Refactoring { namespace CodeModel { --- 11,14 ---- *************** *** 64,67 **** --- 63,73 ---- void + CodeRewriter::insertText( const std::string &content ) + { + replaceText( getCurrentInsertionRange(), content ); + } + + + void CodeRewriter::setPreviousStatementEnd( CompoundStatement &statement, int subStatementIndex ) *************** *** 209,213 **** replaceText( text.getOriginalSourceRange(), text.getOriginalText() ); else if ( text.isNewText() ) ! replaceText( getCurrentInsertionRange(), "\n" + indentManager_.getIndentSpacer() + "return;" ); } --- 215,227 ---- replaceText( text.getOriginalSourceRange(), text.getOriginalText() ); else if ( text.isNewText() ) ! { ! insertText( "\n" + indentManager_.getIndentSpacer() + "return" ); ! if ( statement.hasValue() ) ! { ! insertText( " " ); ! statement.getValue()->accept( *this ); ! } ! insertText( ";" ); ! } } *************** *** 268,271 **** --- 282,289 ---- replaceText( expression.getText().getOriginalSourceRange(), expression.getText().getOriginalText() ); + } + else if ( expression.getText().isNewText() ) + { + insertText( expression.getText().getOriginalText() ); } } Index: CodeRewriter.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CodeRewriter.h 7 Mar 2003 07:58:31 -0000 1.4 --- CodeRewriter.h 7 Mar 2003 09:41:11 -0000 1.5 *************** *** 6,14 **** #define RFTA_CODEREWRITER_H #include <rfta/parser/SourceRange.h> #include <rfta/refactoring/CodeModelVisitor.h> - #include "IndentLevelManager.h" - #include "TransformList.h" #include <string> --- 6,14 ---- #define RFTA_CODEREWRITER_H + #include "TransformList.h" #include <rfta/parser/SourceRange.h> #include <rfta/refactoring/CodeModelVisitor.h> #include <string> + #include "IndentLevelManager.h" *************** *** 76,79 **** --- 76,81 ---- void deleteText( const SourceRange &range ); + + void insertText( const std::string &content ); private: Index: CodeWriterTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CodeWriterTest.cpp 7 Mar 2003 07:58:31 -0000 1.5 --- CodeWriterTest.cpp 7 Mar 2003 09:41:11 -0000 1.6 *************** *** 115,117 **** --- 115,144 ---- + void + CodeWriterTest::testInsertReturnValueStatement() + { + source_ = " {\n" + " }"; + + generateCompound(); + + RFTA_ASSERT_EQUAL( 0, compound_->getStatementCount() ); + compound_->appendStatement( CodeModel::StatementPtr( new CodeModel::ReturnStatement( makeTrueExpression() ) ) ); + + rewriteSource(); + + std::string expectedSource = " {\n" + " return true;\n" + " }"; + RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); + } + + + CodeModel::ExpressionPtr + CodeWriterTest::makeTrueExpression() + { + return CodeModel::ExpressionPtr( new CodeModel::GenericExpression( "true" ) ); + } + + } // namespace Refactoring Index: CodeWriterTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeWriterTest.h 7 Mar 2003 07:58:31 -0000 1.3 --- CodeWriterTest.h 7 Mar 2003 09:41:11 -0000 1.4 *************** *** 6,14 **** #define RFTA_CODEWRITERTEST_H - #include "SourceBasedTestBase.h" - #include "CodeRewriter.h" #include <rfta/refactoring/CodeModelStatements.h> #include <rfta/refactoring/CodeModelExpressions.h> #include <rfta/refactoring/PlainTextDocument.h> --- 6,14 ---- #define RFTA_CODEWRITERTEST_H #include <rfta/refactoring/CodeModelStatements.h> #include <rfta/refactoring/CodeModelExpressions.h> #include <rfta/refactoring/PlainTextDocument.h> + #include "SourceBasedTestBase.h" + #include "CodeRewriter.h" *************** *** 23,26 **** --- 23,27 ---- CPPUNIT_TEST( testRewriteStatement ); CPPUNIT_TEST( testInsertStatement ); + CPPUNIT_TEST( testInsertReturnValueStatement ); CPPUNIT_TEST_SUITE_END(); *************** *** 38,45 **** --- 39,48 ---- void testRewriteStatement(); void testInsertStatement(); + void testInsertReturnValueStatement(); private: void generateCompound(); void rewriteSource(); + CodeModel::ExpressionPtr makeTrueExpression(); CodeModel::CompoundStatementPtr compound_; Index: IndentLevelManager.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IndentLevelManager.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IndentLevelManager.h 7 Mar 2003 07:58:31 -0000 1.2 --- IndentLevelManager.h 7 Mar 2003 09:41:11 -0000 1.3 *************** *** 6,9 **** --- 6,11 ---- #define RFTA_INDENTLEVELMANAGER_H + #include <rfta/refactoring/Config.h> + #include <string> namespace Refactoring |
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv7390 Modified Files: CodeRewriter.cpp CodeRewriter.h CodeWriterTest.cpp CodeWriterTest.h IndentLevelManager.cpp IndentLevelManager.h rfta.dsp Log Message: * inserted statement in compound is now correctly indented Index: CodeRewriter.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeRewriter.cpp 6 Mar 2003 22:17:58 -0000 1.3 --- CodeRewriter.cpp 7 Mar 2003 07:58:31 -0000 1.4 *************** *** 15,21 **** ! CodeRewriter::CodeRewriter( const std::string &originalSource ) : originalSource_( originalSource ) ! , indentWidth_( 2 ) , nextStatementInsertionPos_( 0 ) , currentInsertionPos_( 0 ) --- 15,22 ---- ! CodeRewriter::CodeRewriter( const std::string &originalSource, ! int indentWidth ) : originalSource_( originalSource ) ! , indentWidth_( indentWidth ) , nextStatementInsertionPos_( 0 ) , currentInsertionPos_( 0 ) *************** *** 92,96 **** { nextStatementInsertionPos_ = statement.getText().getOriginalSourceRange().getStartIndex() + 1; ! indentManager_.enterExistingStatement( nextStatementInsertionPos_ + 1 ); } --- 93,97 ---- { nextStatementInsertionPos_ = statement.getText().getOriginalSourceRange().getStartIndex() + 1; ! indentManager_.enterExistingStatement( nextStatementInsertionPos_ - 1 ); } *************** *** 208,212 **** replaceText( text.getOriginalSourceRange(), text.getOriginalText() ); else if ( text.isNewText() ) ! replaceText( getCurrentInsertionRange(), "\nreturn;" ); } --- 209,213 ---- replaceText( text.getOriginalSourceRange(), text.getOriginalText() ); else if ( text.isNewText() ) ! replaceText( getCurrentInsertionRange(), "\n" + indentManager_.getIndentSpacer() + "return;" ); } Index: CodeRewriter.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeRewriter.h 6 Mar 2003 22:17:58 -0000 1.3 --- CodeRewriter.h 7 Mar 2003 07:58:31 -0000 1.4 *************** *** 25,29 **** { public: ! CodeRewriter( const std::string &originalSource ); /// Destructor. --- 25,30 ---- { public: ! CodeRewriter( const std::string &originalSource, ! int indentWidth ); /// Destructor. Index: CodeWriterTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CodeWriterTest.cpp 6 Mar 2003 22:17:58 -0000 1.4 --- CodeWriterTest.cpp 7 Mar 2003 07:58:31 -0000 1.5 *************** *** 6,10 **** #include "stdafx.h" #include "CodeWriterTest.h" - #include "CodeRewriter.h" #include <rfta/refactoring/CodeModel.h> --- 6,9 ---- *************** *** 32,35 **** --- 31,35 ---- compound_.reset(); document_.reset(); + writer_.reset(); } *************** *** 38,41 **** --- 38,42 ---- CodeWriterTest::tearDown() { + writer_.reset(); document_.reset(); compound_.reset(); *************** *** 58,61 **** --- 59,70 ---- void + CodeWriterTest::rewriteSource() + { + writer_.reset( new CodeModel::CodeRewriter( source_, 2 ) ); + writer_->rewrite( *compound_, *document_ ); + } + + + void CodeWriterTest::testRewriteStatement() { *************** *** 76,81 **** condition.setText( "false" ); ! CodeModel::CodeRewriter writer( source_ ); ! writer.rewrite( *compound_, *document_ ); std::string expectedSource = "{\n" --- 85,89 ---- condition.setText( "false" ); ! rewriteSource(); std::string expectedSource = "{\n" *************** *** 90,95 **** CodeWriterTest::testInsertStatement() { ! source_ = "{\n" ! "}"; generateCompound(); --- 98,103 ---- CodeWriterTest::testInsertStatement() { ! source_ = " {\n" ! " }"; generateCompound(); *************** *** 98,107 **** compound_->appendStatement( CodeModel::StatementPtr( new CodeModel::ReturnStatement() ) ); ! CodeModel::CodeRewriter writer( source_ ); ! writer.rewrite( *compound_, *document_ ); ! std::string expectedSource = "{\n" ! "return;\n" ! "}"; RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); } --- 106,114 ---- compound_->appendStatement( CodeModel::StatementPtr( new CodeModel::ReturnStatement() ) ); ! rewriteSource(); ! std::string expectedSource = " {\n" ! " return;\n" ! " }"; RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); } Index: CodeWriterTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CodeWriterTest.h 6 Mar 2003 22:17:58 -0000 1.2 --- CodeWriterTest.h 7 Mar 2003 07:58:31 -0000 1.3 *************** *** 7,10 **** --- 7,11 ---- #include "SourceBasedTestBase.h" + #include "CodeRewriter.h" #include <rfta/refactoring/CodeModelStatements.h> #include <rfta/refactoring/CodeModelExpressions.h> *************** *** 40,46 **** --- 41,49 ---- private: void generateCompound(); + void rewriteSource(); CodeModel::CompoundStatementPtr compound_; boost::shared_ptr<PlainTextDocument> document_; + boost::shared_ptr<CodeModel::CodeRewriter> writer_; }; Index: IndentLevelManager.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IndentLevelManager.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IndentLevelManager.cpp 6 Mar 2003 22:17:58 -0000 1.1 --- IndentLevelManager.cpp 7 Mar 2003 07:58:31 -0000 1.2 *************** *** 28,32 **** IndentLevelManager::enterExistingStatement( int startingPos ) { ! pushIndent( findIndentLevelOf( startingPos ) ); } --- 28,32 ---- IndentLevelManager::enterExistingStatement( int startingPos ) { ! pushIndent( findIndentLevelOf( startingPos ) + indentWidth_ ); } *************** *** 46,49 **** --- 46,65 ---- { indents_.push_back( indent ); + } + + + int + IndentLevelManager::getIndentLevel() const + { + if ( indents_.empty() ) + return 0; + return indents_.back(); + } + + + const std::string + IndentLevelManager::getIndentSpacer() const + { + return std::string( getIndentLevel(), ' ' ); } Index: IndentLevelManager.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/IndentLevelManager.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IndentLevelManager.h 6 Mar 2003 22:17:59 -0000 1.1 --- IndentLevelManager.h 7 Mar 2003 07:58:31 -0000 1.2 *************** *** 45,48 **** --- 45,52 ---- void enterExistingStatement( int startingPos ); + int getIndentLevel() const; + + const std::string getIndentSpacer() const; + private: int findIndentLevelOf( int pos ) const; Index: rfta.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/rfta.dsp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** rfta.dsp 6 Mar 2003 22:17:59 -0000 1.36 --- rfta.dsp 7 Mar 2003 07:58:31 -0000 1.37 *************** *** 361,364 **** --- 361,372 ---- SOURCE=.\CodeRewriter.h # End Source File + # Begin Source File + + SOURCE=.\IndentLevelManager.cpp + # End Source File + # Begin Source File + + SOURCE=.\IndentLevelManager.h + # End Source File # End Group # Begin Group "Tests" *************** *** 940,951 **** # End Source File # End Group - # Begin Source File - - SOURCE=.\IndentLevelManager.cpp - # End Source File - # Begin Source File - - SOURCE=.\IndentLevelManager.h - # End Source File # Begin Source File --- 948,951 ---- |
From: <bl...@us...> - 2003-03-06 22:54:23
|
Update of /cvsroot/cpptool/rfta/include/rfta/refactoring In directory sc8-pr-cvs1:/tmp/cvs-serv6573/include/rfta/refactoring Modified Files: CodeModelElement.h CodeModelExpressions.h CodeModelStatements.h Log Message: * new statement insertion in compound generate correct text change Index: CodeModelElement.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelElement.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeModelElement.h 25 Dec 2002 12:13:57 -0000 1.3 --- CodeModelElement.h 6 Mar 2003 22:18:42 -0000 1.4 *************** *** 8,11 **** --- 8,12 ---- #include <rfta/refactoring/Config.h> #include <rfta/parser/SourceRange.h> + #include <rfta/parser/ASTNodeForward.h> namespace Refactoring { namespace CodeModel *************** *** 13,16 **** --- 14,45 ---- + class ElementText + { + public: + ElementText(); + explicit ElementText( const ASTNodePtr &node ); + explicit ElementText( const std::string &text ); + + void setText( const std::string &newText ); + + const std::string getOriginalText() const; + + const SourceRange getOriginalSourceRange() const; + + bool hasOriginalSourceRange() const; + + bool isOriginalText() const; + + bool isModifiedText() const; + + bool isNewText() const; + + private: + ASTNodePtr node_; + std::string newText_; + bool hasNewText_; + }; + + /// This class represents class Element *************** *** 21,25 **** virtual ~Element(); ! void setSourceRange( const SourceRange &sourceRange ); void unsetSourceRange(); --- 50,65 ---- virtual ~Element(); ! void setOriginalText( const ElementText &text ); ! void setText( const std::string &text ); ! ! const ElementText &getText() const; ! ! private: ! virtual void originalTextSet(); ! ! ElementText text_; ! ! #if 0 ! void setOriginalText( const SourceRange &sourceRange ); void unsetSourceRange(); *************** *** 36,39 **** --- 76,80 ---- SourceRange sourceRange_; bool wasReplaced_; + #endif }; Index: CodeModelExpressions.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelExpressions.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CodeModelExpressions.h 25 Dec 2002 12:13:57 -0000 1.4 --- CodeModelExpressions.h 6 Mar 2003 22:18:42 -0000 1.5 *************** *** 29,36 **** { public: ! GenericExpression( const std::string &value ); ! const std::string getValue() const; ! void setValue( const std::string &value ); // overridden from Expression --- 29,37 ---- { public: ! GenericExpression( const ElementText &value ); ! // GenericExpression( const std::string &value ); ! // const std::string getValue() const; ! // void setValue( const std::string &value ); // overridden from Expression *************** *** 38,42 **** private: ! std::string value_; }; --- 39,43 ---- private: ! // std::string value_; }; Index: CodeModelStatements.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelStatements.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CodeModelStatements.h 22 Dec 2002 15:47:00 -0000 1.2 --- CodeModelStatements.h 6 Mar 2003 22:18:42 -0000 1.3 *************** *** 9,12 **** --- 9,13 ---- #include <rfta/refactoring/CodeModelForward.h> #include <rfta/refactoring/CodeModelElement.h> + //#include <rfta/parser/SourceRange.h> #include <string> #include <vector> *************** *** 16,19 **** --- 17,47 ---- + class Change + { + public: + enum ChangeType + { + added = 0, + replaced, + removed, + unmodified + }; + + Change() + { + } + + Change( ChangeType type, + const SourceRange &oldRange = SourceRange() ) + : type_( type ) + , oldRange_( oldRange ) + { + } + + ChangeType type_; + SourceRange oldRange_; + }; + + class Statement : public Element { *************** *** 28,31 **** --- 56,71 ---- { public: + struct StatementChange : public Change + { + StatementChange( ChangeType type, + const StatementPtr &statement ) + : Change( type ) + , statement_( statement ) + { + } + + StatementPtr statement_; + }; + void removeStatementAt( int index ); *************** *** 41,44 **** --- 81,88 ---- StatementPtr getStatementAt( int index ) const; + + int getChangeCount() const; + + StatementChange getChangeAt( int changeIndex ) const; // overriden from Statement *************** *** 46,50 **** private: ! typedef std::vector<StatementPtr> Statements; Statements statements_; }; --- 90,99 ---- private: ! void originalTextSet(); ! ! int getActualIndex( int index ) const; ! ! private: ! typedef std::vector<StatementChange> Statements; Statements statements_; }; |
From: <bl...@us...> - 2003-03-06 22:44:49
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv6181/src/rfta Modified Files: CodeModel.cpp CodeModelElement.cpp CodeModelExpressions.cpp CodeModelStatements.cpp CodeRewriter.cpp CodeRewriter.h CodeWriterTest.cpp CodeWriterTest.h rfta.dsp Added Files: IndentLevelManager.cpp IndentLevelManager.h Log Message: * new statement insertion in compound generate correct text change --- NEW FILE: IndentLevelManager.cpp --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2002, Baptiste Lepilleur. // Created: 2003/03/06 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "IndentLevelManager.h" namespace Refactoring { IndentLevelManager::IndentLevelManager( const std::string &originalSource, int indentWidth ) : originalSource_( originalSource ) , indentWidth_( indentWidth ) { } IndentLevelManager::~IndentLevelManager() { } void IndentLevelManager::enterExistingStatement( int startingPos ) { pushIndent( findIndentLevelOf( startingPos ) ); } int IndentLevelManager::findIndentLevelOf( int pos ) const { int indent = 0; while ( --pos >= 0 && originalSource_[pos] != '\n' ) ++indent; return indent; } void IndentLevelManager::pushIndent( int indent ) { indents_.push_back( indent ); } } // namespace Refactoring --- NEW FILE: IndentLevelManager.h --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2002, Baptiste Lepilleur. // Created: 2003/03/06 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_INDENTLEVELMANAGER_H #define RFTA_INDENTLEVELMANAGER_H namespace Refactoring { /// Manage indent level as the code model is visited. class IndentLevelManager { public: class IndentRestorer { public: IndentRestorer( IndentLevelManager &manager ) : manager_( manager ) , count_( manager.indents_.size() ) { } ~IndentRestorer() { manager_.indents_.resize( count_ ); } IndentLevelManager &manager_; int count_; }; friend class IndentRestorer; /*! Constructs a IndentLevelManager object. */ IndentLevelManager( const std::string &originalSource, int indentWidth = 2 ); /// Destructor. virtual ~IndentLevelManager(); void enterExistingStatement( int startingPos ); private: int findIndentLevelOf( int pos ) const; void pushIndent( int indent ); private: typedef std::deque<int> Indents; Indents indents_; const std::string originalSource_; int indentWidth_; }; // Inlines methods for IndentLevelManager: // --------------------------------------- } // namespace Refactoring #endif // RFTA_INDENTLEVELMANAGER_H Index: CodeModel.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModel.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeModel.cpp 25 Dec 2002 12:13:56 -0000 1.3 --- CodeModel.cpp 6 Mar 2003 22:17:56 -0000 1.4 *************** *** 70,74 **** { CompoundStatementPtr compound( new CompoundStatement() ); ! compound->setSourceRange( compoundNode->getRange() ); for ( int index = 0; index < compoundNode->getChildCount(); ++index ) --- 70,75 ---- { CompoundStatementPtr compound( new CompoundStatement() ); ! // compound->setSourceRange( compoundNode->getRange() ); ! compound->setOriginalText( ElementText( compoundNode ) ); for ( int index = 0; index < compoundNode->getChildCount(); ++index ) *************** *** 97,101 **** GeneratorFunction function = it->second; StatementPtr statement = (this->*function)( statementNode ); ! statement->setSourceRange( statementNode->getRange() ); return statement; } --- 98,103 ---- GeneratorFunction function = it->second; StatementPtr statement = (this->*function)( statementNode ); ! // statement->setSourceRange( statementNode->getRange() ); ! statement->setOriginalText( ElementText( statementNode ) ); return statement; } *************** *** 306,311 **** { std::string value = expressionNode->getOriginalText(); ! ExpressionPtr expression( new GenericExpression( value ) ); ! expression->setSourceRange( expressionNode->getRange() ); return expression; } --- 308,314 ---- { std::string value = expressionNode->getOriginalText(); ! ExpressionPtr expression( new GenericExpression( ElementText( value ) ) ); ! // expression->setSourceRange( expressionNode->getRange() ); ! expression->setOriginalText( ElementText( expressionNode ) ); return expression; } *************** *** 316,320 **** { ExpressionPtr expression( new NullExpression() ); ! expression->setSourceRange( expressionNode->getRange() ); return expression; } --- 319,324 ---- { ExpressionPtr expression( new NullExpression() ); ! // expression->setSourceRange( expressionNode->getRange() ); ! expression->setOriginalText( ElementText( expressionNode ) ); return expression; } *************** *** 326,330 **** const std::string primaryType( getDeclaratorPrimaryType( expression ) ); DeclaratorExpressionPtr declaratorExpression( new DeclaratorExpression( primaryType ) ); ! declaratorExpression->setSourceRange( expression->getRange() ); for ( int index = 0; index < expression->getChildCount(); ++index ) --- 330,335 ---- const std::string primaryType( getDeclaratorPrimaryType( expression ) ); DeclaratorExpressionPtr declaratorExpression( new DeclaratorExpression( primaryType ) ); ! declaratorExpression->setOriginalText( ElementText( expression ) ); ! // declaratorExpression->setSourceRange( expression->getRange() ); for ( int index = 0; index < expression->getChildCount(); ++index ) *************** *** 382,386 **** initializerNode->getProperty( ASTNodeProperties::valueProperty ); ExpressionPtr value = generateExpression( valueNode ); ! value->setSourceRange( valueNode->getRange() ); ExpressionPtr initializer; --- 387,392 ---- initializerNode->getProperty( ASTNodeProperties::valueProperty ); ExpressionPtr value = generateExpression( valueNode ); ! value->setOriginalText( ElementText( valueNode ) ); ! // value->setSourceRange( valueNode->getRange() ); ExpressionPtr initializer; *************** *** 390,394 **** initializer.reset( new ConstructorInitializerExpression( value ) ); ! initializer->setSourceRange( initializerNode->getRange() ); return initializer; --- 396,401 ---- initializer.reset( new ConstructorInitializerExpression( value ) ); ! // initializer->setSourceRange( initializerNode->getRange() ); ! initializer->setOriginalText( ElementText( initializerNode ) ); return initializer; Index: CodeModelElement.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelElement.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeModelElement.cpp 25 Dec 2002 12:13:56 -0000 1.3 --- CodeModelElement.cpp 6 Mar 2003 22:17:57 -0000 1.4 *************** *** 6,9 **** --- 6,10 ---- #include "stdafx.h" #include <rfta/refactoring/CodeModelElement.h> + #include <rfta/parser/ASTNode.h> *************** *** 12,19 **** Element::Element() ! : wasReplaced_( false ) { ! unsetSourceRange(); } --- 13,96 ---- + ElementText::ElementText() + : hasNewText_( true ) + { + } + + + ElementText::ElementText( const ASTNodePtr &node ) + : node_( node ) + , hasNewText_( false ) + { + } + + + ElementText::ElementText( const std::string &text ) + : newText_( text ) + , hasNewText_( true ) + { + } + + + void + ElementText::setText( const std::string &newText ) + { + hasNewText_ = true; + newText_ = newText; + } + + + const std::string + ElementText::getOriginalText() const + { + if ( hasNewText_ ) + return newText_; + return node_->getOriginalText(); + } + + + const SourceRange + ElementText::getOriginalSourceRange() const + { + if ( node_ ) + return node_->getRange(); + return SourceRange(); + } + + + bool + ElementText::hasOriginalSourceRange() const + { + return node_; + } + + + bool + ElementText::isOriginalText() const + { + return node_ && !hasNewText_; + } + + + bool + ElementText::isModifiedText() const + { + return node_ && hasNewText_; + } + + + bool + ElementText::isNewText() const + { + return !node_ && hasNewText_ ; + } + + + + Element::Element() ! // : wasReplaced_( false ) { ! // unsetSourceRange(); } *************** *** 25,28 **** --- 102,134 ---- void + Element::setOriginalText( const ElementText &text ) + { + text_ = text; + originalTextSet(); + } + + + void + Element::setText( const std::string &text ) + { + text_.setText( text ); + } + + + const ElementText & + Element::getText() const + { + return text_; + } + + + void + Element::originalTextSet() + { + } + + + #if 0 + void Element::setSourceRange( const SourceRange &sourceRange ) { *************** *** 65,68 **** --- 171,175 ---- wasReplaced_ = true; } + #endif Index: CodeModelExpressions.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelExpressions.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeModelExpressions.cpp 25 Dec 2002 12:13:56 -0000 1.3 --- CodeModelExpressions.cpp 6 Mar 2003 22:17:57 -0000 1.4 *************** *** 16,19 **** --- 16,25 ---- + GenericExpression::GenericExpression( const ElementText &value ) + { + setOriginalText( value ); + } + + /* GenericExpression::GenericExpression( const std::string &value ) : value_( value ) *************** *** 35,39 **** value_ = value; } ! void --- 41,45 ---- value_ = value; } ! */ void Index: CodeModelStatements.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelStatements.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CodeModelStatements.cpp 22 Dec 2002 15:47:34 -0000 1.2 --- CodeModelStatements.cpp 6 Mar 2003 22:17:57 -0000 1.3 *************** *** 7,10 **** --- 7,11 ---- #include <rfta/refactoring/CodeModelStatements.h> #include <rfta/refactoring/CodeModelVisitor.h> + #include <stdexcept> *************** *** 21,25 **** CompoundStatement::removeStatementAt( int index ) { ! statements_.erase( statements_.begin() + index ); } --- 22,29 ---- CompoundStatement::removeStatementAt( int index ) { ! StatementChange &change = statements_.at( getActualIndex( index ) ); ! change.type_ = Change::removed; ! change.oldRange_ = change.statement_->getText().getOriginalSourceRange(); ! change.statement_.reset(); } *************** *** 28,32 **** CompoundStatement::appendStatement( const StatementPtr &statement ) { ! statements_.push_back( statement ); } --- 32,36 ---- CompoundStatement::appendStatement( const StatementPtr &statement ) { ! statements_.push_back( StatementChange( Change::added, statement ) ); } *************** *** 36,40 **** const StatementPtr &statement ) { ! statements_.insert( statements_.begin() + index, statement ); } --- 40,45 ---- const StatementPtr &statement ) { ! statements_.insert( statements_.begin() + getActualIndex(index), ! StatementChange( Change::added, statement ) ); } *************** *** 44,48 **** const StatementPtr &statement ) { ! statements_.at( index ) = statement; } --- 49,56 ---- const StatementPtr &statement ) { ! StatementChange &change = statements_.at( getActualIndex( index ) ); ! change.type_ = Change::replaced; ! change.oldRange_ = change.statement_->getText().getOriginalSourceRange(); ! change.statement_ = statement; } *************** *** 51,55 **** CompoundStatement::getStatementCount() const { ! return statements_.size(); } --- 59,70 ---- CompoundStatement::getStatementCount() const { ! int count = 0; ! for ( Statements::const_iterator it = statements_.begin(); it != statements_.end(); ++it ) ! { ! if ( it->type_ != Change::removed ) ! ++count; ! } ! ! return count; } *************** *** 58,62 **** CompoundStatement::getStatementAt( int index ) const { ! return statements_.at( index ); } --- 73,91 ---- CompoundStatement::getStatementAt( int index ) const { ! return statements_.at( getActualIndex(index ) ).statement_; ! } ! ! ! int ! CompoundStatement::getActualIndex( int index ) const ! { ! int count = 0; ! for ( Statements::const_iterator it = statements_.begin(); it != statements_.end(); ++it ) ! { ! if ( it->type_ != Change::removed && count++ == index ) ! return it - statements_.begin(); ! } ! ! throw std::out_of_range( "index out of range for CompoundStatement::getActualIndex()" ); } *************** *** 67,70 **** --- 96,122 ---- visitor.visit( *this ); } + + + void + CompoundStatement::originalTextSet() + { + for ( Statements::iterator it = statements_.begin(); it != statements_.end(); ++it ) + it->type_ = Change::unmodified; + } + + + int + CompoundStatement::getChangeCount() const + { + return statements_.size(); + } + + + CompoundStatement::StatementChange + CompoundStatement::getChangeAt( int changeIndex ) const + { + return statements_.at( changeIndex ); + } + Index: CodeRewriter.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CodeRewriter.cpp 25 Dec 2002 12:13:56 -0000 1.2 --- CodeRewriter.cpp 6 Mar 2003 22:17:58 -0000 1.3 *************** *** 17,20 **** --- 17,24 ---- CodeRewriter::CodeRewriter( const std::string &originalSource ) : originalSource_( originalSource ) + , indentWidth_( 2 ) + , nextStatementInsertionPos_( 0 ) + , currentInsertionPos_( 0 ) + , indentManager_( originalSource ) { } *************** *** 36,39 **** --- 40,75 ---- + SourceRange + CodeRewriter::getCurrentInsertionRange() const + { + return SourceRange( currentInsertionPos_, 0 ); + } + + + void + CodeRewriter::replaceText( const SourceRange &range, + const std::string &content ) + { + transforms_.add( *new ReplaceTextTransform( range, content ) ); + } + + + void + CodeRewriter::deleteText( const SourceRange &range ) + { + replaceText( range, "" ); + } + + + void + CodeRewriter::setPreviousStatementEnd( CompoundStatement &statement, + int subStatementIndex ) + { + if ( subStatementIndex == 0 ) + { + } + } + + void CodeRewriter::visit( BreakStatement &statement ) *************** *** 51,56 **** CodeRewriter::visit( CompoundStatement &statement ) { ! for ( int index =0; index < statement.getStatementCount(); ++index ) ! statement.getStatementAt( index )->accept( *this ); } --- 87,116 ---- CodeRewriter::visit( CompoundStatement &statement ) { ! IndentLevelManager::IndentRestorer restorer( indentManager_ ); ! ! if ( statement.getText().hasOriginalSourceRange() ) ! { ! nextStatementInsertionPos_ = statement.getText().getOriginalSourceRange().getStartIndex() + 1; ! indentManager_.enterExistingStatement( nextStatementInsertionPos_ + 1 ); ! } ! ! for ( int index =0; index < statement.getChangeCount(); ++index ) ! { ! CompoundStatement::StatementChange change = statement.getChangeAt( index ); ! if ( change.type_ == Change::removed ) ! { ! deleteText( change.statement_->getText().getOriginalSourceRange() ); ! continue; ! } ! ! currentInsertionPos_ = nextStatementInsertionPos_; ! ! if ( change.type_ == Change::unmodified ) ! nextStatementInsertionPos_ = change.statement_->getText().getOriginalSourceRange().getEndIndex(); ! else if ( change.type_ == Change::replaced ) ! deleteText( change.statement_->getText().getOriginalSourceRange() ); ! ! change.statement_->accept( *this ); ! } } *************** *** 141,144 **** --- 201,212 ---- CodeRewriter::visit( ReturnStatement &statement ) { + const ElementText &text = statement.getText(); + if ( text.isOriginalText() ) + return; + + if ( text.isModifiedText() ) + replaceText( text.getOriginalSourceRange(), text.getOriginalText() ); + else if ( text.isNewText() ) + replaceText( getCurrentInsertionRange(), "\nreturn;" ); } *************** *** 195,202 **** CodeRewriter::visit( GenericExpression &expression ) { ! if ( expression.wasReplaced() ) { ! transforms_.add( *new ReplaceTextTransform( expression.getSourceRange(), ! expression.getValue() ) ); } } --- 263,270 ---- CodeRewriter::visit( GenericExpression &expression ) { ! if ( expression.getText().isModifiedText() ) { ! replaceText( expression.getText().getOriginalSourceRange(), ! expression.getText().getOriginalText() ); } } Index: CodeRewriter.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CodeRewriter.h 25 Dec 2002 12:13:56 -0000 1.2 --- CodeRewriter.h 6 Mar 2003 22:17:58 -0000 1.3 *************** *** 6,11 **** --- 6,15 ---- #define RFTA_CODEREWRITER_H + #include <rfta/parser/SourceRange.h> #include <rfta/refactoring/CodeModelVisitor.h> + #include "IndentLevelManager.h" #include "TransformList.h" + #include <string> + namespace Refactoring { *************** *** 61,67 **** --- 65,86 ---- void visit( NullExpression &expression ); + void setPreviousStatementEnd( CompoundStatement &statement, + int subStatementIndex ); + private: + SourceRange getCurrentInsertionRange() const; + + void replaceText( const SourceRange &range, + const std::string &content ); + + void deleteText( const SourceRange &range ); + + private: + IndentLevelManager indentManager_; TransformList transforms_; const std::string originalSource_; + int nextStatementInsertionPos_; + int currentInsertionPos_; + int indentWidth_; }; Index: CodeWriterTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeWriterTest.cpp 25 Dec 2002 22:40:51 -0000 1.3 --- CodeWriterTest.cpp 6 Mar 2003 22:17:58 -0000 1.4 *************** *** 47,51 **** CodeWriterTest::generateCompound() { ! parse(); ASTNodePtr compoundNode = sourceNode_->getChildAt(0); --- 47,51 ---- CodeWriterTest::generateCompound() { ! blankAndParse(); ASTNodePtr compoundNode = sourceNode_->getChildAt(0); *************** *** 60,66 **** CodeWriterTest::testRewriteStatement() { ! source_ = "{" ! " if ( true )" ! " return;" "}"; --- 60,66 ---- CodeWriterTest::testRewriteStatement() { ! source_ = "{\n" ! " if ( true )\n" ! " return;\n" "}"; *************** *** 74,85 **** static_cast<CodeModel::GenericExpression &>( *ifStatement.getCondition() ); ! condition.setValue( "false" ); CodeModel::CodeRewriter writer( source_ ); writer.rewrite( *compound_, *document_ ); ! std::string expectedSource = "{" ! " if ( false )" ! " return;" "}"; RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); --- 74,106 ---- static_cast<CodeModel::GenericExpression &>( *ifStatement.getCondition() ); ! condition.setText( "false" ); CodeModel::CodeRewriter writer( source_ ); writer.rewrite( *compound_, *document_ ); ! std::string expectedSource = "{\n" ! " if ( false )\n" ! " return;\n" ! "}"; ! RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); ! } ! ! ! void ! CodeWriterTest::testInsertStatement() ! { ! source_ = "{\n" ! "}"; ! ! generateCompound(); ! ! RFTA_ASSERT_EQUAL( 0, compound_->getStatementCount() ); ! compound_->appendStatement( CodeModel::StatementPtr( new CodeModel::ReturnStatement() ) ); ! ! CodeModel::CodeRewriter writer( source_ ); ! writer.rewrite( *compound_, *document_ ); ! ! std::string expectedSource = "{\n" ! "return;\n" "}"; RFTA_ASSERT_EQUAL( expectedSource, document_->getAllText() ); Index: CodeWriterTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CodeWriterTest.h 22 Dec 2002 15:47:01 -0000 1.1 --- CodeWriterTest.h 6 Mar 2003 22:17:58 -0000 1.2 *************** *** 21,24 **** --- 21,25 ---- CPPUNIT_TEST_SUITE( CodeWriterTest ); CPPUNIT_TEST( testRewriteStatement ); + CPPUNIT_TEST( testInsertStatement ); CPPUNIT_TEST_SUITE_END(); *************** *** 35,38 **** --- 36,40 ---- void testRewriteStatement(); + void testInsertStatement(); private: Index: rfta.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/rfta.dsp,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** rfta.dsp 31 Jan 2003 21:37:03 -0000 1.35 --- rfta.dsp 6 Mar 2003 22:17:59 -0000 1.36 *************** *** 942,945 **** --- 942,953 ---- # Begin Source File + SOURCE=.\IndentLevelManager.cpp + # End Source File + # Begin Source File + + SOURCE=.\IndentLevelManager.h + # End Source File + # Begin Source File + SOURCE=.\Makefile.am # End Source File |
From: <bl...@us...> - 2003-03-06 22:38:39
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv6573/src/rfta Modified Files: SourceBasedTestBase.cpp SourceBasedTestBase.h TransformListTest.cpp TransformListTest.h Log Message: * new statement insertion in compound generate correct text change Index: SourceBasedTestBase.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/SourceBasedTestBase.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SourceBasedTestBase.cpp 22 Dec 2002 16:03:52 -0000 1.7 --- SourceBasedTestBase.cpp 6 Mar 2003 22:18:41 -0000 1.8 *************** *** 9,12 **** --- 9,13 ---- #include <rfta/parser/ASTNodes.h> #include <rfta/parser/MaxLODMutator.h> + #include <rfta/parser/NonSemanticBlanker.h> #include <rfta/parser/ParseContext.h> #include <rfta/parser/StatementsParser.h> *************** *** 48,51 **** --- 49,73 ---- { sourceNode_ = SourceASTNode::create( source_, source_ ); + ParseContext context( sourceNode_ ); + StatementsParser parser( context, + sourceNode_->getBlankedSourceStart(), + sourceNode_->getBlankedSourceEnd() ); + CPPUNIT_ASSERT( parser.tryParse() ); + + // don't bother with lazy parsing for now... + MaxLODMutator mutator; + mutator.mutate( sourceNode_, sourceNode_ ); + } + + + void + SourceBasedTestBase::blankAndParse() + { + std::string blankedSource; + NullPPDirectiveListener nullListener; + NonSemanticBlanker blanker( source_, blankedSource, nullListener ); + blanker.blank(); + + sourceNode_ = SourceASTNode::create( blankedSource, source_ ); ParseContext context( sourceNode_ ); StatementsParser parser( context, Index: SourceBasedTestBase.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/SourceBasedTestBase.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SourceBasedTestBase.h 22 Dec 2002 16:03:52 -0000 1.5 --- SourceBasedTestBase.h 6 Mar 2003 22:18:41 -0000 1.6 *************** *** 33,36 **** --- 33,37 ---- protected: void parse(); + void blankAndParse(); ASTNodePtr getIdentifierNode( const SourceRange &range ); ASTNodePtr getIdentifierNode( const std::string &identifierRangeKey ); Index: TransformListTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/TransformListTest.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TransformListTest.cpp 22 Dec 2002 16:03:53 -0000 1.4 --- TransformListTest.cpp 6 Mar 2003 22:18:41 -0000 1.5 *************** *** 124,126 **** --- 124,146 ---- + void + TransformListTest::testPreserveOrder() + { + const std::string line1( " return 2;" ); + transforms_->add( *new ReplaceTextTransform( SourceRange( 0,0 ), "{" ) ); + transforms_->add( *new ReplaceTextTransform( SourceRange( 0,0 ), line1 ) ); + transforms_->add( *new ReplaceTextTransform( SourceRange( 0,0 ), "}" ) ); + document_->expectSetSelectionRange( SourceRange( 0,0 ) ); + document_->expectReplaceSelection( "{" ); + document_->expectSetSelectionRange( SourceRange( 1,0 ) ); + document_->expectReplaceSelection( line1 ); + document_->expectSetSelectionRange( SourceRange( 1+line1.length(),0 ) ); + document_->expectReplaceSelection( "}" ); + + transforms_->apply( *document_ ); + + document_->verify(); + } + + } // namespace Refactoring Index: TransformListTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/TransformListTest.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TransformListTest.h 27 Oct 2002 13:28:23 -0000 1.3 --- TransformListTest.h 6 Mar 2003 22:18:41 -0000 1.4 *************** *** 26,29 **** --- 26,30 ---- CPPUNIT_TEST( testApplyTwoOrdered ); CPPUNIT_TEST( testApplyThreeMissordered ); + CPPUNIT_TEST( testPreserveOrder ); CPPUNIT_TEST_SUITE_END(); *************** *** 44,47 **** --- 45,49 ---- void testApplyTwoOrdered(); void testApplyThreeMissordered(); + void testPreserveOrder(); private: |
From: <net...@us...> - 2003-02-15 13:50:17
|
Update of /cvsroot/cpptool/rfta/bin/eclipseplugin In directory sc8-pr-cvs1:/tmp/cvs-serv2753 Added Files: plugin.xml Log Message: -- eclipse plugin settings for testing --- NEW FILE: plugin.xml --- <?xml version="1.0" encoding="UTF-8"?> <plugin id="org.eclipse.cpprefactoring" name="Helloworld Plug-in" version="0.0.0" provider-name="My" class="org.eclipse.cpprefactoring.RefactorPluginMain"> <runtime> <library name="cpprefactoring.jar"/> </runtime> <requires> <import plugin="org.eclipse.core.resources"/> <import plugin="org.eclipse.ui"/> </requires> <extension point="org.eclipse.ui.actionSets"> <actionSet label="Cpp Refactoring Actions" visible="true" id="org.eclipse.cpprefactoring.actionSet"> <menu label="CppRefactoring" id="CppRefactoringMenu"> <separator name="refactoringGroup"> </separator> </menu> <action label="&RenameLocaleVariableAction" icon="icons/RenameVariable.gif" tooltip="Rename a local variable" class="org.eclipse.cpprefactoring.actions.RenameLocaleVariableAction" menubarPath="CppRefactoringMenu/refactoringGroup" toolbarPath="Normal" id="org.eclipse.cpprefactoring.actions.RenameLocaleVariableAction.Menu"> </action> </actionSet> </extension> <extension point="org.eclipse.ui.perspectiveExtensions"> <perspectiveExtension targetID="org.eclipse.ui.resourcePerspective"> <actionSet id="org.eclipse.cpprefactoring.actionSet"> </actionSet> </perspectiveExtension> </extension> <extension point="org.eclipse.ui.popupMenus"> <viewerContribution targetID="#CEditorContext" id="RenameLocaleVariableAction"> <action label="Rename Local Variable" icon="icons/RenameVariable.gif" class="org.eclipse.cpprefactoring.actions.RenameLocaleVariableAction" menubarPath="CppRefactoring" id="org.eclipse.cpprefactoring.actions.RenameLocaleVariableAction.Popup"> </action> </viewerContribution> </extension> </plugin> |
From: <net...@us...> - 2003-02-15 13:49:32
|
Update of /cvsroot/cpptool/rfta/bin/eclipseplugin In directory sc8-pr-cvs1:/tmp/cvs-serv2398 Added Files: rftaparser_mdr.ext rfta_mdr.ext eclipseplugin.dll cpprefactoring.jar Log Message: -- binaries of eclipse plugin for testing --- NEW FILE: rftaparser_mdr.ext --- (This appears to be a binary file; contents omitted.) --- NEW FILE: rfta_mdr.ext --- (This appears to be a binary file; contents omitted.) --- NEW FILE: eclipseplugin.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cpprefactoring.jar --- (This appears to be a binary file; contents omitted.) |
From: <net...@us...> - 2003-02-15 13:47:29
|
Update of /cvsroot/cpptool/rfta/bin/eclipseplugin In directory sc8-pr-cvs1:/tmp/cvs-serv1945/eclipseplugin Log Message: Directory /cvsroot/cpptool/rfta/bin/eclipseplugin added to the repository |