Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2015-01-06 03:08:39 +0000
committerSergey Prigogin2015-01-06 03:08:39 +0000
commit75900af3aee09a6a11a8c62b1a11006968dbe285 (patch)
tree133402740aff9e40e1da6142bc39615c9ee958aa
parent5d6e09d1cb940b23aef241d5eae8aa7bafa64164 (diff)
downloadorg.eclipse.cdt-75900af3aee09a6a11a8c62b1a11006968dbe285.tar.gz
org.eclipse.cdt-75900af3aee09a6a11a8c62b1a11006968dbe285.tar.xz
org.eclipse.cdt-75900af3aee09a6a11a8c62b1a11006968dbe285.zip
Improved "Expand Selection To Enclosing Element" command for template
definitions.
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectEnclosingAction.java15
1 files changed, 10 insertions, 5 deletions
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());
}

Back to the top