From 20feb58da06b4482f43cf12c92975e7c62601561 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Tue, 7 Oct 2014 15:54:08 -0700 Subject: [PATCH] Bug 446225 - Captured variables not recognized as usages --- .../cdt/core/parser/tests/ast2/AST2CPPTests.java | 1 + .../core/dom/parser/cpp/semantics/CPPVisitor.java | 10 ++++++---- .../cdt/internal/ui/search/OccurrencesFinder.java | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 7f0c1cefc11..51e0a1dc0e7 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -8336,6 +8336,7 @@ public class AST2CPPTests extends AST2TestBase { ICPPVariable foo1= bh.assertNonProblemOnFirstIdentifier("foo =", ICPPVariable.class); ICPPVariable foo2= bh.assertNonProblemOnFirstIdentifier("[foo]", ICPPVariable.class); assertTrue(foo1 == foo2); + assertEquals(2, bh.getTranslationUnit().getReferences(foo1).length); } // typedef int TInt; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index 3b7d56922a2..e7633f5a959 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -1443,7 +1443,7 @@ public class CPPVisitor extends ASTQueries { private void addProblem(IASTProblem problem) { if (fProblems == null) { - fProblems= new ArrayList(); + fProblems= new ArrayList<>(); } fProblems.add(problem); } @@ -1610,7 +1610,7 @@ public class CPPVisitor extends ASTQueries { if (areEquivalentBindings(nameBinding, binding, index)) { return true; } - // A using declaration is a declaration for the references of its delegates + // A using declaration is a declaration for the references of its delegates. if (nameBinding instanceof ICPPUsingDeclaration) { if (ArrayUtil.contains(((ICPPUsingDeclaration) nameBinding).getDelegates(), binding)) { return true; @@ -1634,8 +1634,9 @@ public class CPPVisitor extends ASTQueries { return true; } if ((binding1 instanceof IIndexBinding) != (binding2 instanceof IIndexBinding) && index != null) { - // Even though we know one of them is an index binding, we need to adapt both because they might not come from an - // index with the same number of fragments. So one of them could be a composite binding and the other one not. + // Even though we know one of them is an index binding, we need to adapt both because + // they might not come from an index with the same number of fragments. So one of them + // could be a composite binding and the other one not. binding1 = index.adaptBinding(binding1); binding2 = index.adaptBinding(binding2); @@ -1753,6 +1754,7 @@ public class CPPVisitor extends ASTQueries { prop == IASTNamedTypeSpecifier.NAME || prop == ICPPASTConstructorChainInitializer.MEMBER_ID || prop == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT || + prop == ICPPASTCapture.IDENTIFIER || prop == IASTImplicitNameOwner.IMPLICIT_NAME) { break; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java index b9c51148c94..9152951f7bc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java @@ -57,7 +57,7 @@ public class OccurrencesFinder implements IOccurrencesFinder { if (!(node instanceof IASTName)) return CSearchMessages.OccurrencesFinder_no_element; fRoot= root; - fSelectedNode= (IASTName)node; + fSelectedNode= (IASTName) node; fTarget= fSelectedNode.resolveBinding(); if (fTarget == null) return CSearchMessages.OccurrencesFinder_no_binding;