diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCapture.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCapture.java index 2891aabe067..c14a13fa57b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCapture.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTCapture.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.core.dom.ast.cpp; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNameOwner; import org.eclipse.cdt.core.dom.ast.IASTNode; /** @@ -21,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface ICPPASTCapture extends IASTNode, ICPPASTPackExpandable { +public interface ICPPASTCapture extends IASTNode, ICPPASTPackExpandable, IASTNameOwner { ASTNodeProperty IDENTIFIER = new ASTNodeProperty("ICPPASTCapture - IDENTIFIER [IASTName]"); //$NON-NLS-1$ @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCapture.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCapture.java index b5aea2ceaf8..28fbad63347 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCapture.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTCapture.java @@ -101,4 +101,14 @@ public class CPPASTCapture extends ASTNode implements ICPPASTCapture { assertNotFrozen(); fPackExpansion= val; } + + @Override + public int getRoleForName(IASTName name) { + if (name == fIdentifier) { + // Treat the capture as a reference to the captured variable. + // This choice may be revisited when C++14 init-captures are implemented. + return r_reference; + } + return r_unclear; + } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java index 8a52ba58184..559c4b68607 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/SemanticHighlightingTest.java @@ -483,4 +483,12 @@ public class SemanticHighlightingTest extends TestCase { public void testInheritingConstructor_484898() throws Exception { makeAssertions(); } + + // void foo(int param) { //$functionDeclaration,parameterVariable + // int local; //$localVariableDeclaration + // [local, param](){}; //$class,localVariable,parameterVariable + // } + public void testLocalVariableInLambdaCapture_486679() throws Exception { + makeAssertions(); + } }