|
From: <bl...@us...> - 2003-03-16 13:15:26
|
Update of /cvsroot/cpptool/rfta/src/rfta
In directory sc8-pr-cvs1:/tmp/cvs-serv25283/src/rfta
Modified Files:
CodeModel.cpp CodeModelElement.cpp CodeModelExpressions.cpp
CodeRewriter.cpp CodeWriterTest.cpp
Log Message:
* refactored so that GenericExpression don't rely on ElementText::setText().
Index: CodeModel.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModel.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CodeModel.cpp 8 Mar 2003 13:11:42 -0000 1.5
--- CodeModel.cpp 16 Mar 2003 13:15:22 -0000 1.6
***************
*** 308,313 ****
{
std::string value = expressionNode->getOriginalText();
! ExpressionPtr expression( new GenericExpression( ElementText( value ) ) );
! // expression->setSourceRange( expressionNode->getRange() );
expression->setOriginalText( ElementText( expressionNode ) );
return expression;
--- 308,312 ----
{
std::string value = expressionNode->getOriginalText();
! ExpressionPtr expression( new GenericExpression() );
expression->setOriginalText( ElementText( expressionNode ) );
return expression;
Index: CodeModelElement.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelElement.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CodeModelElement.cpp 7 Mar 2003 09:41:11 -0000 1.5
--- CodeModelElement.cpp 16 Mar 2003 13:15:22 -0000 1.6
***************
*** 32,36 ****
}
!
void
ElementText::setText( const std::string &newText )
--- 32,36 ----
}
! /*
void
ElementText::setText( const std::string &newText )
***************
*** 39,43 ****
newText_ = newText;
}
!
const std::string
--- 39,43 ----
newText_ = newText;
}
! */
const std::string
***************
*** 66,96 ****
- 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();
}
--- 66,71 ----
***************
*** 108,112 ****
}
!
void
Element::setText( const std::string &text )
--- 83,87 ----
}
! /*
void
Element::setText( const std::string &text )
***************
*** 114,118 ****
text_.setText( text );
}
!
const ElementText &
--- 89,93 ----
text_.setText( text );
}
! */
const ElementText &
Index: CodeModelExpressions.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelExpressions.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CodeModelExpressions.cpp 7 Mar 2003 09:41:11 -0000 1.5
--- CodeModelExpressions.cpp 16 Mar 2003 13:15:22 -0000 1.6
***************
*** 16,34 ****
- GenericExpression::GenericExpression( const ElementText &value )
- {
- setOriginalText( value );
- }
-
-
GenericExpression::GenericExpression( const std::string &value )
{
- setText( value );
}
! /*
const std::string
! GenericExpression::getValue() const
{
return value_;
}
--- 16,31 ----
GenericExpression::GenericExpression( const std::string &value )
+ : value_( value )
+ , valueChange_( Change( Change::replaced ) )
{
}
!
const std::string
! GenericExpression::getTextValue() const
{
+ if ( valueChange_.isUnmodified() )
+ return getText().getOriginalText();
return value_;
}
***************
*** 36,45 ****
void
! GenericExpression::setValue( const std::string &value )
{
! replace();
value_ = value;
}
! */
void
--- 33,60 ----
void
! GenericExpression::setValueText( const std::string &value )
{
! if ( valueChange_.isUnmodified() )
! {
! valueChange_.type_ = Change::replaced;
! valueChange_.oldRange_ = getText().getOriginalSourceRange();
! }
value_ = value;
}
!
!
! Change
! GenericExpression::getValueChange() const
! {
! return valueChange_;
! }
!
!
! void
! GenericExpression::originalTextSet()
! {
! valueChange_.type_ = Change::unmodified;
! }
!
void
Index: CodeRewriter.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** CodeRewriter.cpp 16 Mar 2003 12:24:47 -0000 1.19
--- CodeRewriter.cpp 16 Mar 2003 13:15:22 -0000 1.20
***************
*** 491,513 ****
{
if ( isInserting() )
! insertText( expression.getText().getOriginalText() );
! else if ( expression.getText().isModifiedText() )
! {
! replaceText( expression.getText().getOriginalSourceRange(),
! expression.getText().getOriginalText() );
! }
!
!
! #if 0
! if ( expression.getText().isModifiedText() )
{
replaceText( expression.getText().getOriginalSourceRange(),
! expression.getText().getOriginalText() );
! }
! else if ( expression.getText().isNewText() )
! {
! insertText( expression.getText().getOriginalText() );
}
- #endif
}
--- 491,500 ----
{
if ( isInserting() )
! insertText( expression.getTextValue() );
! else
{
replaceText( expression.getText().getOriginalSourceRange(),
! expression.getTextValue() );
}
}
Index: CodeWriterTest.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** CodeWriterTest.cpp 16 Mar 2003 12:24:47 -0000 1.23
--- CodeWriterTest.cpp 16 Mar 2003 13:15:22 -0000 1.24
***************
*** 55,59 ****
dynamic_cast<CodeModel::GenericExpression &>(
*ifStatement.getCondition() );
! condition.setText( "false" );
rewriteSource();
--- 55,59 ----
dynamic_cast<CodeModel::GenericExpression &>(
*ifStatement.getCondition() );
! condition.setValueText( "false" );
rewriteSource();
|