1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2015-01-05 18:42:28 -08:00
parent 52f60a00ba
commit 5d6e09d1cb
4 changed files with 57 additions and 79 deletions

View file

@ -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);
/**
* <code>OWNED_DECLARATION</code> is the subdeclaration that we maintain
* grammatically.
* <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>
*/
public IASTDeclaration getDeclaration();
/**
* Set the template declaration.
*
* @param declaration
* <code>IASTDeclaration</code>
*/
public void setDeclaration(IASTDeclaration declaration);
/**
* <code>PARAMETER</code> 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 <code>ICPPASTTemplateParameter[]</code>
* 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 <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();

View file

@ -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

View file

@ -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;
}
}

View file

@ -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;
}
}