From a8e7f57545b557806b2a10fb1fb95c3e4489d9c6 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 29 Feb 2008 09:10:44 +0000 Subject: [PATCH] Combine CFindNodeForOffsetAction and CPPFindNodeForOffsetAction. --- .../core/dom/parser/ASTTranslationUnit.java | 24 ++ .../dom/parser/FindNodeForOffsetAction.java | 214 +++++++++++++++++ .../dom/parser/c/CASTTranslationUnit.java | 226 ------------------ .../core/dom/parser/c/GNUCSourceParser.java | 14 +- .../dom/parser/cpp/CPPASTTranslationUnit.java | 180 +------------- .../dom/parser/cpp/GNUCPPSourceParser.java | 14 +- .../eclipse/cdt/ui/tests/BaseUITestCase.java | 9 +- 7 files changed, 259 insertions(+), 422 deletions(-) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/FindNodeForOffsetAction.java diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java index 5a9a8bb9387..caa28508919 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTTranslationUnit.java @@ -19,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTComment; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition; @@ -308,4 +309,27 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat public final IIndexFileSet getIndexFileSet() { return fIndexFileSet; } + + /* + * (non-Javadoc) + * + * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation) + */ + public final IASTNode selectNodeForLocation(String path, int realOffset, int realLength) { + IASTNode result= null; + if (fLocationResolver != null) { + int start= fLocationResolver.getSequenceNumberForFileOffset(path, realOffset); + if (start >= 0) { + int length= realLength < 1 ? 0 : + fLocationResolver.getSequenceNumberForFileOffset(path, realOffset+realLength-1) + 1 - start; + result= fLocationResolver.findSurroundingPreprocessorNode(start, length); + if (result == null) { + FindNodeForOffsetAction nodeFinder = new FindNodeForOffsetAction(start, length); + accept(nodeFinder); + result = nodeFinder.getNode(); + } + } + } + return result; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/FindNodeForOffsetAction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/FindNodeForOffsetAction.java new file mode 100644 index 00000000000..a42d41926e6 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/FindNodeForOffsetAction.java @@ -0,0 +1,214 @@ +/******************************************************************************* + * Copyright (c) 2008 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Markus Schorn - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser; + +import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; +import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTExpression; +import org.eclipse.cdt.core.dom.ast.IASTInitializer; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; +import org.eclipse.cdt.core.dom.ast.IASTProblem; +import org.eclipse.cdt.core.dom.ast.IASTStatement; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.dom.ast.IASTTypeId; +import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; +import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator; +import org.eclipse.cdt.core.dom.ast.c.ICASTVisitor; +import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisitor; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; + +public class FindNodeForOffsetAction extends CPPASTVisitor implements ICASTVisitor, ICPPASTVisitor { + private IASTNode fFoundNode = null; + private int fOffset = 0; + private int fLength = 0; + + public FindNodeForOffsetAction(int offset, int length) { + fOffset = offset; + fLength = length; + + shouldVisitNames = true; + shouldVisitDeclarations = true; + shouldVisitInitializers = true; + shouldVisitParameterDeclarations = true; + shouldVisitDeclarators = true; + shouldVisitDeclSpecifiers = true; + shouldVisitDesignators = true; + shouldVisitEnumerators = true; + shouldVisitExpressions = true; + shouldVisitStatements = true; + shouldVisitTypeIds = true; + shouldVisitEnumerators = true; + shouldVisitBaseSpecifiers = true; + shouldVisitNamespaces = true; + shouldVisitTemplateParameters= true; + shouldVisitTranslationUnit= true; + } + + public int processNode(IASTNode node) { + if (fFoundNode != null) + return PROCESS_ABORT; + + if (node instanceof ASTNode) { + final int offset = ((ASTNode) node).getOffset(); + final int length = ((ASTNode) node).getLength(); + + if (offset == fOffset && length == fLength) { + fFoundNode = node; + return PROCESS_ABORT; + } + + // skip the rest of this node if the selection is outside of its + // bounds + if (fOffset > offset + length) + return PROCESS_SKIP; + } + return PROCESS_CONTINUE; + } + + @Override + public int visit(IASTDeclaration declaration) { + // use declarations to determine if the search has gone past the + // offset (i.e. don't know the order the visitor visits the nodes) + if (declaration instanceof ASTNode + && ((ASTNode) declaration).getOffset() > fOffset) + return PROCESS_ABORT; + + return processNode(declaration); + } + + @Override + public int visit(IASTDeclarator declarator) { + int ret = processNode(declarator); + + IASTPointerOperator[] ops = declarator.getPointerOperators(); + for (int i = 0; i < ops.length; i++) + processNode(ops[i]); + + if (declarator instanceof IASTArrayDeclarator) { + IASTArrayModifier[] mods = ((IASTArrayDeclarator) declarator) + .getArrayModifiers(); + for (int i = 0; i < mods.length; i++) + processNode(mods[i]); + } + else if (declarator instanceof ICPPASTFunctionDeclarator) { + ICPPASTConstructorChainInitializer[] chainInit = ((ICPPASTFunctionDeclarator)declarator).getConstructorChain(); + for(int i=0; i ((ASTNode) node).getOffset() - + ((ASTNode) node).getLength()) - return PROCESS_SKIP; - - return PROCESS_CONTINUE; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processDeclaration(org.eclipse.cdt.core.dom.ast.IASTDeclaration) - */ - @Override - public int visit(IASTDeclaration declaration) { - // use declarations to determine if the search has gone past the - // offset (i.e. don't know the order the visitor visits the nodes) - if (declaration instanceof ASTNode - && ((ASTNode) declaration).getOffset() > offset) - return PROCESS_ABORT; - - return processNode(declaration); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor.CPPBaseVisitorAction#processDeclarator(org.eclipse.cdt.core.dom.ast.IASTDeclarator) - */ - @Override - public int visit(IASTDeclarator declarator) { - int ret = processNode(declarator); - - IASTPointerOperator[] ops = declarator.getPointerOperators(); - for (int i = 0; i < ops.length; i++) - processNode(ops[i]); - - if (declarator instanceof IASTArrayDeclarator) { - IASTArrayModifier[] mods = ((IASTArrayDeclarator) declarator) - .getArrayModifiers(); - for (int i = 0; i < mods.length; i++) - processNode(mods[i]); - } - - return ret; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processDesignator(org.eclipse.cdt.core.dom.ast.c.ICASTDesignator) - */ - @Override - public int visit(ICASTDesignator designator) { - return processNode(designator); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processDeclSpecifier(org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier) - */ - @Override - public int visit(IASTDeclSpecifier declSpec) { - return processNode(declSpec); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processEnumerator(org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator) - */ - @Override - public int visit(IASTEnumerator enumerator) { - return processNode(enumerator); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processExpression(org.eclipse.cdt.core.dom.ast.IASTExpression) - */ - @Override - public int visit(IASTExpression expression) { - return processNode(expression); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processInitializer(org.eclipse.cdt.core.dom.ast.IASTInitializer) - */ - @Override - public int visit(IASTInitializer initializer) { - return processNode(initializer); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processName(org.eclipse.cdt.core.dom.ast.IASTName) - */ - @Override - public int visit(IASTName name) { - if (name.toString() != null) - return processNode(name); - return PROCESS_CONTINUE; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processParameterDeclaration(org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration) - */ - @Override - public int visit( - IASTParameterDeclaration parameterDeclaration) { - return processNode(parameterDeclaration); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processStatement(org.eclipse.cdt.core.dom.ast.IASTStatement) - */ - @Override - public int visit(IASTStatement statement) { - return processNode(statement); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.internal.core.dom.parser.c.CVisitor.CBaseVisitorAction#processTypeId(org.eclipse.cdt.core.dom.ast.IASTTypeId) - */ - @Override - public int visit(IASTTypeId typeId) { - return processNode(typeId); - } - - public IASTNode getNode() { - return foundNode; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation) - */ - public IASTNode selectNodeForLocation(String path, int realOffset, int realLength) { - IASTNode result= null; - if (fLocationResolver != null) { - int start= fLocationResolver.getSequenceNumberForFileOffset(path, realOffset); - if (start >= 0) { - int length= realLength < 1 ? 0 : - fLocationResolver.getSequenceNumberForFileOffset(path, realOffset+realLength-1) + 1 - start; - result= fLocationResolver.findSurroundingPreprocessorNode(start, length); - if (result == null) { - CFindNodeForOffsetAction nodeFinder = new CFindNodeForOffsetAction(start, length); - accept(nodeFinder); - result = nodeFinder.getNode(); - } - } - } - return result; - } - public ParserLanguage getParserLanguage() { return ParserLanguage.C; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java index d389f23603b..6b67e444f57 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java @@ -571,13 +571,6 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { if (LA(1).hashCode() == checkOffset) failParseWithErrorHandling(); } catch (EndOfFileException e) { - IASTDeclaration[] declarations = translationUnit.getDeclarations(); - // As expected - if (declarations.length != 0) { - ASTNode d = (ASTNode) declarations[declarations.length-1]; - ((ASTNode) translationUnit).setLength(d.getOffset() + d.getLength()); - } else - ((ASTNode) translationUnit).setLength(0); break; } catch (BacktrackException b) { try { @@ -612,6 +605,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { } } } + IASTDeclaration[] declarations = translationUnit.getDeclarations(); + if (declarations.length != 0) { + ASTNode d = (ASTNode) declarations[declarations.length-1]; + ((ASTNode) translationUnit).setLength(d.getOffset() + d.getLength()); + } else { + ((ASTNode) translationUnit).setLength(0); + } } /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java index aab457d9ff7..562a6a574d7 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java @@ -13,19 +13,9 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.DOMException; -import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTArrayModifier; -import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; -import org.eclipse.cdt.core.dom.ast.IASTDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTExpression; -import org.eclipse.cdt.core.dom.ast.IASTInitializer; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration; -import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; -import org.eclipse.cdt.core.dom.ast.IASTStatement; -import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IFunctionType; @@ -33,13 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IMacroBinding; import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; -import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator; -import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator; -import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionTryBlockDeclarator; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; @@ -48,7 +31,6 @@ import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.Linkage; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; -import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider.CPPBuiltinParameter; @@ -148,167 +130,6 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST return CPPVisitor.getReferences(this, binding); } - private class CPPFindNodeForOffsetAction extends CPPASTVisitor { - { - shouldVisitNames = true; - shouldVisitDeclarations = true; - shouldVisitInitializers = true; - shouldVisitParameterDeclarations = true; - shouldVisitDeclarators = true; - shouldVisitDeclSpecifiers = true; - shouldVisitExpressions = true; - shouldVisitStatements = true; - shouldVisitTypeIds = true; - shouldVisitEnumerators = true; - shouldVisitBaseSpecifiers = true; - shouldVisitNamespaces = true; - } - - IASTNode foundNode = null; - int offset = 0; - int length = 0; - - /** - * - */ - public CPPFindNodeForOffsetAction(int offset, int length) { - this.offset = offset; - this.length = length; - } - - public int processNode(IASTNode node) { - if (foundNode != null) - return PROCESS_ABORT; - - if (node instanceof ASTNode && - ((ASTNode)node).getOffset() == offset && - ((ASTNode)node).getLength() == length) { - foundNode = node; - return PROCESS_ABORT; - } - - // skip the rest of this node if the selection is outside of its bounds - if (node instanceof ASTNode && - offset > ((ASTNode)node).getOffset() + ((ASTNode)node).getLength()) - return PROCESS_SKIP; - - return PROCESS_CONTINUE; - } - - - @Override - public int visit(IASTDeclaration declaration) { - // use declarations to determine if the search has gone past the offset (i.e. don't know the order the visitor visits the nodes) - if (declaration instanceof ASTNode && ((ASTNode)declaration).getOffset() > offset) - return PROCESS_ABORT; - - return processNode(declaration); - } - - - @Override - public int visit(IASTDeclarator declarator) { - int ret = processNode(declarator); - - IASTPointerOperator[] ops = declarator.getPointerOperators(); - for(int i=0; i= 0) { - int length= realLength < 1 ? 0 : - fLocationResolver.getSequenceNumberForFileOffset(path, realOffset+realLength-1) + 1 - start; - result= fLocationResolver.findSurroundingPreprocessorNode(start, length); - if (result == null) { - CPPFindNodeForOffsetAction nodeFinder = new CPPFindNodeForOffsetAction(start, length); - accept(nodeFinder); - result = nodeFinder.getNode(); - } - } - } - return result; - } - public IBinding resolveBinding() { if (fBinding == null) fBinding = new CPPNamespace(this); @@ -341,6 +162,7 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.parser.scanner.ISkippedIndexedFilesListener#skippedFile(org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent) */ + @Override public void skippedFile(int offset, IncludeFileContent fileContent) { super.skippedFile(offset, fileContent); fScopeMapper.registerAdditionalDirectives(offset, fileContent.getUsingDirectives()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index f24c498e592..1b23a8128d4 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -4320,12 +4320,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { if (LA(1).hashCode() == checkOffset) failParseWithErrorHandling(); } catch (EndOfFileException e) { - if (translationUnit.getDeclarations().length != 0) { - ASTNode d = (ASTNode) translationUnit.getDeclarations()[translationUnit.getDeclarations().length - 1]; - ((ASTNode) translationUnit).setLength(d.getOffset() + d.getLength()); - } else - ((ASTNode) translationUnit).setLength(0); - break; + break; } catch (BacktrackException b) { try { // Mark as failure and try to reach a recovery point @@ -4350,6 +4345,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { } } } + IASTDeclaration[] declarations = translationUnit.getDeclarations(); + if (declarations.length != 0) { + ASTNode d = (ASTNode) declarations[declarations.length-1]; + ((ASTNode) translationUnit).setLength(d.getOffset() + d.getLength()); + } else { + ((ASTNode) translationUnit).setLength(0); + } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java index 091badedf65..2462696e3cf 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java @@ -328,12 +328,13 @@ public class BaseUITestCase extends BaseTestCase { final String text= firstItem.getText(); if (text.length() > 0 && !text.equals("...")) { item= root.getItem(i1); - assertNotNull("Unexpected tree node " + item.getText(), label); - if (label.equals(item.getText())) { + itemText= item.getText(); + assertNotNull("Unexpected tree node " + itemText, label); + if (label.equals(itemText)) { return item; } if (i > 100) { - assertEquals(label, item.getText()); + assertEquals(label, itemText); return item; } } @@ -349,7 +350,7 @@ public class BaseUITestCase extends BaseTestCase { } runEventQueue(10); } - fail("Timeout expired waiting for tree node " + label + "{" + i0 + "," + i1 + "}"); + assertEquals("Timeout expired waiting for tree node {" + i0 + "," + i1 + "}", label, itemText); return null; } }