1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-04-18 17:38:40 +00:00
parent 0f416da87c
commit 6c11ab94ca

View file

@ -46,19 +46,22 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.NodeHelper;
* @author Mirko Stocker, Lukas Felber
*/
public class MethodDefinitionInsertLocationFinder2 {
// We cache DefinitionFinder2.getDefinition results because refactorings like Implement Method might want to find multiple
// insert locations in the same translation unit. This prevents many redundant calls to DefinitionFinder2.getDefinition
// and speeds up the process quite a bit. Unfortunately, this has the minor side-effect or having to instantiate this class.
Map<IASTSimpleDeclaration, IASTName> cachedDeclarationToDefinition = new HashMap<IASTSimpleDeclaration, IASTName>();
// We cache DefinitionFinder2.getDefinition results because refactorings like Implement Method
// might want to find multiple insert locations in the same translation unit. This prevents
// many redundant calls to DefinitionFinder2.getDefinition and speeds up the process quite
//a bit. Unfortunately, this has the minor side-effect or having to instantiate this class.
Map<IASTSimpleDeclaration, IASTName> cachedDeclarationToDefinition =
new HashMap<IASTSimpleDeclaration, IASTName>();
public InsertLocation2 find(ITranslationUnit declarationTu, IASTFileLocation methodDeclarationLocation,
IASTNode parent, RefactoringASTCache astCache, IProgressMonitor pm) throws CoreException {
IASTDeclaration[] declarations = NodeHelper.getDeclarations(parent);
InsertLocation2 insertLocation = new InsertLocation2();
Collection<IASTSimpleDeclaration> allPreviousSimpleDeclarationsFromClassInReverseOrder = getAllPreviousSimpleDeclarationsFromClassInReverseOrder(declarations, methodDeclarationLocation, pm);
Collection<IASTSimpleDeclaration> allFollowingSimpleDeclarationsFromClass = getAllFollowingSimpleDeclarationsFromClass(declarations, methodDeclarationLocation, pm);
Collection<IASTSimpleDeclaration> allPreviousSimpleDeclarationsFromClassInReverseOrder =
getAllPreviousSimpleDeclarationsFromClassInReverseOrder(declarations, methodDeclarationLocation, pm);
Collection<IASTSimpleDeclaration> allFollowingSimpleDeclarationsFromClass =
getAllFollowingSimpleDeclarationsFromClass(declarations, methodDeclarationLocation, pm);
for (IASTSimpleDeclaration simpleDeclaration : allPreviousSimpleDeclarationsFromClassInReverseOrder) {
if (pm != null && pm.isCanceled()) {