Update of /cvsroot/cpptool/rfta/src/rftavc7addin
In directory sc8-pr-cvs1:/tmp/cvs-serv18210/src/rftavc7addin
Modified Files:
Connect.cpp VC7TextDocument.cpp VC7TextDocument.h
Log Message:
* fixed bug in VC7TextDocument. RenameLocaleVariable refactoring is now working.
Index: Connect.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/Connect.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Connect.cpp 14 May 2003 19:41:55 -0000 1.4
--- Connect.cpp 15 May 2003 07:06:46 -0000 1.5
***************
*** 6,9 ****
--- 6,13 ----
#include "TextSelectionHelper.h"
#include "VC7TextDocument.h"
+ #include <rfta/refactoring/RefactoringError.h>
+ #include <rfta/refactoring/RenameTempRefactoring.h>
+ #include <rfta/refactoring/InlineTempRefactoring.h>
+ #include <rfta/refactoring/SplitTempRefactoring.h>
extern CAddInModule _AtlModule;
***************
*** 369,372 ****
--- 373,404 ----
const Refactoring::SourceRange &selectedRange )
{
+ try
+ {
+ Refactoring::RenameTempRefactoring refactoring( document,
+ selectedRange.getStartIndex() );
+
+ RenameLocaleVariableDialog dialog;
+ dialog.oldName_ = refactoring.getOldVariableName().c_str();
+ dialog.newName_ = refactoring.getOldVariableName().c_str();
+
+ if ( dialog.DoModal() == IDOK )
+ refactoring.apply( (LPCTSTR)dialog.newName_ );
+ }
+ catch ( Refactoring::RefactoringError &e )
+ {
+ CString message( "An error occurred during refactoring:\n" );
+ message += e.what();
+
+ AfxMessageBox( message );
+ CString msg;
+ msg.Format( "Selected range: %s\nSelected Text: %s\nAll Text: %s",
+ selectedRange.toString().c_str(),
+ document.getTextRange( selectedRange ).c_str(),
+ document.getAllText().c_str() );
+ AfxMessageBox( msg );
+ }
+
+
+ /*
CString msg;
msg.Format( "Selected range: %s\nSelected Text: %s\nAll Text: %s",
***************
*** 379,382 ****
--- 411,415 ----
document.replaceTextRange( range, "ABCDE" );
+ */
/*
RenameLocaleVariableDialog dialog;
Index: VC7TextDocument.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/VC7TextDocument.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** VC7TextDocument.cpp 14 May 2003 19:41:56 -0000 1.2
--- VC7TextDocument.cpp 15 May 2003 07:06:46 -0000 1.3
***************
*** 1,4 ****
--- 1,5 ----
#include "StdAfx.h"
#include "vc7textdocument.h"
+ #include <algorithm>
***************
*** 29,33 ****
CString ctext( text );
! return std::string( ctext );
}
--- 30,34 ----
CString ctext( text );
! return stripCR( std::string( ctext ) );
}
***************
*** 43,47 ****
CString ctext( text );
! return std::string( ctext );
}
--- 44,48 ----
CString ctext( text );
! return stripCR( std::string( ctext ) );
}
***************
*** 101,104 ****
--- 102,119 ----
setSelectionRange( range );
return replaceSelection( text );
+ }
+
+
+ std::string
+ VC7TextDocument::stripCR( const std::string &text ) const
+ {
+ // We need to strip CR from EOL because there are two characters, but VS count
+ // them as only one when returning absolute character offset.
+ std::string stripped( text );
+ std::string::iterator newEnd = std::remove( stripped.begin(),
+ stripped.end(),
+ '\r' );
+ stripped.erase( newEnd, stripped.end() );
+ return stripped;
}
Index: VC7TextDocument.h
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rftavc7addin/VC7TextDocument.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** VC7TextDocument.h 14 May 2003 19:41:56 -0000 1.2
--- VC7TextDocument.h 15 May 2003 07:06:46 -0000 1.3
***************
*** 45,48 ****
--- 45,51 ----
private:
+ std::string stripCR( const std::string &text ) const;
+
+ private:
CComPtr<EnvDTE::TextDocument> document_;
CComPtr<EnvDTE::EditPoint> startPoint_;
|