From: Andre B. <net...@us...> - 2004-08-16 20:51:06
|
Update of /cvsroot/cpptool/CppParser/examples/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30640/examples/parser Modified Files: refactoringtest.cpp Log Message: -- implemented "sibling class declaration" renaming Index: refactoringtest.cpp =================================================================== RCS file: /cvsroot/cpptool/CppParser/examples/parser/refactoringtest.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** refactoringtest.cpp 8 Jun 2004 20:23:17 -0000 1.1.1.1 --- refactoringtest.cpp 16 Aug 2004 20:50:57 -0000 1.2 *************** *** 93,106 **** Parser::SymbolTable &table = project_.symbolTable(); Parser::SymbolDeclarationPtr declaration = table.findDeclarationAt( location ); ! CPPUT_ASSERT( declaration, "No class declaration at location." ); ! Parser::SymbolTable::ReferenceEnum enumReference( table.enumReferences(declaration) ); ! while ( enumReference.hasNext() ) { ! const Parser::Location &reference = enumReference.next(); ! Parser::FileId file = reference.file(); ! Parser::SourceEditor &editor = project_.editSource( file ); ! Parser::NodePtr node = editor.findNodeAt( reference.pos() ); ! editor.rename( node, newName_ ); } project_.commitEditChanges(); } --- 93,115 ---- Parser::SymbolTable &table = project_.symbolTable(); Parser::SymbolDeclarationPtr declaration = table.findDeclarationAt( location ); ! CPPUT_ASSERT( declaration!=Parser::SymbolDeclarationPtr(), "No class declaration at location." ); ! // find out all sibling declarations: ! Parser::SymbolDeclarationPtrEnum enumDeclarations( table.enumSiblingDeclaration( declaration ) ); ! CPPUT_ASSERT( enumDeclarations.hasNext(), "Declarations not enumerated." ); ! while ( enumDeclarations.hasNext() ) { ! const Parser::SymbolDeclarationPtr& currentDecl = enumDeclarations.next(); ! ! Parser::SymbolTable::ReferenceEnum enumReference( table.enumReferences(currentDecl) ); ! while ( enumReference.hasNext() ) ! { ! const Parser::Location &reference = enumReference.next(); ! Parser::FileId file = reference.file(); ! Parser::SourceEditor &editor = project_.editSource( file ); ! Parser::NodePtr node = editor.findNodeAt( reference.pos() ); ! editor.rename( node, newName_ ); ! } } + project_.commitEditChanges(); } *************** *** 300,303 **** --- 309,319 ---- void + RefactoringTest::testRenameClassTest6() + { + testRefactoring( renameClassPath_ + "test6.cpp" ); + } + + + void RefactoringTest::testRefactoring( const std::string &path ) { |