From: <net...@us...> - 2002-12-30 10:45:04
|
Update of /cvsroot/cpptool/rfta/include/rfta/refactoring In directory sc8-pr-cvs1:/tmp/cvs-serv30503/include/rfta/refactoring Added Files: InlineTempRefactoring.h Log Message: -- bugfix + moved header to global include --- NEW FILE: InlineTempRefactoring.h --- // ////////////////////////////////////////////////////////////////////////// // (c)Copyright 2002, Andre Baresel // Created: 2002/12/25 // ////////////////////////////////////////////////////////////////////////// #ifndef RFTA_RFTA_INLINETEMPREFACTORING_H #define RFTA_RFTA_INLINETEMPREFACTORING_H #include <rfta/parser/ASTNode.h> #include <rfta/refactoring/RefactoringBase.h> #include <rfta/refactoring/ToolsBox.h> namespace Refactoring { /// This class implements the algorithm for InlineTemp refactoring. class RFTA_API InlineTempRefactoring : public RefactoringBase { public: /** * constructs on object and prepares the inlining */ InlineTempRefactoring(TextDocument &document,int temporaryLocation); /** * destroys object data. */ virtual ~InlineTempRefactoring(); /** * function executes the inlining. */ void apply( bool doAddBraces ); //< refer 'areBracesSuggested' /** * function returns the name of the temporary which is about to be inlined */ const std::string getVariableName() const; /** * returns the number of occurences of the variable. */ int getVariableOccurrenceCount() const; bool areBracesSuggested(); //< returns true if braces are suggested private: void prepare(); //< does prepare the inlining (check if it's possible and find the locations for inlining) void findLocaleVariableOccurrences(); //< find the locations of variable uses void calculateTempDeclRange(); //< finds the source range of the temporary declaration bool isInitializerAtomic(); //< does check the initializer for being an atomic value or not void checkForVariableAssignments(); int temporaryLocation_; //< location where refactoring was asked for SourceASTNodePtr sourceNode_; //< parsed source of the location ToolsBox::ASTNodes occurrences_; //< occurences of the temporary variable ASTNodePtr localeVariableNode_; //< ast node of the identifier at selection ASTNodePtr temporaryDecl; //< ast node of the declaration of the selected identifier ASTNodePtr initValue_; //< ast node of the initializer that initializes the selected variable SourceRange rangeOfTempDeclaration; //< Range of temporary declaration that is inlined (this range can be erased after inlining) bool tempDeclaredInMiddle; //< true if the temporary is declared between other variables. }; // Inlines methods for InlineTempRefactoring: // ------------------------------------------ inline bool InlineTempRefactoring::areBracesSuggested() { return !isInitializerAtomic(); } } // namespace Refactoring #endif // RFTA_RFTA_INLINETEMPREFACTORING_H |