diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java index 7ef6c4e6661..17011824fbe 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation + * John Camelon (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -20,44 +20,12 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPASTTemplateDeclaration extends IASTDeclaration { - /** - * Is the export keyword used? - * - * @return boolean - */ - public boolean isExported(); - - /** - * Should the export keyword be used? - * - * @param value - * boolean - */ - public void setExported(boolean value); - - /** - * OWNED_DECLARATION is the subdeclaration that we maintain - * grammatically. + * OWNED_DECLARATION is the subdeclaration that we maintain grammatically. */ public static final ASTNodeProperty OWNED_DECLARATION = new ASTNodeProperty( "ICPPASTTemplateDeclaration.OWNED_DECLARATION - Subdeclaration maintained grammatically"); //$NON-NLS-1$ - /** - * Get template declaration. - * - * @return IASTDeclaration - */ - public IASTDeclaration getDeclaration(); - - /** - * Set the template declaration. - * - * @param declaration - * IASTDeclaration - */ - public void setDeclaration(IASTDeclaration declaration); - /** * PARAMETER is used for template parameters. */ @@ -65,29 +33,48 @@ public interface ICPPASTTemplateDeclaration extends IASTDeclaration { "ICPPASTTemplateDeclaration.PARAMETER - Template Parameter"); //$NON-NLS-1$ /** - * Get template parameters. - * - * @return ICPPASTTemplateParameter[] + * Is the export keyword used? + */ + public boolean isExported(); + + /** + * Should the export keyword be used? + */ + public void setExported(boolean value); + + /** + * Returns the template declaration. + */ + public IASTDeclaration getDeclaration(); + + /** + * Sets the template declaration. + * + * @param declaration the declaration to set + */ + public void setDeclaration(IASTDeclaration declaration); + + /** + * Returns the template parameters. */ public ICPPASTTemplateParameter[] getTemplateParameters(); /** - * Add a template parameter. + * Adds a template parameter. * - * @param parm ICPPASTTemplateParameter + * @param paramm the parameter to add * @since 5.2 */ - public void addTemplateParameter(ICPPASTTemplateParameter parm); + public void addTemplateParameter(ICPPASTTemplateParameter paramm); /** * @deprecated Use addTemplateParameter. */ @Deprecated - public void addTemplateParamter(ICPPASTTemplateParameter parm); + public void addTemplateParamter(ICPPASTTemplateParameter paramm); /** - * get the template scope representing this declaration in the logical tree - * @return ICPPTemplateScope + * Returns the template scope representing this declaration in the logical tree. */ public ICPPTemplateScope getScope(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalTemplateDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalTemplateDeclaration.java index 0b82f64d81b..d3892f27160 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalTemplateDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalTemplateDeclaration.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; * and the names of the nested declaration. */ public interface ICPPASTInternalTemplateDeclaration extends ICPPASTTemplateDeclaration { - /** * Returns whether this template declaration is associated with the last name of * the possibly qualified name of the enclosing declaration. If this template declaration diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java index 6c9764153ba..8c4136ff082 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java @@ -15,6 +15,7 @@ import java.util.ResourceBundle; import org.eclipse.ui.texteditor.ITextEditor; 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.model.ISourceRange; @@ -23,17 +24,14 @@ import org.eclipse.cdt.internal.core.model.ext.SourceRange; import org.eclipse.cdt.internal.ui.editor.SelectionHistory; public class StructureSelectNextAction extends StructureSelectionAction { - public static final String PREFIX = "StructureSelectNext."; //$NON-NLS-1$ - public StructureSelectNextAction(ResourceBundle bundle, ITextEditor editor, - SelectionHistory history) { + public StructureSelectNextAction(ResourceBundle bundle, ITextEditor editor, SelectionHistory history) { super(bundle, PREFIX, editor, history); } @Override public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) { - ISourceRange newSourceRange = expandToNext(ast, current); if (newSourceRange == null) { newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current); @@ -45,20 +43,19 @@ public class StructureSelectNextAction extends StructureSelectionAction { } private ISourceRange expandToNext(IASTTranslationUnit ast, SourceRange current) { - - IASTNode enclosingNode = ast.getNodeSelector(null).findEnclosingNode(current.getStartPos(), - current.getLength()); + IASTNodeSelector selector = ast.getNodeSelector(null); + IASTNode enclosingNode = selector.findEnclosingNode(current.getStartPos(), current.getLength()); if (samePosition(enclosingNode, current)) { enclosingNode = enclosingNode.getParent(); } if (enclosingNode == null) { return null; } - - // find the last child of enclosingNode containing selection end - - int selectionEnd = current.getStartPos()+current.getLength(); - + + // Find the last child of enclosingNode containing selection end. + + int selectionEnd = current.getStartPos() + current.getLength(); + int lastSelectedChildIndex = -1; IASTNode[] children = enclosingNode.getChildren(); for (int i = 0; i < children.length; i++) { @@ -68,13 +65,12 @@ public class StructureSelectNextAction extends StructureSelectionAction { break; } } - - if (lastSelectedChildIndex != -1 && lastSelectedChildIndex+1 < children.length) { - IASTNode nextNode = children[lastSelectedChildIndex+1]; - int endingOffset = nextNode.getFileLocation().getNodeOffset()+nextNode.getFileLocation().getNodeLength(); - return new SourceRange(current.getStartPos(),endingOffset-current.getStartPos()); + + if (lastSelectedChildIndex >= 0 && lastSelectedChildIndex + 1 < children.length) { + IASTNode nextNode = children[lastSelectedChildIndex + 1]; + int endingOffset = nextNode.getFileLocation().getNodeOffset() + nextNode.getFileLocation().getNodeLength(); + return new SourceRange(current.getStartPos(), endingOffset - current.getStartPos()); } return null; } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java index ecf7eacb72d..09e7542052b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java @@ -15,6 +15,7 @@ import java.util.ResourceBundle; import org.eclipse.ui.texteditor.ITextEditor; 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.model.ISourceRange; @@ -23,17 +24,14 @@ import org.eclipse.cdt.internal.core.model.ext.SourceRange; import org.eclipse.cdt.internal.ui.editor.SelectionHistory; public class StructureSelectPreviousAction extends StructureSelectionAction { - public static final String PREFIX = "StructureSelectPrevious."; //$NON-NLS-1$ - public StructureSelectPreviousAction(ResourceBundle bundle, ITextEditor editor, - SelectionHistory history) { + public StructureSelectPreviousAction(ResourceBundle bundle, ITextEditor editor, SelectionHistory history) { super(bundle, PREFIX, editor, history); } - + @Override public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) { - ISourceRange newSourceRange = expandToPrevious(ast, current); if (newSourceRange == null) { newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current); @@ -45,20 +43,19 @@ public class StructureSelectPreviousAction extends StructureSelectionAction { } private ISourceRange expandToPrevious(IASTTranslationUnit ast, SourceRange current) { - - IASTNode enclosingNode = ast.getNodeSelector(null).findEnclosingNode(current.getStartPos(), - current.getLength()); + IASTNodeSelector selector = ast.getNodeSelector(null); + IASTNode enclosingNode = selector.findEnclosingNode(current.getStartPos(), current.getLength()); if (samePosition(enclosingNode, current)) { enclosingNode = enclosingNode.getParent(); } if (enclosingNode == null) { return null; } - - // find the first child of enclosingNode containing selection end - + + // Find the first child of enclosingNode containing selection end. + int selectionStart = current.getStartPos(); - + int firstSelectedChildIndex = -1; IASTNode[] children = enclosingNode.getChildren(); for (int i = 0; i < children.length; i++) { @@ -68,13 +65,12 @@ public class StructureSelectPreviousAction extends StructureSelectionAction { break; } } - - if (firstSelectedChildIndex != -1 && firstSelectedChildIndex-1 >= 0) { - IASTNode prevNode = children[firstSelectedChildIndex-1]; + + if (firstSelectedChildIndex > 0) { + IASTNode prevNode = children[firstSelectedChildIndex - 1]; int endingOffset = current.getStartPos() + current.getLength(); return new SourceRange(prevNode.getFileLocation().getNodeOffset(), endingOffset - prevNode.getFileLocation().getNodeOffset()); } return null; } - }