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 2011-09-20 17:36:01 -07:00
parent 4f80345f71
commit 83124590a9
12 changed files with 76 additions and 70 deletions

View file

@ -1596,6 +1596,22 @@ public abstract class IndexCPPBindingResolutionTest extends IndexBindingResoluti
assertEquals("ns", ref.getOwner().getName()); 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 */ /* CPP assertion helpers */
/* ##################################################################### */ /* ##################################################################### */

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Doug Schaefer (IBM) - Initial API and implementation * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp; 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. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICPPClassType extends ICompositeType, ICPPBinding { 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; public static final int k_class = ICPPASTCompositeTypeSpecifier.k_class;
/** /**

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Rational Software - Initial API and implementation * IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c; 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() * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
*/ */
public int getKey() { public int getKey() {
return (definition != null) ? ((IASTCompositeTypeSpecifier) definition.getParent()).getKey() return definition != null ?
: ((IASTElaboratedTypeSpecifier) declarations[0].getParent()).getKind(); ((IASTCompositeTypeSpecifier) definition.getParent()).getKey() :
((IASTElaboratedTypeSpecifier) declarations[0].getParent()).getKind();
} }
/* /*

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Niefer (IBM) - Initial API and implementation * Andrew Niefer (IBM) - Initial API and implementation
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -222,7 +222,6 @@ public class CPPClassSpecialization extends CPPSpecialization
return scope.getNestedClasses(); return scope.getNestedClasses();
} }
public IField[] getFields() { public IField[] getFields() {
return ClassTypeHelper.getFields(this); return ClassTypeHelper.getFields(this);
} }
@ -239,7 +238,6 @@ public class CPPClassSpecialization extends CPPSpecialization
return ClassTypeHelper.getAllDeclaredMethods(this); return ClassTypeHelper.getAllDeclaredMethods(this);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey() * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
*/ */
@ -247,7 +245,7 @@ public class CPPClassSpecialization extends CPPSpecialization
if (getDefinition() != null) if (getDefinition() != null)
return getCompositeTypeSpecifier().getKey(); return getCompositeTypeSpecifier().getKey();
return (getSpecializedBinding()).getKey(); return getSpecializedBinding().getKey();
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -316,7 +314,6 @@ public class CPPClassSpecialization extends CPPSpecialization
return false; return false;
} }
public static boolean isSameClassSpecialization(ICPPClassSpecialization t1, ICPPClassSpecialization t2) { public static boolean isSameClassSpecialization(ICPPClassSpecialization t1, ICPPClassSpecialization t2) {
// exclude class template specialization or class instance // exclude class template specialization or class instance
if (t2 instanceof ICPPTemplateInstance || t2 instanceof ICPPTemplateDefinition || if (t2 instanceof ICPPTemplateInstance || t2 instanceof ICPPTemplateDefinition ||

View file

@ -185,14 +185,14 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
} }
IASTNode n= definition.getParent(); IASTNode n= definition.getParent();
if (n instanceof ICPPASTElaboratedTypeSpecifier) { if (n instanceof ICPPASTElaboratedTypeSpecifier) {
return ((ICPPASTElaboratedTypeSpecifier)n).getKind(); return ((ICPPASTElaboratedTypeSpecifier) n).getKind();
} }
} }
if (declarations != null && declarations.length > 0) { if (declarations != null && declarations.length > 0) {
IASTNode n = declarations[0].getParent(); IASTNode n = declarations[0].getParent();
if (n instanceof ICPPASTElaboratedTypeSpecifier) { if (n instanceof ICPPASTElaboratedTypeSpecifier) {
return ((ICPPASTElaboratedTypeSpecifier)n).getKind(); return ((ICPPASTElaboratedTypeSpecifier) n).getKind();
} }
} }

View file

@ -280,7 +280,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
} }
public IASTNode getPhysicalNode() { public IASTNode getPhysicalNode() {
return (definition != null) ? (IASTNode) definition : declarations[0]; return definition != null ? (IASTNode) definition : declarations[0];
} }
public int getKey() { public int getKey() {
@ -306,7 +306,7 @@ public class CPPClassType extends PlatformObject implements ICPPInternalClassTyp
return; 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()) { if (declarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode) declarations[0]).getOffset()) {
declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, name); declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, name);
} else { } else {

View file

@ -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. * Represents a instantiation that cannot be performed because of dependent arguments or an unknown template.
*/ */
public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDeferredClassInstance { public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDeferredClassInstance {
private final ICPPTemplateArgument[] fArguments; private final ICPPTemplateArgument[] fArguments;
private final ICPPClassTemplate fClassTemplate; private final ICPPClassTemplate fClassTemplate;
private final ICPPScope fLookupScope; 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. // With template template parameters the owner must not be calculated, it'd lead to an infinite loop.
// Rather than that we override getOwner(). // Rather than that we override getOwner().
super(null, template.getNameCharArray()); super(null, template.getNameCharArray());
@ -48,7 +48,6 @@ public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDef
this(template, arguments, null); this(template, arguments, null);
} }
@Override @Override
public IBinding getOwner() { public IBinding getOwner() {
return fClassTemplate.getOwner(); return fClassTemplate.getOwner();

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Andrew Niefer (IBM Corporation) - initial API and implementation * Andrew Niefer (IBM Corporation) - initial API and implementation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;

View file

@ -35,8 +35,8 @@ class CompositeCStructure extends CompositeCBinding implements ICompositeType, I
public IField[] getFields() { public IField[] getFields() {
IField[] result = ((ICompositeType) rbinding).getFields(); IField[] result = ((ICompositeType) rbinding).getFields();
for(int i= 0; i < result.length; i++) for (int i= 0; i < result.length; i++)
result[i] = (IField) cf.getCompositeBinding((IIndexFragmentBinding) result[i]); result[i] = (IField) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
return result; return result;
} }
@ -49,7 +49,9 @@ class CompositeCStructure extends CompositeCBinding implements ICompositeType, I
} }
@Override @Override
public Object clone() {fail(); return null;} public Object clone() {
fail(); return null;
}
public boolean isAnonymous() { public boolean isAnonymous() {
return ((ICompositeType) rbinding).isAnonymous(); return ((ICompositeType) rbinding).isAnonymous();

View file

@ -59,7 +59,7 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
} }
public IBinding getBaseClass() { public IBinding getBaseClass() {
if(baseClass!=null) { if (baseClass != null) {
return baseClass; return baseClass;
} else { } else {
return cf.getCompositeBinding((IIndexFragmentBinding)base.getBaseClass()); return cf.getCompositeBinding((IIndexFragmentBinding)base.getBaseClass());
@ -79,7 +79,7 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
} }
public void setBaseClass(IBinding binding) { public void setBaseClass(IBinding binding) {
if(writable) { if (writable) {
baseClass= binding; baseClass= binding;
} else { } else {
base.setBaseClass(binding); base.setBaseClass(binding);
@ -93,33 +93,33 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
} }
public ICPPBase[] getBases() { public ICPPBase[] getBases() {
final ICPPBase[] preresult = ((ICPPClassType)rbinding).getBases(); final ICPPBase[] preresult = ((ICPPClassType) rbinding).getBases();
ICPPBase[] result = new ICPPBase[preresult.length]; ICPPBase[] result = new ICPPBase[preresult.length];
for(int i=0; i<preresult.length; i++) { for (int i= 0; i < preresult.length; i++) {
result[i] = new CPPBaseDelegate(preresult[i]); result[i] = new CPPBaseDelegate(preresult[i]);
} }
return result; return result;
} }
public ICPPConstructor[] getConstructors() { public ICPPConstructor[] getConstructors() {
ICPPConstructor[] result = ((ICPPClassType)rbinding).getConstructors(); ICPPConstructor[] result = ((ICPPClassType) rbinding).getConstructors();
for(int i=0; i<result.length; i++) { for (int i= 0; i < result.length; i++) {
result[i] = (ICPPConstructor) cf.getCompositeBinding((IIndexFragmentBinding) result[i]); result[i] = (ICPPConstructor) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
} }
return result; return result;
} }
public ICPPField[] getDeclaredFields() { public ICPPField[] getDeclaredFields() {
ICPPField[] result = ((ICPPClassType)rbinding).getDeclaredFields(); ICPPField[] result = ((ICPPClassType) rbinding).getDeclaredFields();
for(int i=0; i<result.length; i++) { for (int i= 0; i < result.length; i++) {
result[i] = (ICPPField) cf.getCompositeBinding((IIndexFragmentBinding)result[i]); result[i] = (ICPPField) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
} }
return result; return result;
} }
public ICPPMethod[] getDeclaredMethods() { public ICPPMethod[] getDeclaredMethods() {
ICPPMethod[] result = ((ICPPClassType)rbinding).getDeclaredMethods(); ICPPMethod[] result = ((ICPPClassType) rbinding).getDeclaredMethods();
for(int i=0; i<result.length; i++) { for (int i= 0; i < result.length; i++) {
result[i]= (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding)result[i]); result[i]= (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
} }
return result; return result;
@ -130,9 +130,9 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
} }
public IBinding[] getFriends() { public IBinding[] getFriends() {
IBinding[] preResult = ((ICPPClassType)rbinding).getFriends(); IBinding[] preResult = ((ICPPClassType) rbinding).getFriends();
IBinding[] result = new IBinding[preResult.length]; IBinding[] result = new IBinding[preResult.length];
for(int i=0; i<preResult.length; i++) { for (int i= 0; i < preResult.length; i++) {
result[i] = cf.getCompositeBinding((IIndexFragmentBinding) preResult[i]); result[i] = cf.getCompositeBinding((IIndexFragmentBinding) preResult[i]);
} }
return result; return result;
@ -143,8 +143,8 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
} }
public ICPPClassType[] getNestedClasses() { public ICPPClassType[] getNestedClasses() {
ICPPClassType[] result = ((ICPPClassType)rbinding).getNestedClasses(); ICPPClassType[] result = ((ICPPClassType) rbinding).getNestedClasses();
for(int i=0; i<result.length; i++) { for (int i= 0; i < result.length; i++) {
result[i] = (ICPPClassType) cf.getCompositeBinding((IIndexFragmentBinding) result[i]); result[i] = (ICPPClassType) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
} }
return result; return result;
@ -155,14 +155,14 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
} }
public int getKey() { public int getKey() {
return ((ICPPClassType)rbinding).getKey(); return ((ICPPClassType) rbinding).getKey();
} }
public boolean isSameType(IType type) { public boolean isSameType(IType type) {
return ((ICPPClassType)rbinding).isSameType(type); return ((ICPPClassType) rbinding).isSameType(type);
} }
public boolean isAnonymous() { public boolean isAnonymous() {
return ((ICPPClassType)rbinding).isAnonymous(); return ((ICPPClassType) rbinding).isAnonymous();
} }
} }

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -63,8 +63,8 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
private volatile ICPPClassScope fScope; private volatile ICPPClassScope fScope;
private ObjectMap specializationMap= null; // Obtained from the synchronized PDOM cache private ObjectMap specializationMap= null; // Obtained from the synchronized PDOM cache
public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType, PDOMBinding specialized) public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType,
throws CoreException { PDOMBinding specialized) throws CoreException {
super(linkage, parent, (ICPPSpecialization) classType, specialized); super(linkage, parent, (ICPPSpecialization) classType, specialized);
} }
@ -177,8 +177,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
if (base != null) { if (base != null) {
if (predecessor != null) { if (predecessor != null) {
predecessor.setNextBase(base.getNextBase()); predecessor.setNextBase(base.getNextBase());
} } else {
else {
setFirstBase(base.getNextBase()); setFirstBase(base.getNextBase());
} }
base.delete(); base.delete();
@ -294,15 +293,15 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
} }
public int getKey() { public int getKey() {
return (getSpecializedBinding()).getKey(); return getSpecializedBinding().getKey();
} }
public boolean isSameType(IType type) { public boolean isSameType(IType type) {
if( type == this ) if (type == this)
return true; return true;
if( type instanceof ITypedef ) if (type instanceof ITypedef)
return type.isSameType( this ); return type.isSameType(this);
if (type instanceof PDOMNode) { if (type instanceof PDOMNode) {
PDOMNode node= (PDOMNode) type; PDOMNode node= (PDOMNode) type;

View file

@ -6,11 +6,11 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Andrew Ferguson (Symbian) * Andrew Ferguson (Symbian)
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -45,19 +45,13 @@ import org.eclipse.core.runtime.CoreException;
/** /**
* @author Doug Schaefer * @author Doug Schaefer
*
*/ */
class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDOMMemberOwner { class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDOMMemberOwner {
private static final int FIRSTBASE = PDOMCPPBinding.RECORD_SIZE + 0; private static final int FIRSTBASE = PDOMCPPBinding.RECORD_SIZE + 0;
private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4; private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4;
private static final int FIRSTFRIEND = PDOMCPPBinding.RECORD_SIZE + 8; private static final int FIRSTFRIEND = PDOMCPPBinding.RECORD_SIZE + 8;
private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 12; // byte private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 12; // byte
private static final int ANONYMOUS= PDOMCPPBinding.RECORD_SIZE + 13; // byte private static final int ANONYMOUS= PDOMCPPBinding.RECORD_SIZE + 13; // byte
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 14; protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 14;
@ -163,8 +157,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
if (base != null) { if (base != null) {
if (predecessor != null) { if (predecessor != null) {
predecessor.setNextBase(base.getNextBase()); predecessor.setNextBase(base.getNextBase());
} } else {
else {
setFirstBase(base.getNextBase()); setFirstBase(base.getNextBase());
} }
base.delete(); base.delete();
@ -202,8 +195,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
if (friend != null) { if (friend != null) {
if (predecessor != null) { if (predecessor != null) {
predecessor.setNextFriend(friend.getNextFriend()); predecessor.setNextFriend(friend.getNextFriend());
} } else {
else {
setFirstFriend(friend.getNextFriend()); setFirstFriend(friend.getNextFriend());
} }
friend.delete(); friend.delete();