diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java index a5e8f536a17..f1c6228a53b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPBindingResolutionTest.java @@ -1595,7 +1595,23 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti IFunction ref= getBindingFromASTName("fun", 0); assertEquals("ns", ref.getOwner().getName()); } - + + // class A {}; + // void f(A a) {} + // struct B {}; + // void g(B b) {} + + // struct A; + // class B; + // + // void test(A a, B b) { + // f(a); + // g(b); + // } + public void testStructClassMismatch_358282() throws Exception { + getBindingFromASTName("f(a)", 1, ICPPFunction.class); + getBindingFromASTName("g(b)", 1, ICPPFunction.class); + } /* CPP assertion helpers */ /* ##################################################################### */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java index de6b52dc375..c12b248514f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassType.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation + * Doug Schaefer (IBM) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.cpp; @@ -21,7 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IField; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPClassType extends ICompositeType, ICPPBinding { - public static final ICPPClassType[] EMPTY_CLASS_ARRAY = new ICPPClassType[0]; + public static final ICPPClassType[] EMPTY_CLASS_ARRAY = {}; public static final int k_class = ICPPASTCompositeTypeSpecifier.k_class; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java index bc7810c1c4f..e2f25473675 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CStructure.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Rational Software - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM Rational Software - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -208,8 +208,9 @@ public class CStructure extends PlatformObject implements ICompositeType, ICInte * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey() */ public int getKey() { - return (definition != null) ? ((IASTCompositeTypeSpecifier) definition.getParent()).getKey() - : ((IASTElaboratedTypeSpecifier) declarations[0].getParent()).getKind(); + return definition != null ? + ((IASTCompositeTypeSpecifier) definition.getParent()).getKey() : + ((IASTElaboratedTypeSpecifier) declarations[0].getParent()).getKind(); } /* diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java index 197ba953e87..6e2447413ea 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Niefer (IBM) - Initial API and implementation - * Bryan Wilkinson (QNX) - * Markus Schorn (Wind River Systems) + * Andrew Niefer (IBM) - Initial API and implementation + * Bryan Wilkinson (QNX) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -222,7 +222,6 @@ public class CPPClassSpecialization extends CPPSpecialization return scope.getNestedClasses(); } - public IField[] getFields() { return ClassTypeHelper.getFields(this); } @@ -239,7 +238,6 @@ public class CPPClassSpecialization extends CPPSpecialization return ClassTypeHelper.getAllDeclaredMethods(this); } - /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey() */ @@ -247,7 +245,7 @@ public class CPPClassSpecialization extends CPPSpecialization if (getDefinition() != null) return getCompositeTypeSpecifier().getKey(); - return (getSpecializedBinding()).getKey(); + return getSpecializedBinding().getKey(); } /* (non-Javadoc) @@ -316,7 +314,6 @@ public class CPPClassSpecialization extends CPPSpecialization return false; } - public static boolean isSameClassSpecialization(ICPPClassSpecialization t1, ICPPClassSpecialization t2) { // exclude class template specialization or class instance if (t2 instanceof ICPPTemplateInstance || t2 instanceof ICPPTemplateDefinition || diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java index fec1948046d..409de0c5536 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java @@ -185,14 +185,14 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass } IASTNode n= definition.getParent(); if (n instanceof ICPPASTElaboratedTypeSpecifier) { - return ((ICPPASTElaboratedTypeSpecifier)n).getKind(); + return ((ICPPASTElaboratedTypeSpecifier) n).getKind(); } } if (declarations != null && declarations.length > 0) { IASTNode n = declarations[0].getParent(); if (n instanceof ICPPASTElaboratedTypeSpecifier) { - return ((ICPPASTElaboratedTypeSpecifier)n).getKind(); + return ((ICPPASTElaboratedTypeSpecifier) n).getKind(); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java index 1ca174cae6e..f48af6c28ac 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassType.java @@ -280,7 +280,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp } public IASTNode getPhysicalNode() { - return (definition != null) ? (IASTNode) definition : declarations[0]; + return definition != null ? (IASTNode) definition : declarations[0]; } public int getKey() { @@ -306,7 +306,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp return; } - //keep the lowest offset declaration in [0] + // Keep the lowest offset declaration in [0] if (declarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode) declarations[0]).getOffset()) { declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, name); } else { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java index 04d2202eb94..dfc6f059114 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPDeferredClassInstance.java @@ -30,12 +30,12 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; * Represents a instantiation that cannot be performed because of dependent arguments or an unknown template. */ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDeferredClassInstance { - private final ICPPTemplateArgument[] fArguments; private final ICPPClassTemplate fClassTemplate; private final ICPPScope fLookupScope; - public CPPDeferredClassInstance(ICPPClassTemplate template, ICPPTemplateArgument[] arguments, ICPPScope lookupScope) throws DOMException { + public CPPDeferredClassInstance(ICPPClassTemplate template, ICPPTemplateArgument[] arguments, + ICPPScope lookupScope) throws DOMException { // With template template parameters the owner must not be calculated, it'd lead to an infinite loop. // Rather than that we override getOwner(). super(null, template.getNameCharArray()); @@ -48,7 +48,6 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef this(template, arguments, null); } - @Override public IBinding getOwner() { return fClassTemplate.getOwner(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java index 773a35d5d7e..47d12562692 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownClass.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Andrew Niefer (IBM Corporation) - initial API and implementation - * Sergey Prigogin (Google) - * Markus Schorn (Wind River Systems) + * Andrew Niefer (IBM Corporation) - initial API and implementation + * Sergey Prigogin (Google) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCStructure.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCStructure.java index 35a5891b69b..c7ad8114918 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCStructure.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCStructure.java @@ -35,8 +35,8 @@ class CompositeCStructure extends CompositeCBinding implements ICompositeType, I public IField[] getFields() { IField[] result = ((ICompositeType) rbinding).getFields(); - for(int i= 0; i < result.length; i++) - result[i] = (IField) cf.getCompositeBinding((IIndexFragmentBinding) result[i]); + for (int i= 0; i < result.length; i++) + result[i] = (IField) cf.getCompositeBinding((IIndexFragmentBinding)result[i]); return result; } @@ -49,7 +49,9 @@ class CompositeCStructure extends CompositeCBinding implements ICompositeType, I } @Override - public Object clone() {fail(); return null;} + public Object clone() { + fail(); return null; + } public boolean isAnonymous() { return ((ICompositeType) rbinding).isAnonymous(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java index 4050da7c023..a95683e753e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassType.java @@ -59,7 +59,7 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType } public IBinding getBaseClass() { - if(baseClass!=null) { + if (baseClass != null) { return baseClass; } else { return cf.getCompositeBinding((IIndexFragmentBinding)base.getBaseClass()); @@ -79,7 +79,7 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType } public void setBaseClass(IBinding binding) { - if(writable) { + if (writable) { baseClass= binding; } else { base.setBaseClass(binding); @@ -93,33 +93,33 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType } public ICPPBase[] getBases() { - final ICPPBase[] preresult = ((ICPPClassType)rbinding).getBases(); + final ICPPBase[] preresult = ((ICPPClassType) rbinding).getBases(); ICPPBase[] result = new ICPPBase[preresult.length]; - for(int i=0; i