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());
}
// 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 */
/* ##################################################################### */

View file

@ -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;
/**

View file

@ -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();
}
/*

View file

@ -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 ||

View file

@ -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();
}
}

View file

@ -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 {

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.
*/
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();

View file

@ -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();

View file

@ -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<preresult.length; i++) {
for (int i= 0; i < preresult.length; i++) {
result[i] = new CPPBaseDelegate(preresult[i]);
}
return result;
}
public ICPPConstructor[] getConstructors() {
ICPPConstructor[] result = ((ICPPClassType)rbinding).getConstructors();
for(int i=0; i<result.length; i++) {
ICPPConstructor[] result = ((ICPPClassType) rbinding).getConstructors();
for (int i= 0; i < result.length; i++) {
result[i] = (ICPPConstructor) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
}
return result;
}
public ICPPField[] getDeclaredFields() {
ICPPField[] result = ((ICPPClassType)rbinding).getDeclaredFields();
for(int i=0; i<result.length; i++) {
ICPPField[] result = ((ICPPClassType) rbinding).getDeclaredFields();
for (int i= 0; i < result.length; i++) {
result[i] = (ICPPField) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
}
return result;
}
public ICPPMethod[] getDeclaredMethods() {
ICPPMethod[] result = ((ICPPClassType)rbinding).getDeclaredMethods();
for(int i=0; i<result.length; i++) {
ICPPMethod[] result = ((ICPPClassType) rbinding).getDeclaredMethods();
for (int i= 0; i < result.length; i++) {
result[i]= (ICPPMethod) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
}
return result;
@ -130,9 +130,9 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
}
public IBinding[] getFriends() {
IBinding[] preResult = ((ICPPClassType)rbinding).getFriends();
IBinding[] preResult = ((ICPPClassType) rbinding).getFriends();
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]);
}
return result;
@ -143,8 +143,8 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
}
public ICPPClassType[] getNestedClasses() {
ICPPClassType[] result = ((ICPPClassType)rbinding).getNestedClasses();
for(int i=0; i<result.length; i++) {
ICPPClassType[] result = ((ICPPClassType) rbinding).getNestedClasses();
for (int i= 0; i < result.length; i++) {
result[i] = (ICPPClassType) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
}
return result;
@ -155,14 +155,14 @@ class CompositeCPPClassType extends CompositeCPPBinding implements ICPPClassType
}
public int getKey() {
return ((ICPPClassType)rbinding).getKey();
return ((ICPPClassType) rbinding).getKey();
}
public boolean isSameType(IType type) {
return ((ICPPClassType)rbinding).isSameType(type);
return ((ICPPClassType) rbinding).isSameType(type);
}
public boolean isAnonymous() {
return ((ICPPClassType)rbinding).isAnonymous();
return ((ICPPClassType) rbinding).isAnonymous();
}
}

View file

@ -63,8 +63,8 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
private volatile ICPPClassScope fScope;
private ObjectMap specializationMap= null; // Obtained from the synchronized PDOM cache
public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType, PDOMBinding specialized)
throws CoreException {
public PDOMCPPClassSpecialization(PDOMLinkage linkage, PDOMNode parent, ICPPClassType classType,
PDOMBinding specialized) throws CoreException {
super(linkage, parent, (ICPPSpecialization) classType, specialized);
}
@ -177,8 +177,7 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
if (base != null) {
if (predecessor != null) {
predecessor.setNextBase(base.getNextBase());
}
else {
} else {
setFirstBase(base.getNextBase());
}
base.delete();
@ -294,15 +293,15 @@ class PDOMCPPClassSpecialization extends PDOMCPPSpecialization implements
}
public int getKey() {
return (getSpecializedBinding()).getKey();
return getSpecializedBinding().getKey();
}
public boolean isSameType(IType type) {
if( type == this )
if (type == this)
return true;
if( type instanceof ITypedef )
return type.isSameType( this );
if (type instanceof ITypedef)
return type.isSameType(this);
if (type instanceof PDOMNode) {
PDOMNode node= (PDOMNode) type;

View file

@ -45,19 +45,13 @@ import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
*
*/
class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDOMMemberOwner {
private static final int FIRSTBASE = PDOMCPPBinding.RECORD_SIZE + 0;
private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4;
private static final int FIRSTFRIEND = PDOMCPPBinding.RECORD_SIZE + 8;
private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 12; // byte
private static final int ANONYMOUS= PDOMCPPBinding.RECORD_SIZE + 13; // byte
@SuppressWarnings("hiding")
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 (predecessor != null) {
predecessor.setNextBase(base.getNextBase());
}
else {
} else {
setFirstBase(base.getNextBase());
}
base.delete();
@ -202,8 +195,7 @@ class PDOMCPPClassType extends PDOMCPPBinding implements IPDOMCPPClassType, IPDO
if (friend != null) {
if (predecessor != null) {
predecessor.setNextFriend(friend.getNextFriend());
}
else {
} else {
setFirstFriend(friend.getNextFriend());
}
friend.delete();