From 470a0074397087506e6dd8db6ab9ca5cce6f87ff Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 20 Apr 2014 17:04:10 -0700 Subject: [PATCH] Fixed compiler warnings. --- .../cpp/CPPASTAmbiguousSimpleDeclaration.java | 18 ++++++++++-------- .../dom/parser/cpp/CPPASTDeleteExpression.java | 15 +++++++-------- .../dom/parser/cpp/CPPASTFieldDeclarator.java | 18 ++++++------------ .../core/dom/parser/cpp/CPPImplicitMethod.java | 15 ++++++++------- 4 files changed, 31 insertions(+), 35 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java index 0fbd9ce152f..783b8f3b6d6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTAmbiguousSimpleDeclaration.java @@ -31,10 +31,11 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; /** * Handles ambiguities for simple declarations. - *
+ *
  * class C {
- *    C(D);  // if D a type we have a constructor, otherwise this declares the field D.
+ *    C(D);  // If D a type we have a constructor, otherwise this declares the field D.
  * };
+ * 
*/ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implements IASTAmbiguousSimpleDeclaration { private IASTSimpleDeclaration fSimpleDecl; @@ -49,7 +50,7 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement @Override protected void beforeResolution() { - // populate containing scope, so that it will not be affected by the alternative branches. + // Populate containing scope, so that it will not be affected by the alternative branches. IScope scope= CPPVisitor.getContainingScope(this); if (scope instanceof IASTInternalScope) { ((IASTInternalScope) scope).populateCache(); @@ -96,17 +97,17 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement final IASTAmbiguityParent owner= (IASTAmbiguityParent) getParent(); IASTNode nodeToReplace= this; - // handle nested ambiguities first + // Handle nested ambiguities first. owner.replace(nodeToReplace, fSimpleDecl); IASTDeclarator dtor= fSimpleDecl.getDeclarators()[0]; dtor.accept(resolver); - // find nested names + // Find nested names. final NameCollector nameCollector= new NameCollector(); dtor.accept(nameCollector); final IASTName[] names= nameCollector.getNames(); - // resolve names + // Resolve names. boolean hasIssue= false; for (IASTName name : names) { try { @@ -121,13 +122,13 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement } } if (hasIssue) { - // use the alternate version + // Use the alternate version. final IASTAmbiguityParent parent = (IASTAmbiguityParent) fSimpleDecl; parent.replace(fSimpleDecl.getDeclSpecifier(), fAltDeclSpec); parent.replace(dtor, fAltDtor); } - // resolve further nested ambiguities + // Resolve further nested ambiguities. fSimpleDecl.accept(resolver); return fSimpleDecl; } @@ -138,6 +139,7 @@ public class CPPASTAmbiguousSimpleDeclaration extends ASTAmbiguousNode implement } @Override + @Deprecated public void addAttribute(IASTAttribute attribute) { fSimpleDecl.addAttribute(attribute); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeleteExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeleteExpression.java index 40a17c2b09d..f4804bc9aed 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeleteExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTDeleteExpression.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.core.dom.ast.ASTVisitor; -import org.eclipse.cdt.core.dom.ast.IASTDeclaration; import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTImplicitName; import org.eclipse.cdt.core.dom.ast.IASTNode; @@ -38,7 +37,7 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr private boolean isGlobal; private boolean isVectored; - private IASTImplicitName[] implicitNames = null; + private IASTImplicitName[] implicitNames; public CPPASTDeleteExpression() { } @@ -58,8 +57,8 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr @Override public CPPASTDeleteExpression copy(CopyStyle style) { - CPPASTDeleteExpression copy = new CPPASTDeleteExpression(operand == null ? null - : operand.copy(style)); + CPPASTDeleteExpression copy = + new CPPASTDeleteExpression(operand == null ? null : operand.copy(style)); copy.isGlobal = isGlobal; copy.isVectored = isVectored; return copy(copy, style); @@ -131,10 +130,11 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr } } - if (names.isEmpty()) + if (names.isEmpty()) { implicitNames = IASTImplicitName.EMPTY_NAME_ARRAY; - else + } else { implicitNames = names.toArray(new IASTImplicitName[names.size()]); + } } return implicitNames; @@ -163,7 +163,7 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr if (action.shouldVisitExpressions) { switch (action.leave(this)) { case ASTVisitor.PROCESS_ABORT: return false; - case ASTVisitor.PROCESS_SKIP: return true; + case ASTVisitor.PROCESS_SKIP: return true; default: break; } } @@ -198,5 +198,4 @@ public class CPPASTDeleteExpression extends ASTNode implements ICPPASTDeleteExpr operand = (IASTExpression) other; } } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java index 30f3af61577..8139e96a4e1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFieldDeclarator.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -16,14 +16,11 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldDeclarator; -import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent; /** * Field declarator for c++. */ -public class CPPASTFieldDeclarator extends CPPASTDeclarator implements - ICPPASTFieldDeclarator, IASTAmbiguityParent { - +public class CPPASTFieldDeclarator extends CPPASTDeclarator implements ICPPASTFieldDeclarator { private IASTExpression bitField; public CPPASTFieldDeclarator() { @@ -75,13 +72,10 @@ public class CPPASTFieldDeclarator extends CPPASTDeclarator implements @Override public void replace(IASTNode child, IASTNode other) { - if( child == bitField ) - { - other.setPropertyInParent( child.getPropertyInParent() ); - other.setParent( child.getParent() ); + if (child == bitField) { + other.setPropertyInParent(child.getPropertyInParent()); + other.setParent(child.getParent()); bitField = (IASTExpression) other; } - } - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java index 0a5f54b54d4..17418ca39b5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitMethod.java @@ -50,7 +50,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod public int getVisibility() { IASTDeclaration decl= getPrimaryDeclaration(); if (decl == null) { - // 12.1-5, 12.8-10 Implicit constructors and assignment operators are public + // 12.1-5, 12.8-10 Implicit constructors and assignment operators are public. return ICPPASTVisibilityLabel.v_public; } @@ -86,7 +86,7 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod } public IASTDeclaration getPrimaryDeclaration() { - // first check if we already know it + // First check if we already know it. if (declarations != null) { for (IASTDeclarator dtor : declarations) { if (dtor == null) @@ -104,17 +104,17 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod IFunctionType ftype = getType(); IType[] params = ftype.getParameterTypes(); - ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal - .getPhysicalNodeOfScope(getScope()); + ICPPASTCompositeTypeSpecifier compSpec = + (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(getScope()); if (compSpec == null) { return null; } IASTDeclaration[] members = compSpec.getMembers(); for (IASTDeclaration member : members) { - IASTDeclarator[] ds = null; while (member instanceof ICPPASTTemplateDeclaration) member = ((ICPPASTTemplateDeclaration) member).getDeclaration(); + IASTDeclarator[] ds; if (member instanceof IASTSimpleDeclaration) { ds = ((IASTSimpleDeclaration) member).getDeclarators(); } else if (member instanceof IASTFunctionDefinition) { @@ -149,10 +149,11 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod } if (ok) { name.setBinding(this); - if (member instanceof IASTSimpleDeclaration) + if (member instanceof IASTSimpleDeclaration) { ASTInternal.addDeclaration(this, dtor); - else if (member instanceof IASTFunctionDefinition) + } else if (member instanceof IASTFunctionDefinition) { ASTInternal.addDefinition(this, dtor); + } return member; } }