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: <net...@us...> - 2003-04-14 19:33:22
|
Update of /cvsroot/cpptool/rfta/include/rfta/parser In directory sc8-pr-cvs1:/tmp/cvs-serv27346/rfta/include/rfta/parser Modified Files: ASTNodes.h Log Message: -- additional nodes created by the namespace parser Index: ASTNodes.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/parser/ASTNodes.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ASTNodes.h 12 Apr 2003 19:04:10 -0000 1.14 --- ASTNodes.h 14 Apr 2003 19:33:14 -0000 1.15 *************** *** 35,38 **** --- 35,51 ---- static const ASTNodeType usingNamespace; + // a namespace alias node: + static const ASTNodeType namespaceAlias; + + // a parsed namespace declaration node: + static const ASTNodeType namespaceDeclaration; + + // a parsed declaration list at file level or lower (not in compound statement) + static const ASTNodeType declarationList; + + // a not parsed function/method implementation + // e.g. "int fct() { ... }" + static const ASTNodeType unparsedfunctionImplementation; + // statement types // /////////////// *************** *** 186,189 **** --- 199,204 ---- // properties for global declarations: + static const ASTNodeProperty namespaceBodyProperty; + static const ASTNodeProperty namespaceAliasProperty; static const ASTNodeProperty templateBodyProperty; static const ASTNodeProperty linkageBodyProperty; |
From: <net...@us...> - 2003-04-14 19:33:19
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv27346/rfta/src/rftaparser Modified Files: ASTNodes.cpp Log Message: -- additional nodes created by the namespace parser Index: ASTNodes.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ASTNodes.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ASTNodes.cpp 12 Apr 2003 19:04:12 -0000 1.16 --- ASTNodes.cpp 14 Apr 2003 19:33:12 -0000 1.17 *************** *** 13,21 **** const ASTNodeType ASTNodeTypes::source( "source-file", isCompositeStatement ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedSourcePart ( "unparsed-source-part", isCompositeStatement ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedTemplate ( "unparsed-template" , isCompositeStatement ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedNamespace ( "unparsed-namespace" , isCompositeStatement ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedLinkage ( "unparsed-linkage" , isCompositeStatement ); /* AB: NEW */ const ASTNodeType ASTNodeTypes::usingNamespace ( "using-namespace" , 0 ); const ASTNodeType ASTNodeTypes::unparsedCompoundStatement( "unparsed-compound-statement", isCompositeStatement | needMutation ); --- 13,25 ---- const ASTNodeType ASTNodeTypes::source( "source-file", isCompositeStatement ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedSourcePart ( "unparsed-source-part", mayHaveLocalScopeIdentifierChildren ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedTemplate ( "unparsed-template" , mayHaveLocalScopeIdentifierChildren ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedNamespace ( "unparsed-namespace" , mayHaveLocalScopeIdentifierChildren ); ! /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedLinkage ( "unparsed-linkage" , 0 ); /* AB: NEW */ const ASTNodeType ASTNodeTypes::usingNamespace ( "using-namespace" , 0 ); + /* AB: NEW */ const ASTNodeType ASTNodeTypes::namespaceAlias ( "namespace-alias" , mayHaveLocalScopeIdentifierChildren ); + /* AB: NEW */ const ASTNodeType ASTNodeTypes::namespaceDeclaration ( "namespace-declaration" , mayHaveLocalScopeIdentifierChildren ); + /* AB: NEW */ const ASTNodeType ASTNodeTypes::declarationList ( "declaration-list" , mayHaveLocalScopeIdentifierChildren ); + /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedfunctionImplementation ( "unparsed-function-implementation" , mayHaveLocalScopeIdentifierChildren ); const ASTNodeType ASTNodeTypes::unparsedCompoundStatement( "unparsed-compound-statement", isCompositeStatement | needMutation ); *************** *** 91,94 **** --- 95,100 ---- /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::templateBodyProperty( "template-body-property" ); /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::linkageBodyProperty( "linkage-body-property" ); + /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::namespaceBodyProperty( "namespace-body-property" ); + /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::namespaceAliasProperty( "namespace-alias-property" ); } // namespace Refactoring |
From: <net...@us...> - 2003-04-14 19:33:00
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv27166/rfta/src/rftaparser Modified Files: DeclarationListParserTest.cpp Log Message: -- code cleanup Index: DeclarationListParserTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationListParserTest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DeclarationListParserTest.cpp 12 Apr 2003 19:08:40 -0000 1.1 --- DeclarationListParserTest.cpp 14 Apr 2003 19:32:54 -0000 1.2 *************** *** 48,54 **** "if ( e == a ) return true;" "return false;" ! "} int x;"); int startIndex = 2; int endIndex = source.length()-7; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationListParser, source, --- 48,57 ---- "if ( e == a ) return true;" "return false;" ! "} " ! "int x;"); ! int startIndex = 2; int endIndex = source.length()-7; + SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationListParser, source, |
From: <net...@us...> - 2003-04-14 19:32:08
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv26738/rfta/src/rftaparser Modified Files: DeclarationListParser.cpp Log Message: -- moved to different directory Index: DeclarationListParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationListParser.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DeclarationListParser.cpp 12 Apr 2003 19:08:39 -0000 1.1 --- DeclarationListParser.cpp 14 Apr 2003 19:32:04 -0000 1.2 *************** *** 7,11 **** #include "stdafx.h" #include <rfta/parser/ASTNodes.h> ! #include "DeclarationParser.h" #include "DeclarationListParser.h" #include <rfta/parser/ParseContext.h> --- 7,11 ---- #include "stdafx.h" #include <rfta/parser/ASTNodes.h> ! #include <rfta/parser/DeclarationParser.h> #include "DeclarationListParser.h" #include <rfta/parser/ParseContext.h> |
From: <net...@us...> - 2003-04-14 19:31:32
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv26454/rfta/src/rftaparser Modified Files: DeclarationParserTest.cpp Log Message: -- additional nodes created by the namespace parser Index: DeclarationParserTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationParserTest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DeclarationParserTest.cpp 12 Apr 2003 19:08:40 -0000 1.1 --- DeclarationParserTest.cpp 14 Apr 2003 19:31:28 -0000 1.2 *************** *** 8,12 **** #include "DeclarationParserTest.h" #include <rfta/parser/ASTNodes.h> ! #include "DeclarationParser.h" --- 8,12 ---- #include "DeclarationParserTest.h" #include <rfta/parser/ASTNodes.h> ! #include <rfta/parser/DeclarationParser.h> *************** *** 49,56 **** source, source.length()-1 ); ! RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::unparsedNamespace, startIndex, endIndex-startIndex ); } --- 49,61 ---- source, source.length()-1 ); ! ASTNodePtr namespaceDecl = sourceAST->getChildAt(0); ! RFTA_ASSERT_NODE_HAS( namespaceDecl, ASTNodeTypes::unparsedNamespace, startIndex, endIndex-startIndex ); + RFTA_ASSERT_NODE_HAS( namespaceDecl->getProperty(ASTNodeProperties::namespaceBodyProperty), + ASTNodeTypes::unparsedSourcePart, + 14, + 3 ); } *************** *** 65,69 **** source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ! ASTNodeTypes::unparsedNamespace, startIndex, endIndex-startIndex ); --- 70,74 ---- source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ! ASTNodeTypes::namespaceAlias, startIndex, endIndex-startIndex ); *************** *** 94,101 **** source, source.length()-2 ); ! RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::usingNamespace, startIndex, ! endIndex-startIndex ); } --- 99,108 ---- source, source.length()-2 ); ! ! ASTNodePtr namespaceDecl = sourceAST->getChildAt(0); ! RFTA_ASSERT_NODE_HAS( namespaceDecl, ASTNodeTypes::usingNamespace, startIndex, ! endIndex-startIndex ); } *************** *** 170,174 **** source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ! ASTNodeTypes::unparsedSourcePart, startIndex, endIndex-startIndex ); --- 177,181 ---- source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ! ASTNodeTypes::unparsedfunctionImplementation, startIndex, endIndex-startIndex ); |
From: <net...@us...> - 2003-04-14 19:30:37
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv26007/rfta/src/rftaparser Modified Files: DeclarationParser.cpp Log Message: -- new node type for function implementations Index: DeclarationParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/DeclarationParser.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DeclarationParser.cpp 12 Apr 2003 19:08:40 -0000 1.1 --- DeclarationParser.cpp 14 Apr 2003 19:30:32 -0000 1.2 *************** *** 6,10 **** #include "stdafx.h" ! #include "DeclarationParser.h" #include "NamespaceParser.h" #include "UsingNamespaceParser.h" --- 6,10 ---- #include "stdafx.h" ! #include <rfta/parser/DeclarationParser.h> #include "NamespaceParser.h" #include "UsingNamespaceParser.h" *************** *** 98,101 **** --- 98,102 ---- findNextBalanced('{','}'); declarationNode->setLength( getCurrentLength() - start_difference ); + declarationNode->mutateType(ASTNodeTypes::unparsedfunctionImplementation); return true; } |
From: <net...@us...> - 2003-04-14 19:29:31
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv25482/rfta/src/rftaparser Modified Files: LinkageParser.cpp Log Message: -- moved to different directory Index: LinkageParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/LinkageParser.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LinkageParser.cpp 12 Apr 2003 19:08:40 -0000 1.1 --- LinkageParser.cpp 14 Apr 2003 19:29:27 -0000 1.2 *************** *** 7,11 **** #include "stdafx.h" #include "LinkageParser.h" ! #include "DeclarationParser.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> --- 7,11 ---- #include "stdafx.h" #include "LinkageParser.h" ! #include <rfta/parser/DeclarationParser.h> #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> |
From: <net...@us...> - 2003-04-14 19:28:58
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv25160/rfta/src/rftaparser Modified Files: NamespaceParser.cpp Log Message: -- additional nodes created by the namespace parser Index: NamespaceParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/NamespaceParser.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NamespaceParser.cpp 12 Apr 2003 19:08:40 -0000 1.1 --- NamespaceParser.cpp 14 Apr 2003 19:28:54 -0000 1.2 *************** *** 46,58 **** // named namespace or unnamed namespace: // "namespace x" or "namespace { ... }" std::string namespace_name; if (tryReadNextIdentifier(namespace_name)) { ! // namespace has an identifier ! // TODO: add property for name ! } else ! { ! // unnamed namespace ! // TODO: add property marking this as unnamed namespace } --- 46,59 ---- // named namespace or unnamed namespace: // "namespace x" or "namespace { ... }" + int name_startIdx = getCurrentIndex(); std::string namespace_name; if (tryReadNextIdentifier(namespace_name)) { ! // namespace has an identifier which will be stored as child-node. ! ASTNodePtr namespace_identifier = ! createASTNode( ASTNodeTypes::localScopeIdentifier, ! namespaceNode, ! name_startIdx, getCurrentIndex() - name_startIdx + 1 ); ! namespaceNode->addChild( namespace_identifier ); } *************** *** 65,68 **** --- 66,70 ---- // namespace alias: "namespace x = y;" skipSpaces(); + int alias_startIdx = getCurrentIndex(); std::string alias_name = namespace_name; if (!tryReadNextIdentifier(namespace_name)) *************** *** 70,82 **** throwFailure( std::string("expected identifier for namespace alias." )); } ! // TODO: store alias name in a property skipSpaces(); ! expect(';'); } else { // this is a usual namespace definition: ! // "namespace x { }" expect('{'); findNextBalanced('{','}'); } } --- 72,104 ---- throwFailure( std::string("expected identifier for namespace alias." )); } ! namespaceNode->mutateType(ASTNodeTypes::namespaceAlias); ! // store alias name in property ! context_.bindNextNodeToProperty(namespaceNode,ASTNodeProperties::namespaceAliasProperty ); ! ! ASTNodePtr namespace_identifier = ! createASTNode( ASTNodeTypes::localScopeIdentifier, ! namespaceNode, ! alias_startIdx, getCurrentIndex() - alias_startIdx + 1 ); ! ! context_.addNode(namespace_identifier); ! skipSpaces(); ! expect(';'); } else { // this is a usual namespace definition: ! // "namespace x { }" ! int body_startIdx = getCurrentIndex(); expect('{'); findNextBalanced('{','}'); + // store body in namespace-body-property + context_.bindNextNodeToProperty(namespaceNode,ASTNodeProperties::namespaceBodyProperty ); + + ASTNodePtr namespace_body = + createASTNode( ASTNodeTypes::unparsedSourcePart, + namespaceNode, + body_startIdx, getCurrentIndex() - body_startIdx ); + + context_.addNode(namespace_body); } } |
From: <net...@us...> - 2003-04-14 19:28:06
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv24775/rfta/src/rftaparser Modified Files: TemplateDeclarationParser.cpp Log Message: -- moved to different directory Index: TemplateDeclarationParser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/TemplateDeclarationParser.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TemplateDeclarationParser.cpp 12 Apr 2003 19:08:40 -0000 1.1 --- TemplateDeclarationParser.cpp 14 Apr 2003 19:28:00 -0000 1.2 *************** *** 7,11 **** #include "stdafx.h" #include "TemplateDeclarationParser.h" ! #include "DeclarationParser.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> --- 7,11 ---- #include "stdafx.h" #include "TemplateDeclarationParser.h" ! #include <rfta/parser/DeclarationParser.h> #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> |
From: <net...@us...> - 2003-04-14 19:27:10
|
Update of /cvsroot/cpptool/rfta/include/rfta/parser In directory sc8-pr-cvs1:/tmp/cvs-serv24393 Added Files: DeclarationParser.h Log Message: -- moved to different directory --- NEW FILE: DeclarationParser.h --- // ////////////////////////////////////////////////////////////////////////// // Header file DeclarationParser.h for class DeclarationParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_DeclarationParser_H #define RFTA_DeclarationParser_H #include <rfta/parser/Parser.h> namespace Refactoring { /// namespace parser. class RFTAPARSER_API DeclarationParser : public Parser { public: /*! Constructs a DeclarationParser object. */ DeclarationParser( ParseContext &context, const char *start, const char *end ); /// Destructor. virtual ~DeclarationParser(); bool tryParse(); private: bool parseCommonDeclaration(); }; // Inlines methods for DeclarationParser: // --------------------------------------- } // namespace Refactoring #endif // RFTA_DeclarationParser_H |
From: <net...@us...> - 2003-04-14 19:26:41
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv24187 Removed Files: DeclarationParser.h Log Message: -- moved to different directory --- DeclarationParser.h DELETED --- |
From: <net...@us...> - 2003-04-12 19:09:31
|
Update of /cvsroot/cpptool/rfta/include/rfta/parser In directory sc8-pr-cvs1:/tmp/cvs-serv12693/include/rfta/parser Modified Files: Parser.h Log Message: -- additional function for scanning the source Index: Parser.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/parser/Parser.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Parser.h 25 Dec 2002 22:40:21 -0000 1.4 --- Parser.h 12 Apr 2003 19:09:27 -0000 1.5 *************** *** 83,86 **** --- 83,87 ---- void readUntilNext( char c ); + void readUntilNextOf( std::string charset ); bool tryReadNextIdentifier( std::string &identifier ); |
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv12201/src/rftaparser Added Files: DeclarationListParser.cpp DeclarationListParser.h DeclarationListParserTest.cpp DeclarationListParserTest.h DeclarationParser.cpp DeclarationParser.h DeclarationParserTest.cpp DeclarationParserTest.h LinkageParser.cpp LinkageParser.h NamespaceParser.cpp NamespaceParser.h TemplateDeclarationParser.cpp TemplateDeclarationParser.h UsingNamespaceParser.cpp UsingNamespaceParser.h Log Message: -- additional files for file level parsing --- NEW FILE: DeclarationListParser.cpp --- // ////////////////////////////////////////////////////////////////////////// // Implementation file DeclarationListParser.cpp for class DeclarationListParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include <rfta/parser/ASTNodes.h> #include "DeclarationParser.h" #include "DeclarationListParser.h" #include <rfta/parser/ParseContext.h> #include <stdexcept> namespace Refactoring { DeclarationListParser::DeclarationListParser( ParseContext &context, const char *start, const char *end ) : Parser( context, start, end ) { } DeclarationListParser::~DeclarationListParser() { } /** * unlike compound statement we seperate the file into ast nodes * as we understand the syntax now. */ bool DeclarationListParser::tryParse() { Tracker tracker( "DeclarationListParser::tryParse", *this ); do { skipSpaces(); if (!hasNext()) break; DeclarationParser parser(context_, current_ , end_ ); if (!parser.tryParse()) break; current_ = parser.getCurrent(); } while ( current_ < end_ ); return true; } } // namespace Refactoring --- NEW FILE: DeclarationListParser.h --- // ////////////////////////////////////////////////////////////////////////// // Header file DeclarationListParser.h for class DeclarationListParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_DeclarationListParser_H #define RFTA_DeclarationListParser_H #include <rfta/parser/Parser.h> namespace Refactoring { /// declaration list parser: { ... }. class RFTAPARSER_API DeclarationListParser : public Parser { public: /*! Constructs a DeclarationListParser object. */ DeclarationListParser( ParseContext &context, const char *start, const char *end ); /// Destructor. virtual ~DeclarationListParser(); bool tryParse(); }; // Inlines methods for DeclarationListParser: // -------------------------------------------- } // namespace Refactoring #endif // RFTA_DeclarationListParser_H --- NEW FILE: DeclarationListParserTest.cpp --- // ////////////////////////////////////////////////////////////////////////// // Implementation file DeclarationListParserTest.cpp for class DeclarationListParserTest // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "DeclarationListParserTest.h" #include <rfta/parser/ASTNodes.h> #include "DeclarationListParser.h" namespace Refactoring { RFTAPARSER_TEST_SUITE_REGISTRATION( DeclarationListParserTest ); DeclarationListParserTest::DeclarationListParserTest() : CppUnit::TestFixture() { } DeclarationListParserTest::~DeclarationListParserTest() { } void DeclarationListParserTest::setUp() { } void DeclarationListParserTest::tearDown() { } void DeclarationListParserTest::testTemplateFuntionFollowedByDecl() { const std::string source( " template<typename F1,typename F2>" "bool checkEquals( const F1 &e, const F2 &a)" "{" "if ( e == a ) return true;" "return false;" "} int x;"); int startIndex = 2; int endIndex = source.length()-7; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationListParser, source, source.length() ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::unparsedTemplate, startIndex, endIndex-startIndex ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(1), ASTNodeTypes::unparsedSourcePart, endIndex+1, 6 ); } } // namespace Refactoring --- NEW FILE: DeclarationListParserTest.h --- // ////////////////////////////////////////////////////////////////////////// // Header file DeclarationListParserTest.h for class DeclarationListParserTest // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_DeclarationListParserTest_H #define RFTA_DeclarationListParserTest_H #include "ParserTesting.h" namespace Refactoring { /// Unit tests for CompoundStatementParserTest class DeclarationListParserTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( DeclarationListParserTest ); CPPUNIT_TEST( testTemplateFuntionFollowedByDecl ); CPPUNIT_TEST_SUITE_END(); public: /*! Constructs a DeclarationListParserTest object. */ DeclarationListParserTest(); /// Destructor. virtual ~DeclarationListParserTest(); void setUp(); void tearDown(); void testTemplateFuntionFollowedByDecl(); private: /// Prevents the use of the copy constructor. DeclarationListParserTest( const DeclarationListParserTest &other ); /// Prevents the use of the copy operator. void operator =( const DeclarationListParserTest &other ); private: }; // Inlines methods for DeclarationListParserTest: // ------------------------------------------------ } // namespace Refactoring #endif // RFTA_DeclarationListParserTest_H --- NEW FILE: DeclarationParser.cpp --- // ////////////////////////////////////////////////////////////////////////// // Implementation file DeclarationParser.cpp for class DeclarationParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/11 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "DeclarationParser.h" #include "NamespaceParser.h" #include "UsingNamespaceParser.h" #include "LinkageParser.h" #include "TypeDeclarationStatementParser.h" #include "TemplateDeclarationParser.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> namespace Refactoring { DeclarationParser::DeclarationParser( ParseContext &context, const char *start, const char *end ) : Parser( context, start, end ) { } DeclarationParser::~DeclarationParser() { } bool DeclarationParser::parseCommonDeclaration() { Tracker tracker( "DeclarationParser::parseCommonDeclaration", *this ); // this difference is used to reduce the length of the AST node to the relevant part // of the declaration (skipping the leading white spaces) int start_difference = current_ - start_; ASTNodePtr declarationNode = createASTNode( ASTNodeTypes::unparsedSourcePart, getParentNode(), getCurrentIndex(), getCurrentLength() ); context_.addNode( declarationNode ); const char * rollback = current_; readUntilNextOf(";={"); // check for the most simple case: if (*current_==';') { expect(';'); // this is a very simple kind of declaration ending with a semicolon declarationNode->setLength( getCurrentLength() - start_difference ); return true; } // check for initialized declarations if (*current_=='=') { readUntilNextSemiColonSkippingOverCurlyBraces(); declarationNode->setLength( getCurrentLength() - start_difference ); return true; } if (*current_ != '{') throwFailure( "Don't expect anything other than '{' here." ); // check for the function declaration: const char * start_of_curl = current_; backtrackSkippingSpaces(); current_--; if (*current_=='y') // special case 'try-function-body' { if (hasPrevious() && current_[-1]=='r') { current_--; if (hasPrevious() && current_[-1]=='t') { // TODO: Handle the case of a try-catch-function-body throwFailure( "Handling of try-catch-function-body's not yet implemented."); } } // restore position: current_ = start_of_curl; } if (*current_==')') // check for parameter declaration of a function { current_ = start_of_curl+1; // read until the end of the function body findNextBalanced('{','}'); declarationNode->setLength( getCurrentLength() - start_difference ); return true; } // TODO: CHECK THIS AGAINST SYNTAX: current_--; readUntilNextSemiColonSkippingOverCurlyBraces(); declarationNode->setLength( getCurrentLength() - start_difference ); return true; } bool DeclarationParser::tryParse() { Tracker tracker( "DeclarationParser::parse", *this ); skipSpaces(); if (!hasNext()) return false; int startIndex = getCurrentIndex(); const char * start = current_; // first try one of the high level identifier: // "template", "typedef", "namespace", "extern" std::string identifier; if (tryReadNextIdentifier(identifier)) { if ( "template" == identifier ) { // call template declaration parser TemplateDeclarationParser parser( context_, start , end_ ); parser.parse(); current_ = parser.getCurrent(); return true; } else if ( "typedef" == identifier ) { // call typedef parser TypeDeclarationStatementParser parser( context_, start , end_ ); parser.parse(current_); current_ = parser.getCurrent(); return true; } else if ( "namespace" == identifier ) { // call namespace parser NamespaceParser parser( context_, start , end_ ); subParse( parser ); return true; } else if ( "using" == identifier ) { // call using-namespace parser // call namespace parser UsingNamespaceParser parser( context_, start , end_ ); subParse( parser ); return true; } else if ( "extern" == identifier ) { // check if it's a surrounding extern declaration: // e.g. extern "C" { ... } // if not, fall through to declaration parsing... const char * save = current_; skipSpaces(); if (tryNextIs('\"')) { // it's a linkage declaration LinkageParser parser( context_, start , end_ ); subParse( parser ); return true; } // FALL-THROUGH: // "extern" parser might fall through because of declarations starting // with the 'extern' keyword... these will be taken by the DeclarationParser } } // rollback to start current_ = start; /* its a start of a declaration */ return parseCommonDeclaration(); } } // namespace Refactoring --- NEW FILE: DeclarationParser.h --- // ////////////////////////////////////////////////////////////////////////// // Header file DeclarationParser.h for class DeclarationParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_DeclarationParser_H #define RFTA_DeclarationParser_H #include <rfta/parser/Parser.h> namespace Refactoring { /// namespace parser. class DeclarationParser : public Parser { public: /*! Constructs a DeclarationParser object. */ DeclarationParser( ParseContext &context, const char *start, const char *end ); /// Destructor. virtual ~DeclarationParser(); bool tryParse(); private: bool parseCommonDeclaration(); }; // Inlines methods for DeclarationParser: // --------------------------------------- } // namespace Refactoring #endif // RFTA_DeclarationParser_H --- NEW FILE: DeclarationParserTest.cpp --- // ////////////////////////////////////////////////////////////////////////// // Implementation file DeclarationParserTest.cpp for class DeclarationParserTest // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "DeclarationParserTest.h" #include <rfta/parser/ASTNodes.h> #include "DeclarationParser.h" namespace Refactoring { RFTAPARSER_TEST_SUITE_REGISTRATION( DeclarationParserTest ); DeclarationParserTest::DeclarationParserTest() : CppUnit::TestFixture() { } DeclarationParserTest::~DeclarationParserTest() { } void DeclarationParserTest::setUp() { } void DeclarationParserTest::tearDown() { } void DeclarationParserTest::testNamespaceParse() { const std::string source( " namespace x { } " ); int startIndex = 2; int endIndex = source.length()-1; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::unparsedNamespace, startIndex, endIndex-startIndex ); } void DeclarationParserTest::testNamespaceAlias() { const std::string source( " namespace x = y; " ); int startIndex = 2; int endIndex = 18; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::unparsedNamespace, startIndex, endIndex-startIndex ); } void DeclarationParserTest::testUsingNamespace() { const std::string source( " using namespace x; " ); int startIndex = 1; int endIndex = 19; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-2 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::usingNamespace, startIndex, endIndex-startIndex ); } void DeclarationParserTest::testLongUsingNamespace() { const std::string source( " using namespace ::x::y; " ); int startIndex = 1; int endIndex = 24; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-2 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::usingNamespace, startIndex, endIndex-startIndex ); } void DeclarationParserTest::testGlobalTypedef() { const std::string source( " typedef struct x { int a; } x__; " ); int startIndex = 1; int endIndex = 33; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-2 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::typedefStatement, startIndex, endIndex-startIndex ); } void DeclarationParserTest::testSimpleLinkage() { const std::string source( " extern \"C++\" { int f(); } " ); int startIndex = 2; int endIndex = 27; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::unparsedLinkage, startIndex, endIndex-startIndex ); } void DeclarationParserTest::testSingleLinkage() { const std::string source( " extern \"C++\" int f(); " ); int startIndex = 2; int endIndex = source.length()-1; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::unparsedLinkage, startIndex, endIndex-startIndex ); } void DeclarationParserTest::testSimpleDeclaration() { const std::string source( " extern const int x[2] = { 10 , 2 }; " ); int startIndex = 1; int endIndex = source.length()-1; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::unparsedSourcePart, startIndex, endIndex-startIndex ); } void DeclarationParserTest::testFunctionbody() { const std::string source( " extern int f(int a, int b) { ... } " ); int startIndex = 1; int endIndex = 35; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::unparsedSourcePart, startIndex, endIndex-startIndex ); } void DeclarationParserTest::testClassDeclaration() { const std::string source( " class x: public v, y { public: int fct(int x) { return -1; } }; " ); int startIndex = 1; int endIndex = source.length()-1; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::unparsedSourcePart, startIndex, endIndex-startIndex ); } void DeclarationParserTest::testTemplateClass() { const std::string source( " template x< T > class v { T x; }; " ); int startIndex = 1; int endIndex = source.length()-1; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::unparsedTemplate, startIndex, endIndex-startIndex ); } void DeclarationParserTest::testTemplateFuntion() { const std::string source( " template<typename F1,typename F2>" "bool checkEquals( const F1 &e, const F2 &a)" "{" "if ( e == a ) return true;" "return false;" "} "); int startIndex = 2; int endIndex = source.length()-1; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::unparsedTemplate, startIndex, endIndex-startIndex ); } void DeclarationParserTest::testNestedTemplateClass() { const std::string source( " template x< T > template y< T2 > class v { T x; T2 y;}; " ); int startIndex = 1; int endIndex = source.length()-1; SourceASTNodePtr sourceAST = RFTA_ASSERT_PARSER_PASS( DeclarationParser, source, source.length()-1 ); RFTA_ASSERT_NODE_HAS( sourceAST->getChildAt(0), ASTNodeTypes::unparsedTemplate, startIndex, endIndex-startIndex ); } } // namespace Refactoring --- NEW FILE: DeclarationParserTest.h --- // ////////////////////////////////////////////////////////////////////////// // Header file DeclarationParserTest.h for class DeclarationParserTest // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_DeclarationParserTest_H #define RFTA_DeclarationParserTest_H #include "ParserTesting.h" namespace Refactoring { /// Unit tests for CompoundStatementParserTest class DeclarationParserTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( DeclarationParserTest ); CPPUNIT_TEST( testNamespaceParse ); CPPUNIT_TEST( testUsingNamespace ); CPPUNIT_TEST( testGlobalTypedef ); CPPUNIT_TEST( testLongUsingNamespace ); CPPUNIT_TEST( testNamespaceAlias ); CPPUNIT_TEST( testSimpleLinkage ); CPPUNIT_TEST( testSingleLinkage ); CPPUNIT_TEST( testSimpleDeclaration ); CPPUNIT_TEST( testFunctionbody ); CPPUNIT_TEST( testClassDeclaration ); CPPUNIT_TEST( testTemplateClass ); CPPUNIT_TEST( testTemplateFuntion ); CPPUNIT_TEST( testNestedTemplateClass ); CPPUNIT_TEST_SUITE_END(); public: /*! Constructs a DeclarationParserTest object. */ DeclarationParserTest(); /// Destructor. virtual ~DeclarationParserTest(); void setUp(); void tearDown(); void testNamespaceParse(); void testUsingNamespace(); void testGlobalTypedef(); void testLongUsingNamespace(); void testNamespaceAlias(); void testSimpleLinkage(); void testSingleLinkage(); void testSimpleDeclaration(); void testFunctionbody(); void testClassDeclaration(); void testTemplateClass(); void testTemplateFuntion(); void testNestedTemplateClass(); private: /// Prevents the use of the copy constructor. DeclarationParserTest( const DeclarationParserTest &other ); /// Prevents the use of the copy operator. void operator =( const DeclarationParserTest &other ); private: }; // Inlines methods for DeclarationParserTest: // ------------------------------------------------ } // namespace Refactoring #endif // RFTA_DeclarationParserTest_H --- NEW FILE: LinkageParser.cpp --- // ////////////////////////////////////////////////////////////////////////// // Implementation file LinkageParser.cpp for class LinkageParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/11 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "LinkageParser.h" #include "DeclarationParser.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> namespace Refactoring { LinkageParser::LinkageParser( ParseContext &context, const char *start, const char *end ) : Parser( context, start, end ) { } LinkageParser::~LinkageParser() { } void LinkageParser::parse() { Tracker tracker( "LinkageParser::parse", *this ); ASTNodePtr linkageNode = createASTNode( ASTNodeTypes::unparsedLinkage, getParentNode(), getStartIndex(), getCurrentLength() ); context_.addNode( linkageNode ); expectKeyword( "extern" ); skipSpaces(); // read the literal expect('\"'); if (!tryReadUntilNext('\"')) throwFailure( "Parsing has failed read string-literal." ); skipSpaces(); // check for surrounding linkage: if (tryNextIs('{')) { // is surrounding linkage like: "extern "C" { ... }" findNextBalanced('{','}'); } else { // is single linkage like: extern "C" ... // setup the context to bind next node to templatebody-property context_.bindNextNodeToProperty( linkageNode, ASTNodeProperties::linkageBodyProperty ); DeclarationParser parser( context_, current_, end_ ); parser.tryParse(); current_ = parser.getCurrent(); } linkageNode->setLength( getCurrentLength() ); } } // namespace Refactoring --- NEW FILE: LinkageParser.h --- // ////////////////////////////////////////////////////////////////////////// // Header file LinkageParser.h for class LinkageParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_LinkageParser_H #define RFTA_LinkageParser_H #include <rfta/parser/Parser.h> namespace Refactoring { /// namespace parser. class LinkageParser : public Parser { public: /*! Constructs a LinkageParser object. */ LinkageParser( ParseContext &context, const char *start, const char *end ); /// Destructor. virtual ~LinkageParser(); void parse(); private: }; // Inlines methods for LinkageParser: // --------------------------------------- } // namespace Refactoring #endif // RFTA_LinkageParser_H --- NEW FILE: NamespaceParser.cpp --- // ////////////////////////////////////////////////////////////////////////// // Implementation file NamespaceParser.cpp for class NamespaceParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "NamespaceParser.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> namespace Refactoring { NamespaceParser::NamespaceParser( ParseContext &context, const char *start, const char *end ) : Parser( context, start, end ) { } NamespaceParser::~NamespaceParser() { } void NamespaceParser::parse() { Tracker tracker( "NamespaceParser::parse", *this ); ASTNodePtr namespaceNode = createASTNode( ASTNodeTypes::unparsedNamespace, getParentNode(), getStartIndex(), getCurrentLength() ); context_.addNode( namespaceNode ); expectKeyword( "namespace" ); skipSpaces(); // named namespace or unnamed namespace: // "namespace x" or "namespace { ... }" std::string namespace_name; if (tryReadNextIdentifier(namespace_name)) { // namespace has an identifier // TODO: add property for name } else { // unnamed namespace // TODO: add property marking this as unnamed namespace } if (!namespace_name.empty()) { // check for definition of a namespace alias skipSpaces(); if (tryNextIs('=')) { // namespace alias: "namespace x = y;" skipSpaces(); std::string alias_name = namespace_name; if (!tryReadNextIdentifier(namespace_name)) { throwFailure( std::string("expected identifier for namespace alias." )); } // TODO: store alias name in a property skipSpaces(); expect(';'); } else { // this is a usual namespace definition: // "namespace x { }" expect('{'); findNextBalanced('{','}'); } } namespaceNode->setLength( getCurrentLength() ); } } // namespace Refactoring --- NEW FILE: NamespaceParser.h --- // ////////////////////////////////////////////////////////////////////////// // Header file NamespaceParser.h for class NamespaceParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_NAMESPACEPARSER_H #define RFTA_NAMESPACEPARSER_H #include <rfta/parser/Parser.h> namespace Refactoring { /// namespace parser. class NamespaceParser : public Parser { public: /*! Constructs a NamespaceParser object. */ NamespaceParser( ParseContext &context, const char *start, const char *end ); /// Destructor. virtual ~NamespaceParser(); void parse(); private: }; // Inlines methods for NamespaceParser: // --------------------------------------- } // namespace Refactoring #endif // RFTA_NAMESPACEPARSER_H --- NEW FILE: TemplateDeclarationParser.cpp --- // ////////////////////////////////////////////////////////////////////////// // Implementation file TemplateDeclarationParser.cpp for class TemplateDeclarationParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/12 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "TemplateDeclarationParser.h" #include "DeclarationParser.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> namespace Refactoring { TemplateDeclarationParser::TemplateDeclarationParser( ParseContext &context, const char *start, const char *end ) : Parser( context, start, end ) { } TemplateDeclarationParser::~TemplateDeclarationParser() { } void TemplateDeclarationParser::parse() { Tracker tracker( "TemplateDeclarationParser::parse", *this ); ASTNodePtr templateNode = createASTNode( ASTNodeTypes::unparsedTemplate, getParentNode(), getStartIndex(), getCurrentLength() ); context_.addNode( templateNode ); expectKeyword( "template" ); skipSpaces(); // read the template parameter if (tryNextIs('<')) { // skipping all the parameters until next '>' findNextBalanced('<','>'); } skipSpaces(); // setup the context to bind next node to templatebody-property context_.bindNextNodeToProperty( templateNode, ASTNodeProperties::templateBodyProperty ); // read the template body: DeclarationParser parser( context_, current_ , end_ ); parser.tryParse(); current_ = parser.getCurrent(); templateNode->setLength( getCurrentLength() ); } } // namespace Refactoring --- NEW FILE: TemplateDeclarationParser.h --- // ////////////////////////////////////////////////////////////////////////// // Header file TemplateDeclarationParser.h for class TemplateDeclarationParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/12 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_TemplateDeclarationParser_H #define RFTA_TemplateDeclarationParser_H #include <rfta/parser/Parser.h> namespace Refactoring { /// namespace parser. class TemplateDeclarationParser : public Parser { public: /*! Constructs a TemplateDeclarationParser object. */ TemplateDeclarationParser( ParseContext &context, const char *start, const char *end ); /// Destructor. virtual ~TemplateDeclarationParser(); void parse(); private: }; // Inlines methods for TemplateDeclarationParser: // --------------------------------------- } // namespace Refactoring #endif // RFTA_TemplateDeclarationParser_H --- NEW FILE: UsingNamespaceParser.cpp --- // ////////////////////////////////////////////////////////////////////////// // Implementation file UsingNamespaceParser.cpp for class UsingNamespaceParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "UsingNamespaceParser.h" #include <rfta/parser/ASTNodes.h> #include <rfta/parser/ParseContext.h> namespace Refactoring { UsingNamespaceParser::UsingNamespaceParser( ParseContext &context, const char *start, const char *end ) : Parser( context, start, end ) { } UsingNamespaceParser::~UsingNamespaceParser() { } void UsingNamespaceParser::parse() { Tracker tracker( "UsingNamespaceParser::parse", *this ); ASTNodePtr namespaceNode = createASTNode( ASTNodeTypes::usingNamespace, getParentNode(), getStartIndex(), getCurrentLength() ); context_.addNode( namespaceNode ); expectKeyword( "using" ); skipSpaces(); expectKeyword( "namespace" ); skipSpaces(); // do not parse namespace identification here readUntilNext(';'); namespaceNode->setLength( getCurrentLength() ); } } // namespace Refactoring --- NEW FILE: UsingNamespaceParser.h --- // ////////////////////////////////////////////////////////////////////////// // Header file UsingNamespaceParser.h for class UsingNamespaceParser // (c)Copyright 2003, Andre Baresel. // Created: 2003/04/10 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_UsingNamespaceParser_H #define RFTA_UsingNamespaceParser_H #include <rfta/parser/Parser.h> namespace Refactoring { /// namespace parser. class UsingNamespaceParser : public Parser { public: /*! Constructs a UsingNamespaceParser object. */ UsingNamespaceParser( ParseContext &context, const char *start, const char *end ); /// Destructor. virtual ~UsingNamespaceParser(); void parse(); private: }; // Inlines methods for UsingNamespaceParser: // --------------------------------------- } // namespace Refactoring #endif // RFTA_UsingNamespaceParser_H |
From: <net...@us...> - 2003-04-12 19:07:11
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv11354/src/rftaparser Modified Files: rftaparser.dsp Log Message: -- additional files added to project for file level parsing Index: rftaparser.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/rftaparser.dsp,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** rftaparser.dsp 5 Apr 2003 18:29:01 -0000 1.32 --- rftaparser.dsp 12 Apr 2003 19:07:07 -0000 1.33 *************** *** 56,61 **** # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\build\rftaparser\Release/rftaparser_mdr.ext" /libpath:"../../deplib/cppunit/lib" # Begin Special Build Tool ! TargetDir=\prg\vc\Rfta\build\rftaparser\Release ! TargetPath=\prg\vc\Rfta\build\rftaparser\Release\rftaparser_mdr.ext TargetName=rftaparser_mdr SOURCE="$(InputPath)" --- 56,61 ---- # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\build\rftaparser\Release/rftaparser_mdr.ext" /libpath:"../../deplib/cppunit/lib" # Begin Special Build Tool ! TargetDir=\Projects\Cpptool\rfta\build\rftaparser\Release ! TargetPath=\Projects\Cpptool\rfta\build\rftaparser\Release\rftaparser_mdr.ext TargetName=rftaparser_mdr SOURCE="$(InputPath)" *************** *** 78,82 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RFTA_EXPORTS" /Yu"stdafx.h" /FD /GZ /c ! # ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I "../../include" /I "../../deplib/cppunit/include" /I "../../deplib/boostcvs" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RFTAPARSER_DLL_BUILD" /D CPPUNIT_WRAP_COLUMN=120 /Yu"stdafx.h" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 --- 78,82 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RFTA_EXPORTS" /Yu"stdafx.h" /FD /GZ /c ! # ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I "../../include" /I "../../deplib/cppunit/include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "RFTAPARSER_DLL_BUILD" /D CPPUNIT_WRAP_COLUMN=120 /Yu"stdafx.h" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 *************** *** 90,95 **** # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /dll /debug /machine:I386 /out:"..\..\build\rftaparser\Debug/rftaparser_mdd.ext" /pdbtype:sept /libpath:"../../deplib/cppunit/lib" # Begin Special Build Tool ! TargetDir=\prg\vc\Rfta\build\rftaparser\Debug ! TargetPath=\prg\vc\Rfta\build\rftaparser\Debug\rftaparser_mdd.ext TargetName=rftaparser_mdd SOURCE="$(InputPath)" --- 90,95 ---- # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cppunitd_dll.lib /nologo /dll /debug /machine:I386 /out:"..\..\build\rftaparser\Debug/rftaparser_mdd.ext" /pdbtype:sept /libpath:"../../deplib/cppunit/lib" # Begin Special Build Tool ! TargetDir=\Projects\Cpptool\rfta\build\rftaparser\Debug ! TargetPath=\Projects\Cpptool\rfta\build\rftaparser\Debug\rftaparser_mdd.ext TargetName=rftaparser_mdd SOURCE="$(InputPath)" *************** *** 162,165 **** --- 162,173 ---- # Begin Source File + SOURCE=.\DeclarationListParser.cpp + # End Source File + # Begin Source File + + SOURCE=.\DeclarationListParser.h + # End Source File + # Begin Source File + SOURCE=.\DeclarationOrExpressionParser.cpp # End Source File *************** *** 170,173 **** --- 178,189 ---- # Begin Source File + SOURCE=.\DeclarationParser.cpp + # End Source File + # Begin Source File + + SOURCE=.\DeclarationParser.h + # End Source File + # Begin Source File + SOURCE=.\DefaultStatementParser.cpp # End Source File *************** *** 226,229 **** --- 242,261 ---- # Begin Source File + SOURCE=.\LinkageParser.cpp + # End Source File + # Begin Source File + + SOURCE=.\LinkageParser.h + # End Source File + # Begin Source File + + SOURCE=.\NamespaceParser.cpp + # End Source File + # Begin Source File + + SOURCE=.\NamespaceParser.h + # End Source File + # Begin Source File + SOURCE=.\NullStatementParser.cpp # End Source File *************** *** 274,277 **** --- 306,317 ---- # Begin Source File + SOURCE=.\TemplateDeclarationParser.cpp + # End Source File + # Begin Source File + + SOURCE=.\TemplateDeclarationParser.h + # End Source File + # Begin Source File + SOURCE=.\TryStatementParser.cpp # End Source File *************** *** 290,293 **** --- 330,341 ---- # Begin Source File + SOURCE=.\UsingNamespaceParser.cpp + # End Source File + # Begin Source File + + SOURCE=.\UsingNamespaceParser.h + # End Source File + # Begin Source File + SOURCE=.\WhileStatementParser.cpp # End Source File *************** *** 518,521 **** --- 566,577 ---- # Begin Source File + SOURCE=.\DeclarationListParserTest.cpp + # End Source File + # Begin Source File + + SOURCE=.\DeclarationListParserTest.h + # End Source File + # Begin Source File + SOURCE=.\DeclarationOrExpressionParserTest.cpp *************** *** 544,547 **** --- 600,611 ---- # Begin Source File + SOURCE=.\DeclarationParserTest.cpp + # End Source File + # Begin Source File + + SOURCE=.\DeclarationParserTest.h + # End Source File + # Begin Source File + SOURCE=.\ExpressionMutatorTest.cpp *************** *** 766,773 **** --- 830,855 ---- SOURCE=.\ReturnStatementParserTest.cpp + + !IF "$(CFG)" == "rftaparser - Win32 Release" + + # PROP Exclude_From_Build 1 + + !ELSEIF "$(CFG)" == "rftaparser - Win32 Debug" + + !ENDIF + # End Source File # Begin Source File SOURCE=.\ReturnStatementParserTest.h + + !IF "$(CFG)" == "rftaparser - Win32 Release" + + # PROP Exclude_From_Build 1 + + !ELSEIF "$(CFG)" == "rftaparser - Win32 Debug" + + !ENDIF + # End Source File # Begin Source File |
From: <net...@us...> - 2003-04-12 19:05:26
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv10337/src/rftaparser Modified Files: Parser.cpp Log Message: -- additional function for scanning the source Index: Parser.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/Parser.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Parser.cpp 25 Dec 2002 22:40:21 -0000 1.5 --- Parser.cpp 12 Apr 2003 19:05:16 -0000 1.6 *************** *** 147,150 **** --- 147,164 ---- } + void + Parser::readUntilNextOf( std::string charset ) + { + Tracker tracker( "Parser::readUntilNextOf", *this ); + + while ( hasNext() ) + { + if ( charset.find(*current_) != std::string::npos ) + return; + current_++; + } + return; + } + bool |
From: <net...@us...> - 2003-04-12 19:04:17
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv9824a/src/rftaparser Modified Files: ASTNodes.cpp Log Message: -- additional nodes for file level parsing Index: ASTNodes.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/ASTNodes.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ASTNodes.cpp 24 Mar 2003 07:57:51 -0000 1.15 --- ASTNodes.cpp 12 Apr 2003 19:04:12 -0000 1.16 *************** *** 12,15 **** --- 12,22 ---- const ASTNodeType ASTNodeTypes::source( "source-file", isCompositeStatement ); + + /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedSourcePart ( "unparsed-source-part", isCompositeStatement ); + /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedTemplate ( "unparsed-template" , isCompositeStatement ); + /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedNamespace ( "unparsed-namespace" , isCompositeStatement ); + /* AB: NEW */ const ASTNodeType ASTNodeTypes::unparsedLinkage ( "unparsed-linkage" , isCompositeStatement ); + /* AB: NEW */ const ASTNodeType ASTNodeTypes::usingNamespace ( "using-namespace" , 0 ); + const ASTNodeType ASTNodeTypes::unparsedCompoundStatement( "unparsed-compound-statement", isCompositeStatement | needMutation ); const ASTNodeType ASTNodeTypes::compoundStatement( "compound-statement", isCompositeStatement ); *************** *** 81,84 **** --- 88,94 ---- const ASTNodeProperty ASTNodeProperties::typeDeclSeparator( "type-decl-separator-property" ); + + /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::templateBodyProperty( "template-body-property" ); + /* AB: NEW */ const ASTNodeProperty ASTNodeProperties::linkageBodyProperty( "linkage-body-property" ); } // namespace Refactoring |
From: <net...@us...> - 2003-04-12 19:04:16
|
Update of /cvsroot/cpptool/rfta/include/rfta/parser In directory sc8-pr-cvs1:/tmp/cvs-serv9824a/include/rfta/parser Modified Files: ASTNodes.h Log Message: -- additional nodes for file level parsing Index: ASTNodes.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/parser/ASTNodes.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ASTNodes.h 24 Mar 2003 07:57:49 -0000 1.13 --- ASTNodes.h 12 Apr 2003 19:04:10 -0000 1.14 *************** *** 20,23 **** --- 20,38 ---- static const ASTNodeType source; + // a part of a source file that has not yet been parsed + static const ASTNodeType unparsedSourcePart; + + // a template declaration that has not yet been parsed + static const ASTNodeType unparsedTemplate; + + // a namespace-area that has not yet been parsed + static const ASTNodeType unparsedNamespace; + + // a linkage declaration e.g. 'extern "C++" { }' + static const ASTNodeType unparsedLinkage; + + // the command declaring the use of a namespace "using namespace xxx;" + static const ASTNodeType usingNamespace; + // statement types // /////////////// *************** *** 169,172 **** --- 184,191 ---- // expression type property: static const ASTNodeProperty expressionTypeProperty; + + // properties for global declarations: + static const ASTNodeProperty templateBodyProperty; + static const ASTNodeProperty linkageBodyProperty; }; |
From: <bl...@us...> - 2003-04-10 08:40:40
|
Update of /cvsroot/cpptool/rfta/src/pyrfta In directory sc8-pr-cvs1:/tmp/cvs-serv28189/src/pyrfta Modified Files: ExposeBase.cpp ExposeExpressions2.cpp ExposeStatements.cpp Log Message: * updated some, still need more for Declarator Index: ExposeBase.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/pyrfta/ExposeBase.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExposeBase.cpp 5 Apr 2003 18:29:01 -0000 1.1 --- ExposeBase.cpp 10 Apr 2003 08:40:34 -0000 1.2 *************** *** 2,5 **** --- 2,6 ---- #include <boost/python.hpp> #include <rfta/refactoring/CodeModelElement.h> + #include <rfta/refactoring/ChangeTrackers.h> using namespace boost::python; *************** *** 17,20 **** --- 18,22 ---- .def( "wasAdded", &Change::wasAdded ) .def( "isUnmodified", &Change::isUnmodified ) + .def( "hasSourceRange", &Change::hasSourceRange ) .def_readwrite( "type", &Change::type_ ) .def_readwrite( "oldRange", &Change::oldRange_ ) Index: ExposeExpressions2.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/pyrfta/ExposeExpressions2.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExposeExpressions2.cpp 6 Apr 2003 07:20:23 -0000 1.1 --- ExposeExpressions2.cpp 10 Apr 2003 08:40:34 -0000 1.2 *************** *** 11,18 **** exposeExpressions2() { - // Not derived from Element at the time class_<Declarator, DeclaratorPtr, bases<Element>, boost::noncopyable>( "Declarator", ! init<std::string, std::string, std::string>() ) ! .def( init<std::string, std::string, std::string, ExpressionPtr>() ) .add_property( "type", &Declarator::getType, &Declarator::setType ) .add_property( "typeSuffix", &Declarator::getTypeSuffix, &Declarator::setTypeSuffix ) --- 11,17 ---- exposeExpressions2() { class_<Declarator, DeclaratorPtr, bases<Element>, boost::noncopyable>( "Declarator", ! init<TypePartPtr, IdentifierPtr, TypePartPtr>() ) ! .def( init<TypePartPtr, IdentifierPtr, TypePartPtr, ExpressionPtr>() ) .add_property( "type", &Declarator::getType, &Declarator::setType ) .add_property( "typeSuffix", &Declarator::getTypeSuffix, &Declarator::setTypeSuffix ) Index: ExposeStatements.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/pyrfta/ExposeStatements.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ExposeStatements.cpp 6 Apr 2003 07:20:23 -0000 1.2 --- ExposeStatements.cpp 10 Apr 2003 08:40:34 -0000 1.3 *************** *** 15,23 **** ; - class_<CompoundStatement::StatementChange, bases<Change> >( "CompoundStatementChange", - init<Change::ChangeType, StatementPtr>() ) - // .def_readwrite( "statement", &CompoundStatement::StatementChange::statement_ ) - ; - class_<CompoundStatement, CompoundStatementPtr, bases<Statement>, boost::noncopyable >( "CompoundStatement" ) .def( "removeStatementAt", &CompoundStatement::removeStatementAt ) --- 15,18 ---- *************** *** 29,32 **** --- 24,28 ---- .def( "getChangeCount", &CompoundStatement::getChangeCount ) .def( "getChangeAt", &CompoundStatement::getChangeAt ) + .def( "getChangeStatementAt", &CompoundStatement::getChangeStatementAt ) ; |
Update of /cvsroot/cpptool/rfta/include/rfta/refactoring In directory sc8-pr-cvs1:/tmp/cvs-serv25617/include/rfta/refactoring Modified Files: CodeModel.h CodeModelElement.h CodeModelExpressions.h CodeModelStatements.h CodeModelVisitor.h Added Files: ChangeTrackers.h Log Message: * added support for appending a variable declaration in a declaration expression. --- NEW FILE: ChangeTrackers.h --- #ifndef RFTA_CHANGETRACKERS_H_INCLUDED #define RFTA_CHANGETRACKERS_H_INCLUDED #include <rfta/refactoring/CodeModelForward.h> #include <rfta/parser/SourceRange.h> #include <stdexcept> #include <vector> namespace Refactoring { namespace CodeModel { class RFTA_API Change { public: enum ChangeType { added = 0, replaced, removed, unmodified }; Change() : type_( unmodified ) { } Change( ChangeType type, const SourceRange &oldRange = SourceRange() ) : type_( type ) , oldRange_( oldRange ) { } bool wasReplaced() const { return type_ == replaced; } bool wasRemoved() const { return type_ == removed; } bool wasAdded() const { return type_ == added; } bool isUnmodified() const { return type_ == unmodified; } bool hasSourceRange() const { return !oldRange_.isEmpty(); } ChangeType type_; SourceRange oldRange_; }; struct NoConstraintPolicy { template<typename Type> static void checkConstraint( const Type & ) { } }; struct NotNullConstraintPolicy { template<typename Type> static void checkConstraint( const Type &pointer ) { if ( !pointer ) throw std::invalid_argument( "ChangeTracker: parameter can not be null." ); } }; // The tracked element always exist, so change may only be unmodified or replaced. template<typename TrackedType ,typename ConstraintPolicy = NotNullConstraintPolicy> class ChangeTracker { public: ChangeTracker( const TrackedType &element ) : element_( element ) , change_( Change::added ) { ConstraintPolicy::checkConstraint( element ); } void setElementIsFromSource() { change_.type_ = Change::unmodified; change_.oldRange_ = hasElement() ? element_->getSourceRange() : SourceRange(); } void setElement( const TrackedType &newElement ) { ConstraintPolicy::checkConstraint( newElement ); change_.type_ = Change::replaced; element_ = newElement; } bool hasElement() const { return element_; } TrackedType getElement() const { return element_; } Change getChange() const { return change_; } private: Change change_; TrackedType element_; }; typedef ChangeTracker<StatementPtr> StatementChangeTracker; typedef ChangeTracker<ExpressionPtr> ExpressionChangeTracker; // Tracked element may not exist, so change may be of any types. template<typename TrackedType> class OptionalChangeTracker { public: OptionalChangeTracker() : change_( Change::added ) { } OptionalChangeTracker( const TrackedType &element ) : element_( element ) , change_( Change::added ) { } void setElementIsFromSource() { change_.type_ = Change::unmodified; change_.oldRange_ = hasElement() ? element_->getSourceRange() : SourceRange(); } void setElement( const TrackedType &newElement ) { if ( newElement ) { change_.type_ = hadElementInSource() ? Change::replaced : Change::added; } else { change_.type_ = hadElementInSource() ? Change::removed : Change::unmodified; } element_ = newElement; } bool hasElement() const { return element_; } TrackedType getElement() const { return element_; } Change getChange() const { return change_; } private: bool hadElementInSource() const { return !change_.oldRange_.isEmpty(); } Change change_; TrackedType element_; }; template<typename TrackedType> class CompositeChangeTracker { public: void setElementIsFromSource() { for ( Changes::iterator it = changes_.begin(); it != changes_.end(); ++it ) it->setElementIsFromSource(); } void removeAt( int index ) { changes_.at( getActualIndex(index) ).setElement( TrackedType() ); } void insertAt( int index, const TrackedType &element ) { changes_.insert( changes_.begin() + getActualIndex( index ), Tracker(element) ); } void append( const TrackedType &element ) { changes_.push_back( Tracker(element) ); } void setAt( int index, const TrackedType &element ) { changes_.at( getActualIndex(index) ).setElement( element ); } int getElementCount() const { int count = 0; for ( Changes::const_iterator it = changes_.begin(); it != changes_.end(); ++it ) { if ( it->hasElement() ) ++count; } return count; } TrackedType getAt( int index ) const { return changes_.at( getActualIndex(index) ).getElement(); } int getChangeCount() const { return changes_.size(); } Change getChangeAt( int index ) const { return changes_.at( index ).getChange(); } TrackedType getChangeElementAt( int index ) const { return changes_.at( index ).getElement(); } private: int getActualIndex( int index ) const { int count = 0; for ( Changes::const_iterator it = changes_.begin(); it != changes_.end(); ++it ) { if ( it->hasElement() && count++ == index ) return it - changes_.begin(); } throw std::out_of_range( "index out of range for CompositeChangeTracker::getActualIndex()" ); } private: typedef OptionalChangeTracker<TrackedType> Tracker; typedef std::vector<Tracker> Changes; Changes changes_; }; typedef OptionalChangeTracker<StatementPtr> OptionalStatementChangeTracker; typedef OptionalChangeTracker<ExpressionPtr> OptionalExpressionChangeTracker; } // namespace CodeModel } // namespace Refactoring #endif // RFTA_CHANGETRACKERS_H_INCLUDED Index: CodeModel.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModel.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CodeModel.h 6 Apr 2003 07:42:16 -0000 1.4 --- CodeModel.h 10 Apr 2003 08:37:46 -0000 1.5 *************** *** 56,59 **** --- 56,61 ---- TypePartPtr getDeclaratorPrimaryType( const ASTNodePtr &declaratorNode ); + TypePartPtr makeOptionalType( const ASTNodePtr &typeNode ); + IdentifierPtr makeIdentifier( const ASTNodePtr &identifierNode ); DeclaratorPtr makeVariableDeclarator( const ASTNodePtr &variableDeclaratorNode ); ExpressionPtr makeVariableInitializerExpression( const ASTNodePtr &initializerNode ); Index: CodeModelElement.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelElement.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CodeModelElement.h 5 Apr 2003 18:28:57 -0000 1.13 --- CodeModelElement.h 10 Apr 2003 08:37:46 -0000 1.14 *************** *** 7,15 **** #include <rfta/refactoring/CodeModelForward.h> - #include <rfta/parser/SourceRange.h> #include <rfta/parser/ASTNodeForward.h> #include <boost/enable_shared_from_this.hpp> #include <boost/utility.hpp> - #include <stdexcept> namespace Refactoring { namespace CodeModel --- 7,13 ---- *************** *** 59,253 **** ASTNodePtr node_; }; - - - class RFTA_API Change - { - public: - enum ChangeType - { - added = 0, - replaced, - removed, - unmodified - }; - - Change() - : type_( unmodified ) - { - } - - Change( ChangeType type, - const SourceRange &oldRange = SourceRange() ) - : type_( type ) - , oldRange_( oldRange ) - { - } - - bool wasReplaced() const - { - return type_ == replaced; - } - - bool wasRemoved() const - { - return type_ == removed; - } - - bool wasAdded() const - { - return type_ == added; - } - - bool isUnmodified() const - { - return type_ == unmodified; - } - - ChangeType type_; - SourceRange oldRange_; - }; - - - struct NoConstraintPolicy - { - template<typename Type> - static void checkConstraint( const Type & ) - { - } - }; - - - struct NotNullConstraintPolicy - { - template<typename Type> - static void checkConstraint( const Type &pointer ) - { - if ( !pointer ) - throw std::invalid_argument( "ChangeTracker: parameter can not be null." ); - } - }; - - - // The tracked element always exist, so change may only be unmodified or replaced. - template<typename TrackedType - ,typename ConstraintPolicy = NotNullConstraintPolicy> - class ChangeTracker - { - public: - ChangeTracker( const TrackedType &element ) - : element_( element ) - , change_( Change::added ) - { - ConstraintPolicy::checkConstraint( element ); - } - - void setElementIsFromSource() - { - change_.type_ = Change::unmodified; - change_.oldRange_ = hasElement() ? element_->getSourceRange() - : SourceRange(); - } - - void setElement( const TrackedType &newElement ) - { - ConstraintPolicy::checkConstraint( newElement ); - - change_.type_ = Change::replaced; - element_ = newElement; - } - - bool hasElement() const - { - return element_; - } - - TrackedType getElement() const - { - return element_; - } - - Change getChange() const - { - return change_; - } - - private: - Change change_; - TrackedType element_; - }; - - - typedef ChangeTracker<StatementPtr> StatementChangeTracker; - typedef ChangeTracker<ExpressionPtr> ExpressionChangeTracker; - - - - // Tracked element may not exist, so change may be of any types. - template<typename TrackedType> - class OptionalChangeTracker - { - public: - OptionalChangeTracker() - : change_( Change::added ) - { - } - - OptionalChangeTracker( const TrackedType &element ) - : element_( element ) - , change_( Change::added ) - { - } - - void setElementIsFromSource() - { - change_.type_ = Change::unmodified; - change_.oldRange_ = hasElement() ? element_->getSourceRange() - : SourceRange(); - } - - void setElement( const TrackedType &newElement ) - { - if ( newElement ) - { - change_.type_ = hadElementInSource() ? Change::replaced - : Change::added; - } - else - { - change_.type_ = hadElementInSource() ? Change::removed - : Change::unmodified; - } - - element_ = newElement; - } - - bool hasElement() const - { - return element_; - } - - TrackedType getElement() const - { - return element_; - } - - Change getChange() const - { - return change_; - } - - private: - bool hadElementInSource() const - { - return !change_.oldRange_.isEmpty(); - } - - Change change_; - TrackedType element_; - }; - - - typedef OptionalChangeTracker<StatementPtr> OptionalStatementChangeTracker; - typedef OptionalChangeTracker<ExpressionPtr> OptionalExpressionChangeTracker; --- 57,60 ---- Index: CodeModelExpressions.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelExpressions.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** CodeModelExpressions.h 6 Apr 2003 18:06:59 -0000 1.15 --- CodeModelExpressions.h 10 Apr 2003 08:37:47 -0000 1.16 *************** *** 6,10 **** #define RFTA_CODEMODELEXPRESSIONS_H ! #include <rfta/refactoring/Config.h> #include <rfta/refactoring/CodeModelForward.h> #include <rfta/refactoring/CodeModelElement.h> --- 6,10 ---- #define RFTA_CODEMODELEXPRESSIONS_H ! #include <rfta/refactoring/ChangeTrackers.h> #include <rfta/refactoring/CodeModelForward.h> #include <rfta/refactoring/CodeModelElement.h> *************** *** 42,46 **** void accept( ExpressionVisitor &visitor ); ! private: // overridden from CodeElement void setElementIsFromSource(); --- 42,46 ---- void accept( ExpressionVisitor &visitor ); ! private: // overridden from Element void setElementIsFromSource(); *************** *** 58,61 **** --- 58,64 ---- std::string getTypeText() const; + // overridden from Element + void accept( ElementVisitor &visitor ); + private: std::string typePart_; *************** *** 74,91 **** Change getPrimaryTypeChange() const; - int getDeclaratorCount() const; DeclaratorPtr getDeclaratorAt( int index ) const; void insertDeclaratorAt( int index, const DeclaratorPtr &declarator ); void appendDeclarator( const DeclaratorPtr &declarator ); void removeDeclaratorAt( int index ); // overridden from Expression void accept( ExpressionVisitor &visitor ); private: ! typedef std::vector<DeclaratorPtr> Declarators; ! Declarators declarators_; ChangeTracker<TypePartPtr> primaryTypeTracker_; }; --- 77,107 ---- Change getPrimaryTypeChange() const; int getDeclaratorCount() const; + DeclaratorPtr getDeclaratorAt( int index ) const; + void insertDeclaratorAt( int index, const DeclaratorPtr &declarator ); + void appendDeclarator( const DeclaratorPtr &declarator ); + void removeDeclaratorAt( int index ); + Change getChangeAt( int changeIndex ) const; + + DeclaratorPtr getChangeDeclaratorAt( int changeIndex ) const; + + int getChangeCount() const; + // overridden from Expression void accept( ExpressionVisitor &visitor ); + private: // overridden from Element + void setElementIsFromSource(); + private: ! // typedef std::vector<DeclaratorPtr> Declarators; ! // Declarators declarators_; ! CompositeChangeTracker<DeclaratorPtr> declaratorsTracker_; ChangeTracker<TypePartPtr> primaryTypeTracker_; }; *************** *** 99,102 **** --- 115,121 ---- std::string getIdentifier() const; + // overridden from Element + void accept( ElementVisitor &visitor ); + private: std::string identifier_; *************** *** 119,129 **** --- 138,159 ---- TypePartPtr getType() const; + void setType( const TypePartPtr &type ); + bool hasType() const; + + Change getTypeChange() const; + TypePartPtr getTypeSuffix() const; + void setTypeSuffix( const TypePartPtr &typeSuffix ); + bool hasTypeSuffix() const; + + Change getTypeSuffixChange() const; + IdentifierPtr getName() const; void setName( const IdentifierPtr &name ); + Change getNameChange() const; bool hasInitializer() const; *************** *** 134,141 **** void accept( ElementVisitor &visitor ); private: ! TypePartPtr type_; ! IdentifierPtr name_; ! TypePartPtr typeSuffix_; ExpressionPtr initializer_; }; --- 164,174 ---- void accept( ElementVisitor &visitor ); + private: // overridden from Element + void setElementIsFromSource(); + private: ! OptionalChangeTracker<TypePartPtr> typeTracker_; ! ChangeTracker<IdentifierPtr> nameTracker_; ! OptionalChangeTracker<TypePartPtr> typeSuffixTracker_; ExpressionPtr initializer_; }; Index: CodeModelStatements.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelStatements.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** CodeModelStatements.h 5 Apr 2003 18:28:57 -0000 1.19 --- CodeModelStatements.h 10 Apr 2003 08:37:47 -0000 1.20 *************** *** 6,13 **** #define RFTA_CODEMODELSTATEMENTS_H ! #include <rfta/refactoring/Config.h> #include <rfta/refactoring/CodeModelForward.h> #include <rfta/refactoring/CodeModelElement.h> - //#include <rfta/parser/SourceRange.h> #include <string> #include <vector> --- 6,12 ---- #define RFTA_CODEMODELSTATEMENTS_H ! #include <rfta/refactoring/ChangeTrackers.h> #include <rfta/refactoring/CodeModelForward.h> #include <rfta/refactoring/CodeModelElement.h> #include <string> #include <vector> *************** *** 31,46 **** { public: - struct StatementChange : public Change - { - StatementChange( ChangeType type, - const StatementPtr &statement ) - : Change( type ) - , statement_( statement ) - { - } - - StatementPtr statement_; - }; - void removeStatementAt( int index ); --- 30,33 ---- *************** *** 59,63 **** int getChangeCount() const; ! StatementChange getChangeAt( int changeIndex ) const; // overriden from Statement --- 46,52 ---- int getChangeCount() const; ! Change getChangeAt( int changeIndex ) const; ! ! StatementPtr getChangeStatementAt( int changeIndex ) const; // overriden from Statement *************** *** 68,76 **** private: ! int getActualIndex( int index ) const; ! ! private: ! typedef std::vector<StatementChange> Statements; ! Statements statements_; }; --- 57,61 ---- private: ! CompositeChangeTracker<StatementPtr> statementsTracker_; }; Index: CodeModelVisitor.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelVisitor.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CodeModelVisitor.h 8 Apr 2003 08:06:36 -0000 1.6 --- CodeModelVisitor.h 10 Apr 2003 08:37:49 -0000 1.7 *************** *** 58,61 **** --- 58,67 ---- { public: + using StatementVisitor::visit; + using ExpressionVisitor::visit; + + virtual void visit( const TypePartPtr &element ) =0; + virtual void visit( const IdentifierPtr &element ) =0; + // should add Label }; |
From: <bl...@us...> - 2003-04-10 08:37:56
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv25617/src/rfta Modified Files: CodeModel.cpp CodeModelElement.cpp CodeModelExpressions.cpp CodeModelGeneratorTest.cpp CodeModelStatements.cpp CodeRewriter.cpp CodeRewriter.h CodeWriterTest.cpp CodeWriterTest.h rfta.dsp Log Message: * added support for appending a variable declaration in a declaration expression. Index: CodeModel.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModel.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** CodeModel.cpp 6 Apr 2003 18:06:59 -0000 1.11 --- CodeModel.cpp 10 Apr 2003 08:37:50 -0000 1.12 *************** *** 314,327 **** TypePartPtr primaryType( getDeclaratorPrimaryType( expression ) ); DeclaratorExpressionPtr declaratorExpression( new DeclaratorExpression( primaryType ) ); - setElementSource( *declaratorExpression, expression ); for ( int index = 0; index < expression->getChildCount(); ++index ) { ! DeclaratorPtr declarator = ! makeVariableDeclarator( expression->getChildAt( index ) ); declaratorExpression->appendDeclarator( declarator ); } return declaratorExpression; } --- 314,329 ---- TypePartPtr primaryType( getDeclaratorPrimaryType( expression ) ); DeclaratorExpressionPtr declaratorExpression( new DeclaratorExpression( primaryType ) ); for ( int index = 0; index < expression->getChildCount(); ++index ) { ! const ASTNodePtr &declaratorNode = expression->getChildAt( index ); ! DeclaratorPtr declarator = makeVariableDeclarator( declaratorNode ); ! setElementSource( *declarator, declaratorNode ); declaratorExpression->appendDeclarator( declarator ); } + setElementSource( *declaratorExpression, expression ); + return declaratorExpression; } *************** *** 345,348 **** --- 347,361 ---- ASTNodePtr typeNode = node->getProperty( ASTNodeProperties::typeDeclSecondaryPrefixProperty ); + TypePartPtr type = makeOptionalType( typeNode ); + + ASTNodePtr typeSuffixNode = + node->getProperty( ASTNodeProperties::typeDeclSuffixProperty ); + TypePartPtr typeSuffix = makeOptionalType( typeSuffixNode ); + + ASTNodePtr nameNode = + node->getProperty( ASTNodeProperties::variableNameProperty ); + IdentifierPtr name = makeIdentifier( nameNode ); + + /* std::string type = typeNode ? typeNode->getBlankedText() : std::string(""); *************** *** 356,370 **** : std::string(""); - ASTNodePtr initializerNode = - node->getProperty( ASTNodeProperties::variableInitializerProperty ); - TypePartPtr typePtr( new TypePart( type ) ); TypePartPtr typeSuffixPtr( new TypePart( typeSuffix ) ); IdentifierPtr namePtr( new Identifier( name ) ); if ( !initializerNode ) ! return DeclaratorPtr( new Declarator( typePtr, namePtr, typeSuffixPtr ) ); ExpressionPtr initializer = makeVariableInitializerExpression( initializerNode ); ! return DeclaratorPtr( new Declarator( typePtr, namePtr, typeSuffixPtr, initializer ) ); } --- 369,411 ---- : std::string(""); TypePartPtr typePtr( new TypePart( type ) ); + setElementSource( *typePtr, typeNode ); + TypePartPtr typeSuffixPtr( new TypePart( typeSuffix ) ); + setElementSource( *typeSuffixPtr, typeSuffixNode ); + IdentifierPtr namePtr( new Identifier( name ) ); + setElementSource( *namePtr, nameNode ); + */ + + ASTNodePtr initializerNode = + node->getProperty( ASTNodeProperties::variableInitializerProperty ); + if ( !initializerNode ) ! return DeclaratorPtr( new Declarator( type, name, typeSuffix ) ); ExpressionPtr initializer = makeVariableInitializerExpression( initializerNode ); ! return DeclaratorPtr( new Declarator( type, name, typeSuffix, initializer ) ); ! } ! ! ! TypePartPtr ! Generator::makeOptionalType( const ASTNodePtr &typeNode ) ! { ! if ( !typeNode ) ! return TypePartPtr(); ! ! TypePartPtr typePtr( new TypePart( typeNode->getBlankedText() ) ); ! setElementSource( *typePtr, typeNode ); ! return typePtr; ! } ! ! ! IdentifierPtr ! Generator::makeIdentifier( const ASTNodePtr &identifierNode ) ! { ! IdentifierPtr namePtr( new Identifier( identifierNode->getBlankedText() ) ); ! setElementSource( *namePtr, identifierNode ); ! return namePtr; } Index: CodeModelElement.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelElement.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CodeModelElement.cpp 16 Mar 2003 16:18:40 -0000 1.9 --- CodeModelElement.cpp 10 Apr 2003 08:37:50 -0000 1.10 *************** *** 1,3 **** ! // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2002, Baptiste Lepilleur. // Created: 2002/12/22 --- 1,3 ---- ! / ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2002, Baptiste Lepilleur. // Created: 2002/12/22 Index: CodeModelExpressions.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelExpressions.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CodeModelExpressions.cpp 6 Apr 2003 18:06:59 -0000 1.13 --- CodeModelExpressions.cpp 10 Apr 2003 08:37:50 -0000 1.14 *************** *** 103,107 **** DeclaratorExpression::getDeclaratorCount() const { ! return declarators_.size(); } --- 103,107 ---- DeclaratorExpression::getDeclaratorCount() const { ! return declaratorsTracker_.getElementCount(); } *************** *** 110,114 **** DeclaratorExpression::getDeclaratorAt( int index ) const { ! return declarators_.at( index ); } --- 110,114 ---- DeclaratorExpression::getDeclaratorAt( int index ) const { ! return declaratorsTracker_.getAt( index ); } *************** *** 118,122 **** const DeclaratorPtr &declarator ) { ! declarators_.insert( declarators_.begin() + index, declarator ); } --- 118,122 ---- const DeclaratorPtr &declarator ) { ! declaratorsTracker_.insertAt( index, declarator ); } *************** *** 125,129 **** DeclaratorExpression::appendDeclarator( const DeclaratorPtr &declarator ) { ! declarators_.push_back( declarator ); } --- 125,129 ---- DeclaratorExpression::appendDeclarator( const DeclaratorPtr &declarator ) { ! declaratorsTracker_.append( declarator ); } *************** *** 132,136 **** DeclaratorExpression::removeDeclaratorAt( int index ) { ! declarators_.erase( declarators_.begin() + index ); } --- 132,165 ---- DeclaratorExpression::removeDeclaratorAt( int index ) { ! declaratorsTracker_.removeAt( index ); ! } ! ! ! Change ! DeclaratorExpression::getChangeAt( int changeIndex ) const ! { ! return declaratorsTracker_.getChangeAt( changeIndex ); ! } ! ! ! DeclaratorPtr ! DeclaratorExpression::getChangeDeclaratorAt( int changeIndex ) const ! { ! return declaratorsTracker_.getChangeElementAt( changeIndex ); ! } ! ! ! int ! DeclaratorExpression::getChangeCount() const ! { ! return declaratorsTracker_.getChangeCount(); ! } ! ! ! void ! DeclaratorExpression::setElementIsFromSource() ! { ! primaryTypeTracker_.setElementIsFromSource(); ! declaratorsTracker_.setElementIsFromSource(); } *************** *** 159,162 **** --- 188,198 ---- + void + TypePart::accept( ElementVisitor &visitor ) + { + visitor.visit( makeSharedFromThis( this ) ); + } + + Identifier::Identifier( const std::string &identifier ) *************** *** 175,185 **** Declarator::Declarator( const TypePartPtr &type, const IdentifierPtr &name, const TypePartPtr &typeSuffix ) ! : type_( type ) ! , name_( name ) ! , typeSuffix_( typeSuffix ) { } --- 211,228 ---- + void + Identifier::accept( ElementVisitor &visitor ) + { + visitor.visit( makeSharedFromThis( this ) ); + } + + Declarator::Declarator( const TypePartPtr &type, const IdentifierPtr &name, const TypePartPtr &typeSuffix ) ! : typeTracker_( type ) ! , nameTracker_( name ) ! , typeSuffixTracker_( typeSuffix ) { } *************** *** 190,196 **** const TypePartPtr &typeSuffix, const ExpressionPtr &initializer ) ! : type_( type ) ! , name_( name ) ! , typeSuffix_( typeSuffix ) , initializer_( initializer ) { --- 233,239 ---- const TypePartPtr &typeSuffix, const ExpressionPtr &initializer ) ! : typeTracker_( type ) ! , nameTracker_( name ) ! , typeSuffixTracker_( typeSuffix ) , initializer_( initializer ) { *************** *** 206,210 **** Declarator::getType() const { ! return type_; } --- 249,253 ---- Declarator::getType() const { ! return typeTracker_.getElement(); } *************** *** 213,217 **** Declarator::setType( const TypePartPtr &type ) { ! type_ = type; } --- 256,274 ---- Declarator::setType( const TypePartPtr &type ) { ! typeTracker_.setElement( type ); ! } ! ! ! bool ! Declarator::hasType() const ! { ! return typeTracker_.hasElement(); ! } ! ! ! Change ! Declarator::getTypeChange() const ! { ! return typeTracker_.getChange(); } *************** *** 220,224 **** Declarator::getTypeSuffix() const { ! return typeSuffix_; } --- 277,281 ---- Declarator::getTypeSuffix() const { ! return typeSuffixTracker_.getElement(); } *************** *** 227,231 **** Declarator::setTypeSuffix( const TypePartPtr &typeSuffix ) { ! typeSuffix_ = typeSuffix; } --- 284,302 ---- Declarator::setTypeSuffix( const TypePartPtr &typeSuffix ) { ! typeSuffixTracker_.setElement( typeSuffix ); ! } ! ! ! bool ! Declarator::hasTypeSuffix() const ! { ! return typeSuffixTracker_.hasElement(); ! } ! ! ! Change ! Declarator::getTypeSuffixChange() const ! { ! return typeSuffixTracker_.getChange(); } *************** *** 234,238 **** Declarator::getName() const { ! return name_; } --- 305,309 ---- Declarator::getName() const { ! return nameTracker_.getElement(); } *************** *** 241,245 **** Declarator::setName( const IdentifierPtr &name ) { ! name_ = name; } --- 312,323 ---- Declarator::setName( const IdentifierPtr &name ) { ! nameTracker_.setElement( name ); ! } ! ! ! Change ! Declarator::getNameChange() const ! { ! return nameTracker_.getChange(); } *************** *** 263,266 **** --- 341,353 ---- { initializer_ = initializer; + } + + + void + Declarator::setElementIsFromSource() + { + typeTracker_.setElementIsFromSource(); + nameTracker_.setElementIsFromSource(); + typeSuffixTracker_.setElementIsFromSource(); } Index: CodeModelGeneratorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelGeneratorTest.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CodeModelGeneratorTest.cpp 6 Apr 2003 18:06:59 -0000 1.6 --- CodeModelGeneratorTest.cpp 10 Apr 2003 08:37:50 -0000 1.7 *************** *** 55,60 **** CodeModel::DeclaratorPtr declarator = declExpression->getDeclaratorAt(0); ! RFTA_ASSERT_EQUAL( "", declarator->getType()->getTypeText() ); ! RFTA_ASSERT_EQUAL( "", declarator->getTypeSuffix()->getTypeText() ); RFTA_ASSERT_EQUAL( "x", declarator->getName()->getIdentifier() ); CPPUNIT_ASSERT( declarator->hasInitializer() ); --- 55,60 ---- CodeModel::DeclaratorPtr declarator = declExpression->getDeclaratorAt(0); ! CPPUNIT_ASSERT( !declarator->hasType() ); ! CPPUNIT_ASSERT( !declarator->hasTypeSuffix() ); RFTA_ASSERT_EQUAL( "x", declarator->getName()->getIdentifier() ); CPPUNIT_ASSERT( declarator->hasInitializer() ); Index: CodeModelStatements.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelStatements.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** CodeModelStatements.cpp 5 Apr 2003 18:29:01 -0000 1.17 --- CodeModelStatements.cpp 10 Apr 2003 08:37:50 -0000 1.18 *************** *** 30,37 **** CompoundStatement::removeStatementAt( int index ) { ! StatementChange &change = statements_.at( getActualIndex( index ) ); ! change.type_ = Change::removed; ! change.oldRange_ = change.statement_->getSourceRange(); ! change.statement_.reset(); } --- 30,34 ---- CompoundStatement::removeStatementAt( int index ) { ! statementsTracker_.removeAt( index ); } *************** *** 40,44 **** CompoundStatement::appendStatement( const StatementPtr &statement ) { ! statements_.push_back( StatementChange( Change::added, statement ) ); } --- 37,41 ---- CompoundStatement::appendStatement( const StatementPtr &statement ) { ! statementsTracker_.append( statement ); } *************** *** 48,53 **** const StatementPtr &statement ) { ! statements_.insert( statements_.begin() + getActualIndex(index), ! StatementChange( Change::added, statement ) ); } --- 45,49 ---- const StatementPtr &statement ) { ! statementsTracker_.insertAt( index, statement ); } *************** *** 57,64 **** const StatementPtr &statement ) { ! StatementChange &change = statements_.at( getActualIndex( index ) ); ! change.type_ = Change::replaced; ! change.oldRange_ = change.statement_->getSourceRange(); ! change.statement_ = statement; } --- 53,57 ---- const StatementPtr &statement ) { ! statementsTracker_.setAt( index, statement ); } *************** *** 67,78 **** 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; } --- 60,64 ---- CompoundStatement::getStatementCount() const { ! return statementsTracker_.getElementCount(); } *************** *** 81,102 **** 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()" ); } - void CompoundStatement::accept( StatementVisitor &visitor ) --- 67,73 ---- CompoundStatement::getStatementAt( int index ) const { ! return statementsTracker_.getAt( index ); } void CompoundStatement::accept( StatementVisitor &visitor ) *************** *** 109,114 **** CompoundStatement::setElementIsFromSource() { ! for ( Statements::iterator it = statements_.begin(); it != statements_.end(); ++it ) ! it->type_ = Change::unmodified; } --- 80,84 ---- CompoundStatement::setElementIsFromSource() { ! statementsTracker_.setElementIsFromSource(); } *************** *** 117,128 **** CompoundStatement::getChangeCount() const { ! return statements_.size(); } ! CompoundStatement::StatementChange CompoundStatement::getChangeAt( int changeIndex ) const { ! return statements_.at( changeIndex ); } --- 87,105 ---- CompoundStatement::getChangeCount() const { ! return statementsTracker_.getChangeCount(); } ! Change CompoundStatement::getChangeAt( int changeIndex ) const { ! return statementsTracker_.getChangeAt( changeIndex ); ! } ! ! ! StatementPtr ! CompoundStatement::getChangeStatementAt( int changeIndex ) const ! { ! return statementsTracker_.getChangeElementAt( changeIndex ); } Index: CodeRewriter.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** CodeRewriter.cpp 8 Apr 2003 08:06:36 -0000 1.38 --- CodeRewriter.cpp 10 Apr 2003 08:37:50 -0000 1.39 *************** *** 204,207 **** --- 204,210 ---- if ( isInserting() && deletionType == bracedExpressionDelete ) insertText( " " ); + + if ( isUpdating() && change.isUnmodified() ) + setCurrentInsertionPos( change.oldRange_.getEndIndex() ); } *************** *** 289,308 **** for ( int index =0; index < statement->getChangeCount(); ++index ) { ! CompoundStatement::StatementChange change = statement->getChangeAt( index ); ! if ( change.type_ == Change::removed ) { deleteText( change.oldRange_ ); ! continue; } currentInsertionPos_ = nextStatementInsertionPos; ! if ( change.type_ == Change::unmodified ) ! nextStatementInsertionPos = change.statement_->getSourceRange().getEndIndex(); ! else if ( change.type_ == Change::replaced ) ! deleteText( change.statement_->getSourceRange() ); ! ModeModifier mode( mode_, change.type_ == Change::unmodified ? updating : inserting ); ! change.statement_->accept( *this ); } --- 292,313 ---- for ( int index =0; index < statement->getChangeCount(); ++index ) { ! Change change = statement->getChangeAt( index ); ! ! if ( change.wasRemoved() || change.wasReplaced() ) { deleteText( change.oldRange_ ); ! ! if ( change.wasRemoved() ) ! continue; } currentInsertionPos_ = nextStatementInsertionPos; ! StatementPtr subStatement = statement->getChangeStatementAt( index ); ! if ( change.isUnmodified() ) ! nextStatementInsertionPos = subStatement->getSourceRange().getEndIndex(); ! ModeModifier mode( mode_, change.isUnmodified() ? updating : inserting ); ! subStatement->accept( *this ); } *************** *** 634,653 **** CodeRewriter::visit( const DeclaratorExpressionPtr &expression ) { ! if ( expression->getDeclaratorCount() == 0 ) ! return; ! beginInsertNewStatement(); ! insertText( expression->getPrimaryType()->getTypeText() ); ! for ( int index =0; index < expression->getDeclaratorCount(); ++index ) { ! if ( index > 0 ) insertText( ", " ); ! DeclaratorPtr declarator = expression->getDeclaratorAt(index); processDeclarator( declarator ); } ! endInsertNewStatement(); } --- 639,662 ---- CodeRewriter::visit( const DeclaratorExpressionPtr &expression ) { ! if ( isInserting() ) ! beginInsertNewStatement(); ! handleMandatoryChange( expression->getPrimaryTypeChange(), ! *expression->getPrimaryType() ); ! for ( int index =0; index < expression->getChangeCount(); ++index ) { ! Change change = expression->getChangeAt( index ); ! DeclaratorPtr declarator = expression->getChangeDeclaratorAt( index ); ! ! if ( index > 0 ) insertText( ", " ); ! ModeModifier mode( mode_, change.isUnmodified() ? updating : inserting ); processDeclarator( declarator ); } ! if ( isInserting() ) ! endInsertNewStatement(); } *************** *** 656,662 **** CodeRewriter::processDeclarator( const DeclaratorPtr &declarator ) { ! insertText( declarator->getType()->getTypeText() ); ! insertText( declarator->getName()->getIdentifier() ); ! insertText( declarator->getTypeSuffix()->getTypeText() ); } --- 665,678 ---- CodeRewriter::processDeclarator( const DeclaratorPtr &declarator ) { ! handleOptionalChange( declarator->getTypeChange(), ! declarator->getType(), ! "", ! currentInsertionPos_ ); ! handleMandatoryChange( declarator->getNameChange(), ! *declarator->getName() ); ! handleOptionalChange( declarator->getTypeSuffixChange(), ! declarator->getTypeSuffix(), ! "", ! currentInsertionPos_ ); } *************** *** 690,693 **** --- 706,725 ---- CodeRewriter::visit( const NullExpressionPtr &expression ) { + } + + + void + CodeRewriter::visit( const TypePartPtr &element ) + { + if ( isInserting() ) + insertText( element->getTypeText() ); + } + + + void + CodeRewriter::visit( const IdentifierPtr &element ) + { + if ( isInserting() ) + insertText( element->getIdentifier() ); } Index: CodeRewriter.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** CodeRewriter.h 8 Apr 2003 08:06:37 -0000 1.16 --- CodeRewriter.h 10 Apr 2003 08:37:50 -0000 1.17 *************** *** 61,64 **** --- 61,68 ---- void visit( const NullExpressionPtr &expression ); + // overridden from ElementVisitor + void visit( const TypePartPtr &element ); + void visit( const IdentifierPtr &element ); + private: enum Mode Index: CodeWriterTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** CodeWriterTest.cpp 6 Apr 2003 15:11:23 -0000 1.33 --- CodeWriterTest.cpp 10 Apr 2003 08:37:51 -0000 1.34 *************** *** 519,522 **** --- 519,542 ---- + void + CodeWriterTest::testModifyDeclarationExpresion() + { + source_ = "{\n" + " int x;\n" + "}"; + generateCompound(); + + CodeModel::DeclarationStatement &declarationStatement = + dynamic_cast<CodeModel::DeclarationStatement &>( *compound_->getStatementAt(0) ); + CodeModel::DeclaratorPtr declarator( new CodeModel::Declarator( makeTypePart(""), + makeIdentifier("y"), + makeTypePart("") ) ); + declarationStatement.getDeclaration()->appendDeclarator( declarator ); + generateAndCheckSource( "{\n" + " int x, y;\n" + "}" ); + } + + } // namespace Refactoring Index: CodeWriterTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTest.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** CodeWriterTest.h 18 Mar 2003 22:37:49 -0000 1.27 --- CodeWriterTest.h 10 Apr 2003 08:37:51 -0000 1.28 *************** *** 40,43 **** --- 40,44 ---- CPPUNIT_TEST( testModifyForIterationExpression ); CPPUNIT_TEST( testModifyForIteratedStatement ); + CPPUNIT_TEST( testModifyDeclarationExpresion ); CPPUNIT_TEST_SUITE_END(); *************** *** 84,87 **** --- 85,90 ---- void testModifyForIterationExpression(); void testModifyForIteratedStatement(); + + void testModifyDeclarationExpresion(); private: Index: rfta.dsp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/rfta.dsp,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** rfta.dsp 1 Apr 2003 18:22:57 -0000 1.42 --- rfta.dsp 10 Apr 2003 08:37:51 -0000 1.43 *************** *** 311,314 **** --- 311,318 ---- # Begin Source File + SOURCE=..\..\include\rfta\refactoring\ChangeTrackers.h + # End Source File + # Begin Source File + SOURCE=.\CodeModel.cpp # End Source File |
From: <bl...@us...> - 2003-04-08 08:06:41
|
Update of /cvsroot/cpptool/rfta/include/rfta/refactoring In directory sc8-pr-cvs1:/tmp/cvs-serv25603/include/rfta/refactoring Modified Files: CodeModelVisitor.h Log Message: * added support for inserting multiple variable declarations Index: CodeModelVisitor.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelVisitor.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CodeModelVisitor.h 6 Apr 2003 07:20:23 -0000 1.5 --- CodeModelVisitor.h 8 Apr 2003 08:06:36 -0000 1.6 *************** *** 57,60 **** --- 57,61 ---- , public ExpressionVisitor { + public: }; |
From: <bl...@us...> - 2003-04-08 08:06:41
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv25603/src/rfta Modified Files: CodeRewriter.cpp CodeRewriter.h Log Message: * added support for inserting multiple variable declarations Index: CodeRewriter.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** CodeRewriter.cpp 6 Apr 2003 18:06:59 -0000 1.37 --- CodeRewriter.cpp 8 Apr 2003 08:06:36 -0000 1.38 *************** *** 634,658 **** CodeRewriter::visit( const DeclaratorExpressionPtr &expression ) { ! if ( isInserting() ) { ! if ( expression->getDeclaratorCount() == 0 ) ! return; ! beginInsertNewStatement(); ! insertText( expression->getPrimaryType()->getTypeText() ); ! for ( int index =0; index < expression->getDeclaratorCount(); ++index ) ! { ! if ( index > 0 ) ! insertText( ", " ); - DeclaratorPtr declarator = expression->getDeclaratorAt(index); - insertText( declarator->getType()->getTypeText() ); - insertText( declarator->getName()->getIdentifier() ); - insertText( declarator->getTypeSuffix()->getTypeText() ); - } ! endInsertNewStatement(); ! } } --- 634,662 ---- CodeRewriter::visit( const DeclaratorExpressionPtr &expression ) { ! if ( expression->getDeclaratorCount() == 0 ) ! return; ! ! beginInsertNewStatement(); ! insertText( expression->getPrimaryType()->getTypeText() ); ! ! for ( int index =0; index < expression->getDeclaratorCount(); ++index ) { ! if ( index > 0 ) ! insertText( ", " ); ! DeclaratorPtr declarator = expression->getDeclaratorAt(index); ! processDeclarator( declarator ); ! } ! endInsertNewStatement(); ! } ! void ! CodeRewriter::processDeclarator( const DeclaratorPtr &declarator ) ! { ! insertText( declarator->getType()->getTypeText() ); ! insertText( declarator->getName()->getIdentifier() ); ! insertText( declarator->getTypeSuffix()->getTypeText() ); } Index: CodeRewriter.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** CodeRewriter.h 6 Apr 2003 07:20:23 -0000 1.15 --- CodeRewriter.h 8 Apr 2003 08:06:37 -0000 1.16 *************** *** 160,163 **** --- 160,165 ---- void setCurrentInsertionPos( int index ); + void processDeclarator( const DeclaratorPtr &declarator ); + private: IndentLevelManager indentManager_; |
From: <bl...@us...> - 2003-04-06 18:07:02
|
Update of /cvsroot/cpptool/rfta/src/rfta In directory sc8-pr-cvs1:/tmp/cvs-serv21204/src/rfta Modified Files: CodeModel.cpp CodeModelExpressions.cpp CodeModelGeneratorTest.cpp CodeRewriter.cpp CodeWriterInsertTest.cpp CodeWriterInsertTest.h CodeWriterTestBase.cpp CodeWriterTestBase.h Log Message: * added support for inserting multiple variable declarations Index: CodeModel.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModel.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** CodeModel.cpp 6 Apr 2003 07:42:16 -0000 1.10 --- CodeModel.cpp 6 Apr 2003 18:06:59 -0000 1.11 *************** *** 358,366 **** ASTNodePtr initializerNode = node->getProperty( ASTNodeProperties::variableInitializerProperty ); if ( !initializerNode ) ! return DeclaratorPtr( new Declarator( type, name, typeSuffix ) ); ExpressionPtr initializer = makeVariableInitializerExpression( initializerNode ); ! return DeclaratorPtr( new Declarator( type, name, typeSuffix, initializer ) ); } --- 358,370 ---- ASTNodePtr initializerNode = node->getProperty( ASTNodeProperties::variableInitializerProperty ); + + TypePartPtr typePtr( new TypePart( type ) ); + TypePartPtr typeSuffixPtr( new TypePart( typeSuffix ) ); + IdentifierPtr namePtr( new Identifier( name ) ); if ( !initializerNode ) ! return DeclaratorPtr( new Declarator( typePtr, namePtr, typeSuffixPtr ) ); ExpressionPtr initializer = makeVariableInitializerExpression( initializerNode ); ! return DeclaratorPtr( new Declarator( typePtr, namePtr, typeSuffixPtr, initializer ) ); } Index: CodeModelExpressions.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelExpressions.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** CodeModelExpressions.cpp 6 Apr 2003 07:42:16 -0000 1.12 --- CodeModelExpressions.cpp 6 Apr 2003 18:06:59 -0000 1.13 *************** *** 160,166 **** ! Declarator::Declarator( const std::string &type, ! const std::string &name, ! const std::string &typeSuffix ) : type_( type ) , name_( name ) --- 160,182 ---- ! Identifier::Identifier( const std::string &identifier ) ! : identifier_( identifier ) ! { ! } ! ! ! std::string ! Identifier::getIdentifier() const ! { ! if ( isFromSource() ) ! return getSourceText(); ! return identifier_; ! } ! ! ! ! Declarator::Declarator( const TypePartPtr &type, ! const IdentifierPtr &name, ! const TypePartPtr &typeSuffix ) : type_( type ) , name_( name ) *************** *** 170,176 **** ! Declarator::Declarator( const std::string &type, ! const std::string &name, ! const std::string &typeSuffix, const ExpressionPtr &initializer ) : type_( type ) --- 186,192 ---- ! Declarator::Declarator( const TypePartPtr &type, ! const IdentifierPtr &name, ! const TypePartPtr &typeSuffix, const ExpressionPtr &initializer ) : type_( type ) *************** *** 187,191 **** ! std::string Declarator::getType() const { --- 203,207 ---- ! TypePartPtr Declarator::getType() const { *************** *** 195,199 **** void ! Declarator::setType( const std::string &type ) { type_ = type; --- 211,215 ---- void ! Declarator::setType( const TypePartPtr &type ) { type_ = type; *************** *** 201,205 **** ! std::string Declarator::getTypeSuffix() const { --- 217,221 ---- ! TypePartPtr Declarator::getTypeSuffix() const { *************** *** 209,213 **** void ! Declarator::setTypeSuffix( const std::string &typeSuffix ) { typeSuffix_ = typeSuffix; --- 225,229 ---- void ! Declarator::setTypeSuffix( const TypePartPtr &typeSuffix ) { typeSuffix_ = typeSuffix; *************** *** 215,219 **** ! std::string Declarator::getName() const { --- 231,235 ---- ! IdentifierPtr Declarator::getName() const { *************** *** 223,227 **** void ! Declarator::setName( const std::string &name ) { name_ = name; --- 239,243 ---- void ! Declarator::setName( const IdentifierPtr &name ) { name_ = name; *************** *** 248,251 **** --- 264,275 ---- initializer_ = initializer; } + + + void + Declarator::accept( ElementVisitor &visitor ) + { + // @todo baptiste implement this + } + Index: CodeModelGeneratorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeModelGeneratorTest.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CodeModelGeneratorTest.cpp 6 Apr 2003 15:11:23 -0000 1.5 --- CodeModelGeneratorTest.cpp 6 Apr 2003 18:06:59 -0000 1.6 *************** *** 55,61 **** CodeModel::DeclaratorPtr declarator = declExpression->getDeclaratorAt(0); ! RFTA_ASSERT_EQUAL( "", declarator->getType() ); ! RFTA_ASSERT_EQUAL( "", declarator->getTypeSuffix() ); ! RFTA_ASSERT_EQUAL( "x", declarator->getName() ); CPPUNIT_ASSERT( declarator->hasInitializer() ); --- 55,61 ---- CodeModel::DeclaratorPtr declarator = declExpression->getDeclaratorAt(0); ! RFTA_ASSERT_EQUAL( "", declarator->getType()->getTypeText() ); ! RFTA_ASSERT_EQUAL( "", declarator->getTypeSuffix()->getTypeText() ); ! RFTA_ASSERT_EQUAL( "x", declarator->getName()->getIdentifier() ); CPPUNIT_ASSERT( declarator->hasInitializer() ); Index: CodeRewriter.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeRewriter.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** CodeRewriter.cpp 6 Apr 2003 07:42:16 -0000 1.36 --- CodeRewriter.cpp 6 Apr 2003 18:06:59 -0000 1.37 *************** *** 342,359 **** CodeRewriter::visit( const DeclarationStatementPtr &statement ) { ! if ( isInserting() ) ! { ! DeclaratorExpressionPtr declarators = statement->getDeclaration(); ! ! beginInsertNewStatement(); ! insertText( declarators->getPrimaryType()->getTypeText() ); ! ! DeclaratorPtr declarator = declarators->getDeclaratorAt(0); ! insertText( declarator->getType() ); ! insertText( declarator->getName() ); ! insertText( declarator->getTypeSuffix() ); ! ! endInsertNewStatement(); ! } } --- 342,346 ---- CodeRewriter::visit( const DeclarationStatementPtr &statement ) { ! statement->getDeclaration()->accept( *this ); } *************** *** 647,650 **** --- 634,658 ---- CodeRewriter::visit( const DeclaratorExpressionPtr &expression ) { + if ( isInserting() ) + { + if ( expression->getDeclaratorCount() == 0 ) + return; + + beginInsertNewStatement(); + insertText( expression->getPrimaryType()->getTypeText() ); + + for ( int index =0; index < expression->getDeclaratorCount(); ++index ) + { + if ( index > 0 ) + insertText( ", " ); + + DeclaratorPtr declarator = expression->getDeclaratorAt(index); + insertText( declarator->getType()->getTypeText() ); + insertText( declarator->getName()->getIdentifier() ); + insertText( declarator->getTypeSuffix()->getTypeText() ); + } + + endInsertNewStatement(); + } } Index: CodeWriterInsertTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterInsertTest.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CodeWriterInsertTest.cpp 6 Apr 2003 15:11:23 -0000 1.8 --- CodeWriterInsertTest.cpp 6 Apr 2003 18:06:59 -0000 1.9 *************** *** 282,286 **** CodeModel::DeclaratorExpressionPtr declarators( new CodeModel::DeclaratorExpression( makeTypePart( "int " ) ) ); ! CodeModel::DeclaratorPtr declarator( new CodeModel::Declarator( "", "var", "[3]" ) ); declarators->appendDeclarator( declarator ); CodeModel::StatementPtr declarationStatement( new CodeModel::DeclarationStatement( declarators ) ); --- 282,288 ---- CodeModel::DeclaratorExpressionPtr declarators( new CodeModel::DeclaratorExpression( makeTypePart( "int " ) ) ); ! CodeModel::DeclaratorPtr declarator( new CodeModel::Declarator( makeTypePart(""), ! makeIdentifier("var"), ! makeTypePart("[3]") ) ); declarators->appendDeclarator( declarator ); CodeModel::StatementPtr declarationStatement( new CodeModel::DeclarationStatement( declarators ) ); *************** *** 288,291 **** --- 290,314 ---- "{\n" " int var[3];\n" + "}" ); + } + + + void + CodeWriterInsertTest::testInsertDeclarationStatementWithManyVariables() + { + CodeModel::DeclaratorExpressionPtr declarators( + new CodeModel::DeclaratorExpression( makeTypePart( "int " ) ) ); + CodeModel::DeclaratorPtr declarator( new CodeModel::Declarator( makeTypePart(""), + makeIdentifier("var"), + makeTypePart("[3]") ) ); + declarators->appendDeclarator( declarator ); + CodeModel::DeclaratorPtr declarator2( new CodeModel::Declarator( makeTypePart("*"), + makeIdentifier("var2"), + makeTypePart("[7][4]") ) ); + declarators->appendDeclarator( declarator2 ); + CodeModel::StatementPtr declarationStatement( new CodeModel::DeclarationStatement( declarators ) ); + checkGeneratedSource( declarationStatement, + "{\n" + " int var[3], *var2[7][4];\n" "}" ); } Index: CodeWriterInsertTest.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterInsertTest.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CodeWriterInsertTest.h 21 Mar 2003 07:32:26 -0000 1.5 --- CodeWriterInsertTest.h 6 Apr 2003 18:06:59 -0000 1.6 *************** *** 34,37 **** --- 34,38 ---- CPPUNIT_TEST( testInsertForStatement ); CPPUNIT_TEST( testInsertDeclarationStatement ); + CPPUNIT_TEST( testInsertDeclarationStatementWithManyVariables ); CPPUNIT_TEST_SUITE_END(); *************** *** 60,63 **** --- 61,65 ---- void testInsertForStatement(); void testInsertDeclarationStatement(); + void testInsertDeclarationStatementWithManyVariables(); private: Index: CodeWriterTestBase.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTestBase.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CodeWriterTestBase.cpp 6 Apr 2003 15:11:23 -0000 1.6 --- CodeWriterTestBase.cpp 6 Apr 2003 18:06:59 -0000 1.7 *************** *** 88,91 **** --- 88,98 ---- + CodeModel::IdentifierPtr + CodeWriterTestBase::makeIdentifier( const std::string &identifier ) + { + return CodeModel::IdentifierPtr( new CodeModel::Identifier( identifier ) ); + } + + void CodeWriterTestBase::generateAndCheckSource( const std::string &expectedSource ) Index: CodeWriterTestBase.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rfta/CodeWriterTestBase.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CodeWriterTestBase.h 24 Mar 2003 07:57:51 -0000 1.4 --- CodeWriterTestBase.h 6 Apr 2003 18:06:59 -0000 1.5 *************** *** 38,41 **** --- 38,43 ---- CodeModel::TypePartPtr makeTypePart( const std::string &typePart ); + CodeModel::IdentifierPtr makeIdentifier( const std::string &identifier ); + void generateAndCheckSource( const std::string &expectedSource ); |
From: <bl...@us...> - 2003-04-06 18:07:02
|
Update of /cvsroot/cpptool/rfta/include/rfta/refactoring In directory sc8-pr-cvs1:/tmp/cvs-serv21204/include/rfta/refactoring Modified Files: CodeModelExpressions.h CodeModelForward.h Log Message: * added support for inserting multiple variable declarations Index: CodeModelExpressions.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelExpressions.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** CodeModelExpressions.h 6 Apr 2003 07:42:16 -0000 1.14 --- CodeModelExpressions.h 6 Apr 2003 18:06:59 -0000 1.15 *************** *** 92,117 **** ! class RFTA_API Declarator { public: ! Declarator( const std::string &type, ! const std::string &name, ! const std::string &typeSuffix ); ! Declarator( const std::string &type, ! const std::string &name, ! const std::string &typeSuffix, const ExpressionPtr &initializer ); virtual ~Declarator(); ! std::string getType() const; ! void setType( const std::string &type ); ! std::string getTypeSuffix() const; ! void setTypeSuffix( const std::string &typeSuffix ); ! std::string getName() const; ! void setName( const std::string &name ); bool hasInitializer() const; --- 92,129 ---- ! class RFTA_API Identifier : public Element { public: ! Identifier( const std::string &identifier = "" ); ! std::string getIdentifier() const; ! ! private: ! std::string identifier_; ! }; ! ! ! class RFTA_API Declarator : public Element ! { ! public: ! Declarator( const TypePartPtr &type, ! const IdentifierPtr &name, ! const TypePartPtr &typeSuffix ); ! ! Declarator( const TypePartPtr &type, ! const IdentifierPtr &name, ! const TypePartPtr &typeSuffix, const ExpressionPtr &initializer ); virtual ~Declarator(); ! TypePartPtr getType() const; ! void setType( const TypePartPtr &type ); ! TypePartPtr getTypeSuffix() const; ! void setTypeSuffix( const TypePartPtr &typeSuffix ); ! IdentifierPtr getName() const; ! void setName( const IdentifierPtr &name ); bool hasInitializer() const; *************** *** 119,126 **** void setInitializer( const ExpressionPtr &initializer ); private: ! std::string type_; ! std::string name_; ! std::string typeSuffix_; ExpressionPtr initializer_; }; --- 131,141 ---- void setInitializer( const ExpressionPtr &initializer ); + // overridden from Element + void accept( ElementVisitor &visitor ); + private: ! TypePartPtr type_; ! IdentifierPtr name_; ! TypePartPtr typeSuffix_; ExpressionPtr initializer_; }; Index: CodeModelForward.h =================================================================== RCS file: /cvsroot/cpptool/rfta/include/rfta/refactoring/CodeModelForward.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CodeModelForward.h 6 Apr 2003 07:20:23 -0000 1.13 --- CodeModelForward.h 6 Apr 2003 18:06:59 -0000 1.14 *************** *** 15,18 **** --- 15,19 ---- class Label; class TypePart; + class Identifier; class BreakStatement; *************** *** 70,73 **** --- 71,75 ---- typedef boost::shared_ptr<Label> LabelPtr; typedef boost::shared_ptr<TypePart> TypePartPtr; + typedef boost::shared_ptr<Identifier> IdentifierPtr; typedef boost::shared_ptr<DeclaratorExpression> DeclaratorExpressionPtr; typedef boost::shared_ptr<Expression> ExpressionPtr; |
From: <bl...@us...> - 2003-04-06 16:17:23
|
Update of /cvsroot/cpptool/rfta/src/rftaparser In directory sc8-pr-cvs1:/tmp/cvs-serv7316/src/rftaparser Modified Files: VariableDeclMutator.cpp VariableDeclMutator.h VariableDeclMutatorTest.cpp Log Message: * modified variable decl child node range. It now encompass the ', ' that follow the variable declaration. Index: VariableDeclMutator.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/VariableDeclMutator.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** VariableDeclMutator.cpp 15 Mar 2003 16:57:39 -0000 1.15 --- VariableDeclMutator.cpp 6 Apr 2003 16:17:19 -0000 1.16 *************** *** 96,100 **** prefixEndIndex, // variable name start suffixStartIndex, ! suffixEndIndex ); // from now, throw parse failure if unexpected stuff happen --- 96,100 ---- prefixEndIndex, // variable name start suffixStartIndex, ! suffixEndIndex ); // position of last white space after ',' if many variable // from now, throw parse failure if unexpected stuff happen *************** *** 114,118 **** { ASTNodePtr variableDeclNode = ! createVariableDeclarationNode( declStatement, suffixEnd ); addVariableNameNode( variableDeclNode, variableNameStart, suffixStart ); --- 114,118 ---- { ASTNodePtr variableDeclNode = ! createVariableDeclarationNode( declStatement, secondaryPrefixStart, suffixEnd ); addVariableNameNode( variableDeclNode, variableNameStart, suffixStart ); *************** *** 204,224 **** bool VariableDeclMutator::parseTemplateParameterList( const char *¤t, ! const char *end) { ! const char* start = current; ! if ( !tryFindNextBalanced( current, end ) ) ! return false; ! // take care of logical operators ! for (; start < current-1; start++) ! switch(*start) ! { case '&': case '|': ! if (start[1] == start[0]) ! return false; ! break; default: ! break; ! } ! return true; }; --- 204,224 ---- bool VariableDeclMutator::parseTemplateParameterList( const char *¤t, ! const char *end) { ! const char* start = current; ! if ( !tryFindNextBalanced( current, end ) ) ! return false; ! // take care of logical operators ! for (; start < current-1; start++) ! switch(*start) ! { case '&': case '|': ! if (start[1] == start[0]) ! return false; ! break; default: ! break; ! } ! return true; }; *************** *** 380,383 **** --- 380,384 ---- { skipSpaces(); + adjustPreviousDeclarationEndIndex( getCurrentIndex() ); int secondaryPrefixStartIndex = getCurrentIndex(); const char *secondaryPrefixStart = current_; *************** *** 505,515 **** ASTNodePtr ! VariableDeclMutator::createVariableDeclarationNode(const ASTNodePtr& parent, ! int suffixEnd) const { ASTNodePtr result = createASTNode( ASTNodeTypes::variableDeclExpression, ! parent, ! getStartIndex(), ! suffixEnd - getStartIndex() ); // the correct length is set when the initializer is added. parent->addChild(result); --- 506,517 ---- ASTNodePtr ! VariableDeclMutator::createVariableDeclarationNode( const ASTNodePtr &parent, ! int secondaryPrefixStart, ! int suffixEnd ) const { ASTNodePtr result = createASTNode( ASTNodeTypes::variableDeclExpression, ! parent, ! secondaryPrefixStart, ! suffixEnd - getStartIndex() ); // the correct length is set when the initializer is added. parent->addChild(result); *************** *** 611,614 **** --- 613,625 ---- variableDeclNode->setPropertyNode( ASTNodeProperties::variableInitializerProperty, initializerNode ); + } + + + void + VariableDeclMutator::adjustPreviousDeclarationEndIndex( int separatorEndIndex ) + { + int lastVarIndex = node_->getChildCount() -1; + ASTNodePtr previousVarNode = node_->getChildAt( lastVarIndex ); + previousVarNode->setLength( separatorEndIndex - previousVarNode->getStartIndex() ); } Index: VariableDeclMutator.h =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/VariableDeclMutator.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** VariableDeclMutator.h 12 Dec 2002 15:18:01 -0000 1.6 --- VariableDeclMutator.h 6 Apr 2003 16:17:20 -0000 1.7 *************** *** 69,72 **** --- 69,73 ---- ASTNodePtr createVariableDeclarationNode( const ASTNodePtr& parent, + int secondaryPrefixStart, int suffixEnd) const; void addVariableNameNode( const ASTNodePtr& parent, *************** *** 87,90 **** --- 88,93 ---- const ASTNodeType initializerType, int initializerStartIndex ) const; + + void adjustPreviousDeclarationEndIndex( int separatorEndIndex ); private: Index: VariableDeclMutatorTest.cpp =================================================================== RCS file: /cvsroot/cpptool/rfta/src/rftaparser/VariableDeclMutatorTest.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** VariableDeclMutatorTest.cpp 30 Dec 2002 15:01:59 -0000 1.13 --- VariableDeclMutatorTest.cpp 6 Apr 2003 16:17:20 -0000 1.14 *************** *** 354,360 **** { std::string source( " int x1( 7 )" ); - int var1EndIndex = source.length(); int var1PrefixLength = 4; source += ", "; int var2PrefixStartIndex = source.length(); source += "*"; --- 354,360 ---- { std::string source( " int x1( 7 )" ); int var1PrefixLength = 4; source += ", "; + int var1EndIndex = source.length(); int var2PrefixStartIndex = source.length(); source += "*"; *************** *** 366,369 **** --- 366,370 ---- source += "; "; int startIndex = 3; + int decl1StartIndex = startIndex + std::string("int ").length(); int length = source.length() - 2 - startIndex; *************** *** 388,393 **** // var1 ASTNodePtr declStatement1 = statement->getChildAt(0); ! RFTA_ASSERT_EQUAL( startIndex, declStatement1->getStartIndex() ); ! RFTA_ASSERT_EQUAL( var1EndIndex-startIndex, declStatement1->getLength() ); ASTNodePtr var1TypePrefix = declStatement1->getProperty( --- 389,394 ---- // var1 ASTNodePtr declStatement1 = statement->getChildAt(0); ! RFTA_ASSERT_EQUAL( decl1StartIndex, declStatement1->getStartIndex() ); ! RFTA_ASSERT_EQUAL( var1EndIndex-decl1StartIndex, declStatement1->getLength() ); ASTNodePtr var1TypePrefix = declStatement1->getProperty( *************** *** 404,409 **** // var2 ASTNodePtr declStatement2 = statement->getChildAt(1); ! RFTA_ASSERT_EQUAL( startIndex, declStatement2->getStartIndex() ); ! RFTA_ASSERT_EQUAL( var2EndIndex-startIndex, declStatement2->getLength() ); ASTNodePtr var2TypePrefix = declStatement2->getProperty( --- 405,410 ---- // var2 ASTNodePtr declStatement2 = statement->getChildAt(1); ! RFTA_ASSERT_EQUAL( var2PrefixStartIndex, declStatement2->getStartIndex() ); ! RFTA_ASSERT_EQUAL( var2EndIndex-var2PrefixStartIndex, declStatement2->getLength() ); ASTNodePtr var2TypePrefix = declStatement2->getProperty( |