|
From: <net...@us...> - 2004-01-13 22:28:17
|
Update of /cvsroot/cpptool/rfta/src/rfta
In directory sc8-pr-cvs1:/tmp/cvs-serv10304/rfta
Modified Files:
SplitDeclarationRefactoring.cpp
Log Message:
-- integrated preprocessor (replaced all NonSemanticBlanker)
Index: SplitDeclarationRefactoring.cpp
===================================================================
RCS file: /cvsroot/cpptool/rfta/src/rfta/SplitDeclarationRefactoring.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** SplitDeclarationRefactoring.cpp 20 Dec 2003 08:59:50 -0000 1.6
--- SplitDeclarationRefactoring.cpp 13 Jan 2004 22:28:13 -0000 1.7
***************
*** 10,16 ****
#include "IdentifierResolverContext.h"
#include "ReplaceTextTransform.h"
- #include "PreProcessTransform.h"
#include <rfta/refactoring/TransformList.h>
- #include <rfta/parser/MacroReplaceRegistration.h>
#include <rfta/parser/MaxLODMutator.h>
#include <rfta/parser/PreProcessor.h>
--- 10,14 ----
***************
*** 22,26 ****
#include <rfta/parser/ASTNodes.h>
#include <rfta/refactoring/RefactoringError.h>
! #include <rfta/refactoring/TextDocument.h>
#include <rfta/refactoring/CodeModelGenerator.h>
#include <rfta/refactoring/CodeModelStatements.h>
--- 20,26 ----
#include <rfta/parser/ASTNodes.h>
#include <rfta/refactoring/RefactoringError.h>
! #include <rfta/parser/TextDocument.h>
! #include <rfta/parser/Source.h>
! #include <rfta/refactoring/TransformList.h>
#include <rfta/refactoring/CodeModelGenerator.h>
#include <rfta/refactoring/CodeModelStatements.h>
***************
*** 34,40 ****
SplitDeclarationRefactoring::
! SplitDeclarationRefactoring( TextDocument &document,
int declarationLocation )
! : RefactoringBase( document )
, declarationLocation_( declarationLocation )
{
--- 34,41 ----
SplitDeclarationRefactoring::
! SplitDeclarationRefactoring( SourcePtr source,
! SourceManager& manager,
int declarationLocation )
! : RefactoringBase( source, manager )
, declarationLocation_( declarationLocation )
{
***************
*** 56,86 ****
// preprocess
! PreProcessor proc( source );
! MacroReplaceRegistration registration;
! std::string blankedSource = proc.process(registration);
! registration.finishUpData();
// correct pointer to location after preprocessing
! declarationLocation_ -= registration.getReplacementDeltaBefore(SourceRange( declarationLocation_, 1 ));
!
! // store macro replacement information
! int idx;
! for (idx=0; idx < registration.getSize(); idx++)
! {
! MacroReplaceRegistration::MacroReplacement entry = registration.getEntry(idx);
! transforms_.add( *new PreProcessTransform( entry.position_, entry.macroText_.size() - entry.replacement_.size() ) );
! }
int compoundStartIndex =
! ToolsBox::findCompoundBefore( blankedSource, declarationLocation_ );
if ( compoundStartIndex < 0 )
throw RefactoringError( RefactoringError::temporaryNotInFunctionBody );
! sourceNode_ = SourceASTNode::create( blankedSource, source );
ParseContext context( sourceNode_ );
StatementParser parser( context,
sourceNode_->getBlankedSourceStart() +
! compoundStartIndex,
sourceNode_->getBlankedSourceEnd() );
parser.parse();
--- 57,80 ----
// preprocess
! PreProcessorContext preproc_context( getSourceManager() );
! PreProcessor proc( getSource(), preproc_context );
!
! proc.setOption(PreProcessor::skipIncludes); // TODO: disable this if preprocessor features can handle all system headers
! blankedSource_ = proc.process();
// correct pointer to location after preprocessing
! declarationLocation_ = getSource()->getRangePreProcessed(SourceRange( declarationLocation_, 1 )).getStartIndex();
int compoundStartIndex =
! ToolsBox::findCompoundBefore( blankedSource_, declarationLocation_ );
if ( compoundStartIndex < 0 )
throw RefactoringError( RefactoringError::temporaryNotInFunctionBody );
! sourceNode_ = SourceASTNode::create( blankedSource_, source, getSource() );
ParseContext context( sourceNode_ );
StatementParser parser( context,
sourceNode_->getBlankedSourceStart() +
! compoundStartIndex,
sourceNode_->getBlankedSourceEnd() );
parser.parse();
***************
*** 151,157 ****
}
! std::string source( getDocument().getAllText());
! CodeModel::CodeRewriter writer(source, 2);
! writer.rewrite(compound, transforms_, getDocument());
}
--- 145,150 ----
}
! CodeModel::CodeRewriter writer(getSource(), 2);
! writer.rewrite(compound);
}
|