From cc5074d0bc723930a66dfb84185b74614072c99d Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 30 Nov 2012 17:12:32 -0800 Subject: [PATCH] Cosmetics. --- .../internal/core/dom/parser/ASTInternal.java | 9 ++-- .../dom/parser/cpp/CPPBuiltinParameter.java | 4 +- .../cpp/CPPLambdaExpressionParameter.java | 7 ++- .../dom/parser/cpp/ICPPInstanceCache.java | 2 - .../dom/parser/cpp/ICPPInternalFunction.java | 2 - .../dom/parser/cpp/ICPPInternalTemplate.java | 3 +- .../parser/cpp/semantics/CPPTemplates.java | 3 +- .../composite/cpp/CompositeCPPBinding.java | 12 +++--- .../composite/cpp/CompositeCPPParameter.java | 4 +- .../CompositeCPPParameterSpecialization.java | 4 +- .../cdt/internal/core/pdom/PDOMWriter.java | 9 ++-- .../internal/core/pdom/dom/FindBinding.java | 4 +- .../core/pdom/dom/IInternalPDOMNode.java | 2 +- .../core/pdom/dom/IPDOMOverloader.java | 1 - .../cdt/internal/core/pdom/dom/PDOMName.java | 2 +- .../core/pdom/dom/c/PDOMCFunction.java | 43 ++++++++++--------- .../core/pdom/dom/cpp/CPPFindBinding.java | 8 ++-- .../core/pdom/dom/cpp/PDOMCPPBinding.java | 2 +- .../pdom/dom/cpp/PDOMCPPClassTemplate.java | 16 ++++--- .../pdom/dom/cpp/PDOMCPPFunctionTemplate.java | 7 ++- .../core/pdom/dom/cpp/PDOMCPPParameter.java | 2 +- .../dom/cpp/PDOMCPPTemplateTypeParameter.java | 7 ++- 22 files changed, 78 insertions(+), 75 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java index e2087d27d62..b6fa968864b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTInternal.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; @@ -74,7 +74,8 @@ public class ASTInternal { } } - public static IASTNode getDeclaredInSourceFileOnly(IIndexFragment forFragment, IBinding binding, boolean requireDefinition, PDOMBinding nonLocal) { + public static IASTNode getDeclaredInSourceFileOnly(IIndexFragment forFragment, IBinding binding, + boolean requireDefinition, PDOMBinding glob) { IASTNode[] decls; IASTNode def; if (binding instanceof ICPPInternalBinding) { @@ -110,9 +111,9 @@ public class ASTInternal { if (result == null) return null; - if (requireDefinition && nonLocal != null) { + if (requireDefinition && glob != null) { try { - if (nonLocal.hasDeclaration()) + if (glob.hasDeclaration()) return null; } catch (CoreException e) { } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.java index f1f9c2e2c9c..3b3793f7b85 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBuiltinParameter.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; @@ -34,7 +34,7 @@ public class CPPBuiltinParameter extends PlatformObject implements ICPPParameter return result; } - private IType type= null; + private IType type; public CPPBuiltinParameter(IType type) { this.type = type; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLambdaExpressionParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLambdaExpressionParameter.java index db11a37fe21..4b39dce8daf 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLambdaExpressionParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPLambdaExpressionParameter.java @@ -31,8 +31,8 @@ import org.eclipse.core.runtime.PlatformObject; * Binding for a c++ function parameter */ public class CPPLambdaExpressionParameter extends PlatformObject implements ICPPParameter { - private IType fType = null; - private IASTName fDeclaration = null; + private IType fType; + private IASTName fDeclaration; public CPPLambdaExpressionParameter(IASTName name) { fDeclaration = name; @@ -77,14 +77,17 @@ public class CPPLambdaExpressionParameter extends PlatformObject implements ICPP public boolean isStatic() { return false; } + @Override public String[] getQualifiedName() { return new String[] { getName() }; } + @Override public char[][] getQualifiedNameCharArray() { return new char[][] { getNameCharArray() }; } + @Override public boolean isGloballyQualified() { return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInstanceCache.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInstanceCache.java index 489dd35fee1..fccef10a19f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInstanceCache.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInstanceCache.java @@ -15,12 +15,10 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; - /** * Caches instances per template, the template definitions need to implement this interface */ public interface ICPPInstanceCache { - /** * Attempts to cache an instance with this template */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalFunction.java index de1b021888f..4f4d4be7701 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalFunction.java @@ -9,7 +9,6 @@ * IBM Corporation - initial API and implementation * Markus Schorn (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -18,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.IBinding; * Interface for ast-internal implementations of function bindings. */ public interface ICPPInternalFunction extends ICPPInternalBinding { - /** * Called to resolve the parameter in the second phase. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalTemplate.java index 66b033e39e9..68a64cdec60 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalTemplate.java @@ -6,14 +6,13 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; - /** * Interface for templates from the ast. */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 3a94bf2101a..0636d2829cb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -534,8 +534,9 @@ public class CPPTemplates { ICPPASTTemplateDeclaration templateDeclaration = templates[0]; IASTDeclaration decl = templateDeclaration.getDeclaration(); - while (decl instanceof ICPPASTTemplateDeclaration) + while (decl instanceof ICPPASTTemplateDeclaration) { decl = ((ICPPASTTemplateDeclaration) decl).getDeclaration(); + } IASTName name = null; if (decl instanceof IASTSimpleDeclaration) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPBinding.java index c3c6f03429b..2a92ec2fdc1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPBinding.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.cpp; @@ -26,20 +26,20 @@ abstract class CompositeCPPBinding extends CompositeIndexBinding implements ICPP @Override public String[] getQualifiedName() { try { - return ((ICPPBinding)rbinding).getQualifiedName(); - } catch(DOMException de) { - CCorePlugin.log(de); + return ((ICPPBinding) rbinding).getQualifiedName(); + } catch (DOMException e) { + CCorePlugin.log(e); return new String[0]; } } @Override public char[][] getQualifiedNameCharArray() throws DOMException { - return ((ICPPBinding)rbinding).getQualifiedNameCharArray(); + return ((ICPPBinding) rbinding).getQualifiedNameCharArray(); } @Override public boolean isGloballyQualified() throws DOMException { - return ((ICPPBinding)rbinding).isGloballyQualified(); + return ((ICPPBinding) rbinding).isGloballyQualified(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameter.java index bbc23c63db4..3ce3c42abe6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameter.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation - * Markus Schorn (Wind River Systems) + * Andrew Ferguson (Symbian) - Initial implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.cpp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameterSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameterSpecialization.java index 7c26e009ecc..0f282a0b391 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameterSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPParameterSpecialization.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Ferguson (Symbian) - Initial implementation - * Markus Schorn (Wind River Systems) + * Andrew Ferguson (Symbian) - Initial implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.index.composite.cpp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java index bba355b670d..3d591c527d2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMWriter.java @@ -297,16 +297,17 @@ abstract public class PDOMWriter { } } } - } catch (RuntimeException e) { + } catch (RuntimeException e) { th= e; } catch (StackOverflowError e) { th= e; } catch (AssertionError e) { th= e; } finally { - // Because the caller holds a read-lock, the result cache of the index is never cleared. - // ==> Before releasing the lock for the last time in this ast, we clear the result cache. - if (i == data.fSelectedFiles.length-1) { + // Because the caller holds a read-lock, the result cache of the index is never + // cleared. Before releasing the lock for the last time in this AST, we clear + // the result cache. + if (i == data.fSelectedFiles.length - 1) { data.fIndex.clearResultCache(); } lock.release(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/FindBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/FindBinding.java index f8614bee19d..b23f0efcb30 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/FindBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/FindBinding.java @@ -115,7 +115,7 @@ public class FindBinding { public PDOMBinding getResult() { return fResult; } - // IPDOMVisitor + @Override public boolean visit(IPDOMNode node) throws CoreException { if (node instanceof PDOMBinding) { @@ -127,7 +127,7 @@ public class FindBinding { } return false; /* do not visit children of node */ } - // IPDOMVisitor + @Override public void leave(IPDOMNode node) throws CoreException { } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/IInternalPDOMNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/IInternalPDOMNode.java index 73649c2e2ac..2276206e85f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/IInternalPDOMNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/IInternalPDOMNode.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.pdom.dom; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/IPDOMOverloader.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/IPDOMOverloader.java index a6b1d53a061..2d25556ff4d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/IPDOMOverloader.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/IPDOMOverloader.java @@ -20,7 +20,6 @@ import org.eclipse.core.runtime.CoreException; * @author Bryan Wilkinson */ public interface IPDOMOverloader { - /** * @return the signature hash for this PDOM element, which will be unique * for all sibling IPDOMOverloaders with the same name. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java index 3be5bdb1452..d222425d19c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java @@ -211,7 +211,7 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation { try { Database db = linkage.getDB(); long bindingRec = db.getRecPtr(record + BINDING_REC_OFFSET); - PDOMBinding binding = linkage.getBinding(bindingRec); + IPDOMBinding binding = linkage.getBinding(bindingRec); return binding != null ? binding.getNameCharArray() : null; } catch (CoreException e) { CCorePlugin.log(e); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java index a579fc6449f..20a4094fc6b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java @@ -80,27 +80,28 @@ class PDOMCFunction extends PDOMBinding implements IFunction { @Override public void update(final PDOMLinkage linkage, IBinding newBinding) throws CoreException { - if (newBinding instanceof IFunction) { - IFunction func= (IFunction) newBinding; - IFunctionType newType; - IParameter[] newParams; - byte newAnnotation; - newType= func.getType(); - newParams = func.getParameters(); - newAnnotation = PDOMCAnnotation.encodeAnnotation(func); - - setType(linkage, newType); - PDOMCParameter oldParams= getFirstParameter(null); - setParameters(newParams); - if (oldParams != null) { - oldParams.delete(linkage); - } - getDB().putByte(record + ANNOTATIONS, newAnnotation); + if (!(newBinding instanceof IFunction)) + return; + + IFunction func= (IFunction) newBinding; + IFunctionType newType; + IParameter[] newParams; + byte newAnnotation; + newType= func.getType(); + newParams = func.getParameters(); + newAnnotation = PDOMCAnnotation.encodeAnnotation(func); + + setType(linkage, newType); + PDOMCParameter oldParams= getFirstParameter(null); + setParameters(newParams); + if (oldParams != null) { + oldParams.delete(linkage); } + getDB().putByte(record + ANNOTATIONS, newAnnotation); } private void setType(PDOMLinkage linkage, IFunctionType ft) throws CoreException { - linkage.storeType(record+FUNCTION_TYPE, ft); + linkage.storeType(record + FUNCTION_TYPE, ft); } private void setParameters(IParameter[] params) throws CoreException { @@ -109,7 +110,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction { db.putInt(record + NUM_PARAMS, params.length); db.putRecPtr(record + FIRST_PARAM, 0); PDOMCParameter next= null; - for (int i= params.length-1; i >= 0; --i) { + for (int i= params.length; --i >= 0;) { next= new PDOMCParameter(linkage, this, params[i], next); } db.putRecPtr(record + FIRST_PARAM, next == null ? 0 : next.getRecord()); @@ -134,8 +135,8 @@ class PDOMCFunction extends PDOMBinding implements IFunction { public IFunctionType getType() { try { return (IFunctionType) getLinkage().loadType(record + FUNCTION_TYPE); - } catch(CoreException ce) { - CCorePlugin.log(ce); + } catch (CoreException e) { + CCorePlugin.log(e); return new ProblemFunctionType(ISemanticProblem.TYPE_NOT_PERSISTED); } } @@ -163,7 +164,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction { long next = db.getRecPtr(record + FIRST_PARAM); for (int i = 0; i < n && next != 0; i++) { - IType type= i