Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2015-01-06 02:42:28 +0000
committerSergey Prigogin2015-01-06 02:58:03 +0000
commit5d6e09d1cb940b23aef241d5eae8aa7bafa64164 (patch)
treedcb006d499892165f9e88a51dd82b8df370b9e9c
parent52f60a00baf07acb9565695cde26382c580747fb (diff)
downloadorg.eclipse.cdt-5d6e09d1cb940b23aef241d5eae8aa7bafa64164.tar.gz
org.eclipse.cdt-5d6e09d1cb940b23aef241d5eae8aa7bafa64164.tar.xz
org.eclipse.cdt-5d6e09d1cb940b23aef241d5eae8aa7bafa64164.zip
Cosmetics.
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTTemplateDeclaration.java57
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPASTInternalTemplateDeclaration.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectNextAction.java32
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/StructureSelectPreviousAction.java28
4 files changed, 49 insertions, 71 deletions
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 7ef6c4e666..17011824fb 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,74 +20,61 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTTemplateDeclaration extends IASTDeclaration {
+ /**
+ * <code>OWNED_DECLARATION</code> is the subdeclaration that we maintain grammatically.
+ */
+ public static final ASTNodeProperty OWNED_DECLARATION = new ASTNodeProperty(
+ "ICPPASTTemplateDeclaration.OWNED_DECLARATION - Subdeclaration maintained grammatically"); //$NON-NLS-1$
+
+ /**
+ * <code>PARAMETER</code> is used for template parameters.
+ */
+ public static final ASTNodeProperty PARAMETER = new ASTNodeProperty(
+ "ICPPASTTemplateDeclaration.PARAMETER - Template Parameter"); //$NON-NLS-1$
/**
* Is the export keyword used?
- *
- * @return boolean
*/
public boolean isExported();
/**
* Should the export keyword be used?
- *
- * @param value
- * boolean
*/
public void setExported(boolean value);
/**
- * <code>OWNED_DECLARATION</code> 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 <code>IASTDeclaration</code>
+ * Returns the template declaration.
*/
public IASTDeclaration getDeclaration();
/**
- * Set the template declaration.
- *
- * @param declaration
- * <code>IASTDeclaration</code>
+ * Sets the template declaration.
+ *
+ * @param declaration the declaration to set
*/
public void setDeclaration(IASTDeclaration declaration);
/**
- * <code>PARAMETER</code> is used for template parameters.
- */
- public static final ASTNodeProperty PARAMETER = new ASTNodeProperty(
- "ICPPASTTemplateDeclaration.PARAMETER - Template Parameter"); //$NON-NLS-1$
-
- /**
- * Get template parameters.
- *
- * @return <code>ICPPASTTemplateParameter[]</code>
+ * Returns the template parameters.
*/
public ICPPASTTemplateParameter[] getTemplateParameters();
/**
- * Add a template parameter.
+ * Adds a template parameter.
*
- * @param parm <code>ICPPASTTemplateParameter</code>
+ * @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 <code>ICPPTemplateScope</code>
+ * 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 0b82f64d81..d3892f2716 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 6c9764153b..8c4136ff08 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 ecf7eacb72..09e7542052 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;
}
-
}

Back to the top