1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 21:35:40 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-02-06 20:36:09 -08:00
parent 8a73a23e9d
commit 38803901ec
15 changed files with 80 additions and 92 deletions

View file

@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
/**
* This interface represents a binary expression.
*
@ -36,15 +35,14 @@ public interface IASTBinaryExpression extends IASTExpression {
"IASTBinaryExpression.OPERAND_TWO - IASTExpression for RHS"); //$NON-NLS-1$
/**
* Set the operator.
* Sets the operator.
*
* @param op
* Value to set.
* @param op value to set.
*/
public void setOperator(int op);
/**
* Get the operator.
* Returns the operator.
*
* @return int value as operator
*/
@ -244,7 +242,6 @@ public interface IASTBinaryExpression extends IASTExpression {
* @param expression
* <code>IASTExpression</code> value.
*/
public void setOperand1(IASTExpression expression);
/**

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn (Wind River Systems) - Initial API and implementation
* Markus Schorn (Wind River Systems) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@ -25,7 +25,7 @@ public interface IASTBinaryTypeIdExpression extends IASTExpression {
public static enum Operator {__is_base_of}
/**
* Get the operator for the expression.
* Returns the operator for the expression.
*/
public Operator getOperator();
@ -40,22 +40,23 @@ public interface IASTBinaryTypeIdExpression extends IASTExpression {
public IASTTypeId getOperand2();
/**
* Set the operator for the expression.
* Sets the operator for the expression.
*/
public void setOperator(Operator value);
/**
* Set the first operand.
* Sets the first operand.
*/
public void setOperand1(IASTTypeId typeId);
/**
* Set the second operand.
* Sets the second operand.
*/
public void setOperand2(IASTTypeId typeId);
@Override
public IASTBinaryTypeIdExpression copy();
@Override
public IASTBinaryTypeIdExpression copy(CopyStyle style);
}

View file

@ -11,7 +11,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
/**
* This is the root class of expressions.
*
@ -28,7 +27,7 @@ public interface IASTExpression extends IASTInitializerClause {
*/
LVALUE,
/**
* Expiring value as introduced by c++ 0x.
* Expiring value as introduced by c++11.
*/
XVALUE,
/**
@ -42,6 +41,7 @@ public interface IASTExpression extends IASTInitializerClause {
public boolean isRValue() {
return this != LVALUE;
}
/**
* A generalized lvalue is either an lvalue or an xvalue.
*/
@ -53,7 +53,7 @@ public interface IASTExpression extends IASTInitializerClause {
/**
* Empty expression array.
*/
public static final IASTExpression[] EMPTY_EXPRESSION_ARRAY = new IASTExpression[0];
public static final IASTExpression[] EMPTY_EXPRESSION_ARRAY = {};
public IType getExpressionType();

View file

@ -17,7 +17,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTUnaryExpression extends IASTExpression {
/**
* Prefix increment.
* <code>op_prefixIncr</code> ++exp
@ -32,7 +31,7 @@ public interface IASTUnaryExpression extends IASTExpression {
/**
* Operator plus.
* <code>op_plus</code> ==> + exp
* <code>op_plus</code> ==> +exp
*/
public static final int op_plus = 2;

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Mike Kucera (IBM)
* Sergey Prigogin (Google)
* John Camelon (IBM) - Initial API and implementation
* Mike Kucera (IBM)
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
@ -22,7 +22,6 @@ import org.eclipse.cdt.core.dom.ast.IASTImplicitNameOwner;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPASTBinaryExpression extends IASTBinaryExpression, IASTImplicitNameOwner {
/**
* <code>op_pmdot</code> pointer-to-member field dereference.
*/

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2011 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2012 Wind River Systems, Inc. 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
@ -260,9 +260,10 @@ public final class ASTRewrite {
}
/**
* Returns comments for the given node.
*
* @param node the node
* @param pos the position
* @param pos the position of the comments
* @return All comments assigned to the node at this position
* @since 5.3
*/

View file

@ -20,7 +20,6 @@ package org.eclipse.cdt.core.dom.rewrite;
* @noextend This interface is not intended to be extended by clients.
*/
public interface ITrackedNodePosition {
/**
* Returns the original or modified start position of the tracked node depending if called before
* or after the rewrite is applied. <code>-1</code> is returned for removed nodes.

View file

@ -259,7 +259,7 @@ public abstract class ASTNode implements IASTNode {
ASTNode astNode= (ASTNode) node;
final int offset = getOffset();
final int nodeOffset= astNode.getOffset();
return offset <= nodeOffset && nodeOffset+astNode.length <= offset+length;
return offset <= nodeOffset && nodeOffset + astNode.length <= offset + length;
}
return false;
}
@ -267,7 +267,7 @@ public abstract class ASTNode implements IASTNode {
@Override
public IToken getSyntax() throws ExpansionOverlapsBoundaryException {
final int offset = getOffset();
return getSyntax(offset, offset+length, 0);
return getSyntax(offset, offset + length, 0);
}
@Override
@ -279,7 +279,7 @@ public abstract class ASTNode implements IASTNode {
@Override
public IToken getTrailingSyntax() throws ExpansionOverlapsBoundaryException {
int right= getBoundary(1);
return getSyntax(getOffset()+length, right, 1);
return getSyntax(getOffset() + length, right, 1);
}
/**
@ -296,15 +296,14 @@ public abstract class ASTNode implements IASTNode {
ASTNode astNode= (ASTNode) sib;
int offset= astNode.getOffset();
if (direction < 0) {
offset+= astNode.getLength();
offset += astNode.getLength();
}
return offset;
}
// no parent
// No parent.
throw new UnsupportedOperationException();
}
private IToken getSyntax(int fromSequenceNumber, int nextSequenceNumber, int direction) throws ExpansionOverlapsBoundaryException {
final IASTTranslationUnit tu= getTranslationUnit();
if (!(tu instanceof ASTNode))
@ -315,7 +314,7 @@ public abstract class ASTNode implements IASTNode {
throw new UnsupportedOperationException();
int endSequenceNumber= lr.convertToSequenceEndNumber(nextSequenceNumber);
IASTFileLocation total= lr.getMappedFileLocation(fromSequenceNumber, endSequenceNumber-fromSequenceNumber);
IASTFileLocation total= lr.getMappedFileLocation(fromSequenceNumber, endSequenceNumber - fromSequenceNumber);
IASTFileLocation myfloc= getFileLocation();
if (total == null || myfloc == null)
throw new UnsupportedOperationException();
@ -324,13 +323,13 @@ public abstract class ASTNode implements IASTNode {
throw new ExpansionOverlapsBoundaryException();
if (fromSequenceNumber > 0) {
IASTFileLocation fl= lr.getMappedFileLocation(fromSequenceNumber-1, endSequenceNumber-fromSequenceNumber+1);
IASTFileLocation fl= lr.getMappedFileLocation(fromSequenceNumber-1, endSequenceNumber - fromSequenceNumber + 1);
if (fl.getFileName().equals(total.getFileName()) && fl.getNodeOffset() == total.getNodeOffset())
throw new ExpansionOverlapsBoundaryException();
}
if (endSequenceNumber < ((ASTNode) tu).getOffset() + ((ASTNode) tu).getLength()) {
IASTFileLocation fl= lr.getMappedFileLocation(fromSequenceNumber, nextSequenceNumber-fromSequenceNumber+1);
IASTFileLocation fl= lr.getMappedFileLocation(fromSequenceNumber, nextSequenceNumber - fromSequenceNumber + 1);
if (fl.getFileName().equals(total.getFileName()) && fl.getNodeLength() == total.getNodeLength())
throw new ExpansionOverlapsBoundaryException();
}
@ -345,7 +344,7 @@ public abstract class ASTNode implements IASTNode {
try {
Token result= null;
Token last= null;
for (;;) {
while (true) {
Token t= lex.nextToken();
switch (t.getType()) {
case IToken.tEND_OF_INPUT:
@ -366,12 +365,12 @@ public abstract class ASTNode implements IASTNode {
}
}
} catch (OffsetLimitReachedException e) {
// does not happen without using content assist limit
// Does not happen without using content assist limit.
}
return null;
}
protected void setCopyLocation(IASTNode originalNode) {
locations = new IASTNodeLocation[] {new ASTCopyLocation(originalNode)};
locations = new IASTNodeLocation[] { new ASTCopyLocation(originalNode) };
}
}

View file

@ -51,8 +51,8 @@ public class CPPASTLiteralExpression extends ASTNode implements ICPPASTLiteralEx
@Override
public CPPASTLiteralExpression copy(CopyStyle style) {
CPPASTLiteralExpression copy = new CPPASTLiteralExpression(kind, value == null ? null
: value.clone());
CPPASTLiteralExpression copy = new CPPASTLiteralExpression(kind,
value == null ? null : value.clone());
copy.setOffsetAndLength(this);
if (style == CopyStyle.withLocations) {
copy.setCopyLocation(this);

View file

@ -59,7 +59,7 @@ abstract class ASTPreprocessorNode extends ASTNode {
setParent(parent);
setPropertyInParent(property);
setOffset(startNumber);
setLength(endNumber-startNumber);
setLength(endNumber - startNumber);
}
protected char[] getSource(int offset, int length) {
@ -597,9 +597,9 @@ class ASTFunctionStyleMacroDefinition extends ASTMacroDefinition implements IAST
}
}
class ASTUndef extends ASTPreprocessorNode implements IASTPreprocessorUndefStatement {
private final ASTPreprocessorName fName;
public ASTUndef(IASTTranslationUnit parent, char[] name, int startNumber, int nameNumber, int nameEndNumber, IBinding binding, boolean isActive) {
super(parent, IASTTranslationUnit.PREPROCESSOR_STATEMENT, startNumber, nameEndNumber);
fName= new ASTPreprocessorName(this, IASTPreprocessorStatement.MACRO_NAME, nameNumber, nameEndNumber, name, binding);
@ -686,7 +686,7 @@ class ASTFileLocation implements IASTFileLocation {
@Override
public int getEndingLineNumber() {
int end= fLength > 0 ? fOffset+fLength-1 : fOffset;
int end= fLength > 0 ? fOffset + fLength - 1 : fOffset;
return fLocationCtx.getLineNumber(end);
}
@ -701,7 +701,7 @@ class ASTFileLocation implements IASTFileLocation {
@Override
public String toString() {
return getFileName() + "[" + fOffset + "," + (fOffset+fLength) + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
return getFileName() + "[" + fOffset + "," + (fOffset + fLength) + "]"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
}
public int getSequenceNumber() {
@ -709,7 +709,7 @@ class ASTFileLocation implements IASTFileLocation {
}
public int getSequenceEndNumber() {
return fLocationCtx.getSequenceNumberForOffset(fOffset+fLength, true);
return fLocationCtx.getSequenceNumberForOffset(fOffset + fLength, true);
}
public LocationCtxFile getLocationContext() {
@ -723,7 +723,6 @@ class ASTFileLocation implements IASTFileLocation {
}
class ASTMacroExpansion extends ASTPreprocessorNode implements IASTPreprocessorMacroExpansion {
private LocationCtxMacroExpansion fContext;
public ASTMacroExpansion(IASTNode parent, int startNumber, int endNumber) {
@ -765,7 +764,6 @@ class ASTMacroExpansion extends ASTPreprocessorNode implements IASTPreprocessorM
@SuppressWarnings("deprecation")
class ASTMacroExpansionLocation implements IASTMacroExpansionLocation, org.eclipse.cdt.core.dom.ast.IASTMacroExpansion {
private LocationCtxMacroExpansion fContext;
private int fOffset;
private int fLength;
@ -817,7 +815,7 @@ class ASTMacroExpansionLocation implements IASTMacroExpansionLocation, org.eclip
@Override
public String toString() {
return fContext.getMacroDefinition().getName().toString() + "[" + fOffset + "," + (fOffset+fLength) + ")"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
return fContext.getMacroDefinition().getName().toString() + "[" + fOffset + "," + (fOffset+fLength) + "]"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
}
public IASTImageLocation getImageLocation() {
@ -872,7 +870,6 @@ class ASTFileLocationForBuiltins implements IASTFileLocation {
}
}
class ASTImageLocation extends ASTFileLocationForBuiltins implements IASTImageLocation {
private final int fKind;

View file

@ -34,7 +34,7 @@ class LocationCtxMacroExpansion extends LocationCtx {
fLength= length;
fLocationInfos= imageLocations;
fExpansionName= expansionName;
if (expansionName.getParent() instanceof ASTMacroExpansion == false) {
if (!(expansionName.getParent() instanceof ASTMacroExpansion)) {
throw new IllegalArgumentException(expansionName.toString() + " is not a macro expansion name"); //$NON-NLS-1$
}
}

View file

@ -58,7 +58,7 @@ import org.eclipse.cdt.internal.ui.refactoring.NameInformation;
* @author Mirko Stocker
*/
public class ExtractExpression extends ExtractedFunctionConstructionHelper {
final static char[] ZERO= { '0' };
private final static char[] ZERO= { '0' };
@Override
public void constructMethodBody(IASTCompoundStatement compound, List<IASTNode> list,
@ -74,12 +74,12 @@ public class ExtractExpression extends ExtractedFunctionConstructionHelper {
private IASTExpression getExpression(List<IASTNode> list) {
if (list.size() > 1) {
CPPASTBinaryExpression bExp = new CPPASTBinaryExpression();
bExp.setParent(list.get(0).getParent());
bExp.setOperand1((IASTExpression) list.get(0).copy(CopyStyle.withLocations));
bExp.setOperator(((IASTBinaryExpression) list.get(1).getParent()).getOperator());
bExp.setOperand2(getExpression(list.subList(1, list.size())));
return bExp;
CPPASTBinaryExpression expression = new CPPASTBinaryExpression();
expression.setParent(list.get(0).getParent());
expression.setOperand1((IASTExpression) list.get(0).copy(CopyStyle.withLocations));
expression.setOperator(((IASTBinaryExpression) list.get(1).getParent()).getOperator());
expression.setOperand2(getExpression(list.subList(1, list.size())));
return expression;
} else {
return (IASTExpression) list.get(0).copy(CopyStyle.withLocations);
}

View file

@ -34,9 +34,9 @@ import org.eclipse.cdt.internal.ui.refactoring.utils.ASTHelper;
*/
public class ExtractStatement extends ExtractedFunctionConstructionHelper {
@Override
public void constructMethodBody(IASTCompoundStatement compound, List<IASTNode> list,
public void constructMethodBody(IASTCompoundStatement compound, List<IASTNode> nodes,
ASTRewrite rewrite, TextEditGroup group) {
for (IASTNode node : list) {
for (IASTNode node : nodes) {
rewrite.insertBefore(compound, null, node, group);
}
}
@ -48,8 +48,8 @@ public class ExtractStatement extends ExtractedFunctionConstructionHelper {
IASTNode decl = ASTHelper.getDeclarationForNode(returnVariable.getDeclarationName());
return ASTHelper.getDeclarationSpecifier(decl).copy(CopyStyle.withLocations);
}
IASTDeclSpecifier declSpec = new CPPASTSimpleDeclSpecifier();
((IASTSimpleDeclSpecifier) declSpec).setType(IASTSimpleDeclSpecifier.t_void);
IASTSimpleDeclSpecifier declSpec = new CPPASTSimpleDeclSpecifier();
declSpec.setType(IASTSimpleDeclSpecifier.t_void);
return declSpec.copy(CopyStyle.withLocations);
}

View file

@ -57,10 +57,10 @@ import org.eclipse.cdt.internal.ui.refactoring.Container;
import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector;
public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefactoringStrategy {
private IASTTranslationUnit impl_unit;
private IASTTranslationUnit implUnit;
private ToggleRefactoringContext context;
private TextEditGroup infoText;
private ASTLiteralNode includenode;
private ASTLiteralNode includeNode;
public ToggleFromInHeaderToImplementationStrategy(final ToggleRefactoringContext context) {
this.infoText = new TextEditGroup(Messages.EditGroupName);
@ -80,9 +80,9 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact
replaceDefinitionWithDeclaration(collector);
}
ASTRewrite implRewrite = collector.rewriterForTranslationUnit(impl_unit);
if (includenode != null) {
implRewrite.insertBefore(impl_unit, null, includenode, infoText);
ASTRewrite implRewrite = collector.rewriterForTranslationUnit(implUnit);
if (includeNode != null) {
implRewrite.insertBefore(implUnit, null, includeNode, infoText);
}
IASTNode insertionParent = null;
@ -93,11 +93,11 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact
insertionParent = searchNamespaceInImplementation(parent.getName());
if (insertionParent == null) {
insertionParent = createNamespace(parent);
implRewrite = implRewrite.insertBefore(impl_unit.getTranslationUnit(),
implRewrite = implRewrite.insertBefore(implUnit.getTranslationUnit(),
null, insertionParent, infoText);
}
} else {
insertionParent = impl_unit.getTranslationUnit();
insertionParent = implUnit.getTranslationUnit();
}
newDefinition.setParent(insertionParent);
@ -241,13 +241,13 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact
}
private boolean newFileCheck() {
impl_unit = context.getTUForSiblingFile();
if (impl_unit == null) {
implUnit = context.getTUForSiblingFile();
if (implUnit == null) {
ToggleFileCreator filecreator = new ToggleFileCreator(context, ".cpp"); //$NON-NLS-1$
if (filecreator.askUserForFileCreation(context)) {
filecreator.createNewFile();
impl_unit = filecreator.loadTranslationUnit();
includenode = new ASTLiteralNode(filecreator.getIncludeStatement());
implUnit = filecreator.loadTranslationUnit();
includeNode = new ASTLiteralNode(filecreator.getIncludeStatement());
return true;
} else {
return false;
@ -342,7 +342,7 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact
private CPPASTNamespaceDefinition createNamespace(ICPPASTNamespaceDefinition parent_namespace) {
CPPASTNamespaceDefinition insertionParent = new CPPASTNamespaceDefinition(
parent_namespace.getName().copy(CopyStyle.withLocations));
insertionParent.setParent(impl_unit);
insertionParent.setParent(implUnit);
return insertionParent;
}
@ -354,7 +354,7 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact
private IASTNode searchNamespaceInImplementation(final IASTName name) {
final Container<IASTNode> result = new Container<IASTNode>();
this.impl_unit.accept(new ASTVisitor() {
this.implUnit.accept(new ASTVisitor() {
{
shouldVisitNamespaces = true;
}

View file

@ -32,12 +32,11 @@ import org.eclipse.cdt.ui.CUIPlugin;
* @since 5.0
*/
public final class ProjectTemplateStore {
private static final String KEY= "org.eclipse.cdt.ui.text.custom_code_templates"; //$NON-NLS-1$
private final TemplateStore fInstanceStore;
private final TemplateStore fProjectStore;
public ProjectTemplateStore(IProject project) {
fInstanceStore= CUIPlugin.getDefault().getCodeTemplateStore();
if (project == null) {
@ -57,21 +56,20 @@ public final class ProjectTemplateStore {
internalAdd(data);
}
}
@Override
public void save() throws IOException {
StringWriter output= new StringWriter();
TemplateReaderWriter writer= new TemplateReaderWriter();
writer.save(getTemplateData(false), output);
projectSettings.setValue(KEY, output.toString());
projectSettings.save();
}
};
}
}
public static boolean hasProjectSpecificTempates(IProject project) {
String pref= new ProjectScope(project).getNode(CUIPlugin.PLUGIN_ID).get(KEY, null);
if (pref != null && pref.trim().length() > 0) {
@ -87,29 +85,28 @@ public final class ProjectTemplateStore {
}
return false;
}
public TemplatePersistenceData[] getTemplateData() {
if (fProjectStore != null) {
return fProjectStore.getTemplateData(true);
}
return fInstanceStore.getTemplateData(true);
}
public Template findTemplateById(String id) {
Template template= null;
if (fProjectStore != null)
template= fProjectStore.findTemplateById(id);
if (template == null)
template= fInstanceStore.findTemplateById(id);
return template;
}
public void load() throws IOException {
if (fProjectStore != null) {
fProjectStore.load();
Set<String> datas= new HashSet<String>();
TemplatePersistenceData[] data= fProjectStore.getTemplateData(false);
for (TemplatePersistenceData element : data) {
@ -119,7 +116,7 @@ public final class ProjectTemplateStore {
}
datas.add(id);
}
data= fInstanceStore.getTemplateData(false);
for (TemplatePersistenceData orig : data) {
String origId= orig.getId();
@ -134,22 +131,21 @@ public final class ProjectTemplateStore {
}
}
}
public boolean isProjectSpecific(String id) {
if (id == null) {
return false;
}
if (fProjectStore == null)
return false;
return fProjectStore.findTemplateById(id) != null;
}
public void setProjectSpecific(String id, boolean projectSpecific) {
Assert.isNotNull(fProjectStore);
TemplatePersistenceData data= fProjectStore.getTemplateData(id);
if (data == null) {
return; // does not exist
@ -164,7 +160,7 @@ public final class ProjectTemplateStore {
fProjectStore.restoreDefaults();
}
}
public void save() throws IOException {
if (fProjectStore == null) {
fInstanceStore.save();
@ -172,7 +168,7 @@ public final class ProjectTemplateStore {
fProjectStore.save();
}
}
public void revertChanges() throws IOException {
if (fProjectStore != null) {
// nothing to do