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

@ -20,44 +20,12 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPASTTemplateDeclaration extends IASTDeclaration { public interface ICPPASTTemplateDeclaration extends IASTDeclaration {
/** /**
* Is the export keyword used? * <code>OWNED_DECLARATION</code> is the subdeclaration that we maintain grammatically.
*
* @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( public static final ASTNodeProperty OWNED_DECLARATION = new ASTNodeProperty(
"ICPPASTTemplateDeclaration.OWNED_DECLARATION - Subdeclaration maintained grammatically"); //$NON-NLS-1$ "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. * <code>PARAMETER</code> is used for template parameters.
*/ */
@ -65,29 +33,48 @@ public interface ICPPASTTemplateDeclaration extends IASTDeclaration {
"ICPPASTTemplateDeclaration.PARAMETER - Template Parameter"); //$NON-NLS-1$ "ICPPASTTemplateDeclaration.PARAMETER - Template Parameter"); //$NON-NLS-1$
/** /**
* Get template parameters. * 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.
* *
* @return <code>ICPPASTTemplateParameter[]</code> * @param declaration the declaration to set
*/
public void setDeclaration(IASTDeclaration declaration);
/**
* Returns the template parameters.
*/ */
public ICPPASTTemplateParameter[] getTemplateParameters(); 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 * @since 5.2
*/ */
public void addTemplateParameter(ICPPASTTemplateParameter parm); public void addTemplateParameter(ICPPASTTemplateParameter paramm);
/** /**
* @deprecated Use addTemplateParameter. * @deprecated Use addTemplateParameter.
*/ */
@Deprecated @Deprecated
public void addTemplateParamter(ICPPASTTemplateParameter parm); public void addTemplateParamter(ICPPASTTemplateParameter paramm);
/** /**
* get the template scope representing this declaration in the logical tree * Returns the template scope representing this declaration in the logical tree.
* @return <code>ICPPTemplateScope</code>
*/ */
public ICPPTemplateScope getScope(); public ICPPTemplateScope getScope();

View file

@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
* and the names of the nested declaration. * and the names of the nested declaration.
*/ */
public interface ICPPASTInternalTemplateDeclaration extends ICPPASTTemplateDeclaration { public interface ICPPASTInternalTemplateDeclaration extends ICPPASTTemplateDeclaration {
/** /**
* Returns whether this template declaration is associated with the last name of * Returns whether this template declaration is associated with the last name of
* the possibly qualified name of the enclosing declaration. If this template declaration * 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.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.dom.ast.IASTNode; 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.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ISourceRange; 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; import org.eclipse.cdt.internal.ui.editor.SelectionHistory;
public class StructureSelectNextAction extends StructureSelectionAction { public class StructureSelectNextAction extends StructureSelectionAction {
public static final String PREFIX = "StructureSelectNext."; //$NON-NLS-1$ public static final String PREFIX = "StructureSelectNext."; //$NON-NLS-1$
public StructureSelectNextAction(ResourceBundle bundle, ITextEditor editor, public StructureSelectNextAction(ResourceBundle bundle, ITextEditor editor, SelectionHistory history) {
SelectionHistory history) {
super(bundle, PREFIX, editor, history); super(bundle, PREFIX, editor, history);
} }
@Override @Override
public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) { public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) {
ISourceRange newSourceRange = expandToNext(ast, current); ISourceRange newSourceRange = expandToNext(ast, current);
if (newSourceRange == null) { if (newSourceRange == null) {
newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current); newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current);
@ -45,9 +43,8 @@ public class StructureSelectNextAction extends StructureSelectionAction {
} }
private ISourceRange expandToNext(IASTTranslationUnit ast, SourceRange current) { private ISourceRange expandToNext(IASTTranslationUnit ast, SourceRange current) {
IASTNodeSelector selector = ast.getNodeSelector(null);
IASTNode enclosingNode = ast.getNodeSelector(null).findEnclosingNode(current.getStartPos(), IASTNode enclosingNode = selector.findEnclosingNode(current.getStartPos(), current.getLength());
current.getLength());
if (samePosition(enclosingNode, current)) { if (samePosition(enclosingNode, current)) {
enclosingNode = enclosingNode.getParent(); enclosingNode = enclosingNode.getParent();
} }
@ -55,9 +52,9 @@ public class StructureSelectNextAction extends StructureSelectionAction {
return null; return null;
} }
// find the last child of enclosingNode containing selection end // Find the last child of enclosingNode containing selection end.
int selectionEnd = current.getStartPos()+current.getLength(); int selectionEnd = current.getStartPos() + current.getLength();
int lastSelectedChildIndex = -1; int lastSelectedChildIndex = -1;
IASTNode[] children = enclosingNode.getChildren(); IASTNode[] children = enclosingNode.getChildren();
@ -69,12 +66,11 @@ public class StructureSelectNextAction extends StructureSelectionAction {
} }
} }
if (lastSelectedChildIndex != -1 && lastSelectedChildIndex+1 < children.length) { if (lastSelectedChildIndex >= 0 && lastSelectedChildIndex + 1 < children.length) {
IASTNode nextNode = children[lastSelectedChildIndex+1]; IASTNode nextNode = children[lastSelectedChildIndex + 1];
int endingOffset = nextNode.getFileLocation().getNodeOffset()+nextNode.getFileLocation().getNodeLength(); int endingOffset = nextNode.getFileLocation().getNodeOffset() + nextNode.getFileLocation().getNodeLength();
return new SourceRange(current.getStartPos(),endingOffset-current.getStartPos()); return new SourceRange(current.getStartPos(), endingOffset - current.getStartPos());
} }
return null; return null;
} }
} }

View file

@ -15,6 +15,7 @@ import java.util.ResourceBundle;
import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.dom.ast.IASTNode; 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.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ISourceRange; 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; import org.eclipse.cdt.internal.ui.editor.SelectionHistory;
public class StructureSelectPreviousAction extends StructureSelectionAction { public class StructureSelectPreviousAction extends StructureSelectionAction {
public static final String PREFIX = "StructureSelectPrevious."; //$NON-NLS-1$ public static final String PREFIX = "StructureSelectPrevious."; //$NON-NLS-1$
public StructureSelectPreviousAction(ResourceBundle bundle, ITextEditor editor, public StructureSelectPreviousAction(ResourceBundle bundle, ITextEditor editor, SelectionHistory history) {
SelectionHistory history) {
super(bundle, PREFIX, editor, history); super(bundle, PREFIX, editor, history);
} }
@Override @Override
public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) { public ISourceRange doExpand(IASTTranslationUnit ast, SourceRange current) {
ISourceRange newSourceRange = expandToPrevious(ast, current); ISourceRange newSourceRange = expandToPrevious(ast, current);
if (newSourceRange == null) { if (newSourceRange == null) {
newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current); newSourceRange = StructureSelectEnclosingAction.expandToEnclosing(ast, current);
@ -45,9 +43,8 @@ public class StructureSelectPreviousAction extends StructureSelectionAction {
} }
private ISourceRange expandToPrevious(IASTTranslationUnit ast, SourceRange current) { private ISourceRange expandToPrevious(IASTTranslationUnit ast, SourceRange current) {
IASTNodeSelector selector = ast.getNodeSelector(null);
IASTNode enclosingNode = ast.getNodeSelector(null).findEnclosingNode(current.getStartPos(), IASTNode enclosingNode = selector.findEnclosingNode(current.getStartPos(), current.getLength());
current.getLength());
if (samePosition(enclosingNode, current)) { if (samePosition(enclosingNode, current)) {
enclosingNode = enclosingNode.getParent(); enclosingNode = enclosingNode.getParent();
} }
@ -55,7 +52,7 @@ public class StructureSelectPreviousAction extends StructureSelectionAction {
return 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 selectionStart = current.getStartPos();
@ -69,12 +66,11 @@ public class StructureSelectPreviousAction extends StructureSelectionAction {
} }
} }
if (firstSelectedChildIndex != -1 && firstSelectedChildIndex-1 >= 0) { if (firstSelectedChildIndex > 0) {
IASTNode prevNode = children[firstSelectedChildIndex-1]; IASTNode prevNode = children[firstSelectedChildIndex - 1];
int endingOffset = current.getStartPos() + current.getLength(); int endingOffset = current.getStartPos() + current.getLength();
return new SourceRange(prevNode.getFileLocation().getNodeOffset(), endingOffset - prevNode.getFileLocation().getNodeOffset()); return new SourceRange(prevNode.getFileLocation().getNodeOffset(), endingOffset - prevNode.getFileLocation().getNodeOffset());
} }
return null; return null;
} }
} }