diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectEnclosingAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectEnclosingAction.java index 0e35bc8803b..dde879e3a1e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectEnclosingAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectEnclosingAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Tomasz Wesolowski and others. + * Copyright (c) 2010, 2015 Tomasz Wesolowski 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 @@ -7,6 +7,7 @@ * * Contributors: * Tomasz Wesolowski - initial API and implementation + * Sergey Prigogin (Google) *******************************************************************************/ package org.eclipse.cdt.internal.ui.actions; @@ -18,6 +19,7 @@ import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNodeSelector; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.model.ISourceRange; import org.eclipse.cdt.internal.core.model.ext.SourceRange; @@ -39,16 +41,19 @@ public class StructureSelectEnclosingAction extends StructureSelectionAction { } return newSourceRange; } - + /** - * Made public to serve as fallback for other expansions + * Package visibility to serve as a fallback for other expansions. */ - public static ISourceRange expandToEnclosing(IASTTranslationUnit ast, SourceRange current) { + static ISourceRange expandToEnclosing(IASTTranslationUnit ast, SourceRange current) { final IASTNodeSelector nodeSelector = ast.getNodeSelector(null); IASTNode node = nodeSelector.findStrictlyEnclosingNode(current.getStartPos(), current.getLength()); if (node == null) return null; - + + if (node.getPropertyInParent() == ICPPASTTemplateDeclaration.OWNED_DECLARATION) + node = node.getParent(); + final IASTFileLocation fileLocation = node.getFileLocation(); return new SourceRange(fileLocation.getNodeOffset(), fileLocation.getNodeLength()); }