|
From: <net...@us...> - 2002-12-30 10:44:13
|
Update of /cvsroot/cpptool/rfta/src/rfta
In directory sc8-pr-cvs1:/tmp/cvs-serv30300/rfta
Modified Files:
rfta.dsp InlineTempRefactoringTest.h
InlineTempRefactoringTest.cpp InlineTempRefactoring.cpp
Log Message:
-- bugfix + moved header to global include
Index: rfta.dsp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/rfta.dsp,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** rfta.dsp 28 Dec 2002 10:40:23 -0000 1.32
--- rfta.dsp 30 Dec 2002 10:44:08 -0000 1.33
***************
*** 219,223 ****
# Begin Source File
! SOURCE=.\InlineTempRefactoring.h
# End Source File
# Begin Source File
--- 219,223 ----
# Begin Source File
! SOURCE=..\..\include\rfta\refactoring\InlineTempRefactoring.h
# End Source File
# Begin Source File
Index: InlineTempRefactoringTest.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/InlineTempRefactoringTest.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** InlineTempRefactoringTest.h 28 Dec 2002 10:44:39 -0000 1.1
--- InlineTempRefactoringTest.h 30 Dec 2002 10:44:08 -0000 1.2
***************
*** 19,22 ****
--- 19,23 ----
CPPUNIT_TEST_SUITE( InlineTempRefactoringTest );
CPPUNIT_TEST( testEasiestCase );
+ CPPUNIT_TEST( testSelectAtUse );
CPPUNIT_TEST( testThrowNoInitializer );
CPPUNIT_TEST( testThrowInitializerNotSupported );
***************
*** 41,44 ****
--- 42,46 ----
void testEasiestCase();
+ void testSelectAtUse();
void testThrowNoInitializer();
void testThrowInitializerNotSupported();
Index: InlineTempRefactoringTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/InlineTempRefactoringTest.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** InlineTempRefactoringTest.cpp 28 Dec 2002 10:44:39 -0000 1.1
--- InlineTempRefactoringTest.cpp 30 Dec 2002 10:44:08 -0000 1.2
***************
*** 6,10 ****
#include "stdafx.h"
#include "InlineTempRefactoringTest.h"
! #include "InlineTempRefactoring.h"
#include <rfta/refactoring/PlainTextDocument.h>
--- 6,10 ----
#include "stdafx.h"
#include "InlineTempRefactoringTest.h"
! #include <rfta/refactoring/InlineTempRefactoring.h>
#include <rfta/refactoring/PlainTextDocument.h>
***************
*** 50,54 ****
InlineTempRefactoring refactoring( *document_,
selectionIndex );
! refactoring.apply( );
CPPUNIT_ASSERT_EQUAL( LocaleVariableName, refactoring.getVariableName() );
}
--- 50,54 ----
InlineTempRefactoring refactoring( *document_,
selectionIndex );
! refactoring.apply( refactoring.areBracesSuggested() );
CPPUNIT_ASSERT_EQUAL( LocaleVariableName, refactoring.getVariableName() );
}
***************
*** 70,74 ****
InlineTempRefactoring refactoring( *document_,
selectionIndex );
! refactoring.apply( );
std::string failure = std::string("Test fails since it expects the refactoring error '") + expected.what() + "'.";
--- 70,74 ----
InlineTempRefactoring refactoring( *document_,
selectionIndex );
! refactoring.apply( refactoring.areBracesSuggested() );
std::string failure = std::string("Test fails since it expects the refactoring error '") + expected.what() + "'.";
***************
*** 125,128 ****
--- 125,151 ----
builder_->addKeyingMid( " double ", "x"," = 4;", "selection" );
builder_->add( "y += y * x;");
+ builder_->add(
+ " return x * getQuantity();"
+ "}" );
+
+ applyRefactoring( "x" );
+
+ std::string expectedSource(
+ "{"
+ " double y;"
+ " y += y * 4;"
+ " return 4 * getQuantity();"
+ "}" );
+ std::string actualSource( document_->getAllText() );
+ RFTA_ASSERT_EQUAL( expectedSource, actualSource );
+ }
+
+ void
+ InlineTempRefactoringTest::testSelectAtUse()
+ {
+ builder_->add(
+ "{"
+ " double y;double x=4;" );
+ builder_->addKeyingMid( " y += y * ", "x",";", "selection" );
builder_->add(
" return x * getQuantity();"
Index: InlineTempRefactoring.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/InlineTempRefactoring.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** InlineTempRefactoring.cpp 28 Dec 2002 10:52:15 -0000 1.2
--- InlineTempRefactoring.cpp 30 Dec 2002 10:44:08 -0000 1.3
***************
*** 5,9 ****
#include "stdafx.h"
! #include "InlineTempRefactoring.h"
#include <rfta/refactoring/RefactoringError.h>
#include <rfta/refactoring/TextDocument.h>
--- 5,9 ----
#include "stdafx.h"
! #include <rfta/refactoring/InlineTempRefactoring.h>
#include <rfta/refactoring/RefactoringError.h>
#include <rfta/refactoring/TextDocument.h>
***************
*** 138,145 ****
++it )
{
! if ( *it != localeVariableNode_)
! {
! // get the expression this variable belongs to:
! ASTNodePtr parentExpr = boost::make_shared((*it)->getParentNode());
bool go_deeper = false;
do {
--- 138,145 ----
++it )
{
! // get the expression this variable belongs to:
! ASTNodePtr parentExpr = boost::make_shared((*it)->getParentNode());
! if ( parentExpr != temporaryDecl)
! {
bool go_deeper = false;
do {
***************
*** 297,301 ****
void
! InlineTempRefactoring::apply()
{
TransformList transforms;
--- 297,301 ----
void
! InlineTempRefactoring::apply( bool doAddBraces )
{
TransformList transforms;
***************
*** 309,313 ****
std::string newtext;
! if (isInitializerAtomic())
{
newtext = initValue_->getOriginalText();
--- 309,313 ----
std::string newtext;
! if (!doAddBraces)
{
newtext = initValue_->getOriginalText();
***************
*** 322,326 ****
++it )
{
! if ( *it != localeVariableNode_)
{
SourceRange range = (*it)->getRange();
--- 322,327 ----
++it )
{
! ASTNodePtr parentExpr = boost::make_shared((*it)->getParentNode());
! if ( parentExpr != temporaryDecl)
{
SourceRange range = (*it)->getRange();
|