1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-17 05:05:43 +02:00

toString methods and generics.

This commit is contained in:
Sergey Prigogin 2008-02-25 00:00:32 +00:00
parent a2f9f9a4eb
commit bd4d1ba488
10 changed files with 558 additions and 552 deletions

View file

@ -25,6 +25,9 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
private boolean isShort;
private boolean isLong;
/**
* @see org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier
*/
public int getType() {
return type;
}

View file

@ -29,9 +29,10 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
* @author jcamelon
*/
public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, IASTAmbiguityParent {
private IASTName templateName;
private IASTNode[] templateArguments = null;
private IBinding binding = null;
private int fResolutionDepth = 0;
public CPPASTTemplateId() {
}
@ -73,17 +74,12 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
return (IASTNode[]) ArrayUtil.trim(IASTNode.class, templateArguments);
}
private IASTNode [] templateArguments = null;
private IBinding binding = null;
private int fResolutionDepth= 0;
public IBinding resolveBinding() {
if (binding == null) {
// protect for infinite recursion
if (++fResolutionDepth > CPPASTName.MAX_RESOLUTION_DEPTH) {
binding= new CPPASTName.RecursionResolvingBinding(this);
}
else {
} else {
binding = CPPTemplates.createBinding(this);
}
}
@ -95,10 +91,10 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
return null;
}
public char[] toCharArray() {
return templateName.toCharArray();
}
@Override
public String toString() {
return templateName.toString();
@ -113,7 +109,7 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
default: break;
}
}
if( templateName != null ) if( !templateName.accept( action ) ) return false;
if (templateName != null && !templateName.accept(action)) return false;
IASTNode[] nodes = getTemplateArguments();
for (int i = 0; i < nodes.length; i++) {
@ -167,8 +163,7 @@ public class CPPASTTemplateId extends CPPASTNode implements ICPPASTTemplateId, I
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
if( role == IASTNameOwner.r_definition ) return true;
return false;
return role == IASTNameOwner.r_definition;
}
return false;
}

View file

@ -79,7 +79,7 @@ public class CPPASTUsingDirective extends CPPASTNode implements
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
IBinding[] bindings = CPPSemantics.findBindingsForContentAssist(n, isPrefix);
List filtered = new ArrayList();
List<IBinding> filtered = new ArrayList<IBinding>();
for (int i = 0;i < bindings.length; i++) {
if (bindings[i] instanceof ICPPNamespace) {
@ -87,6 +87,6 @@ public class CPPASTUsingDirective extends CPPASTNode implements
}
}
return (IBinding[]) filtered.toArray(new IBinding[filtered.size()]);
return filtered.toArray(new IBinding[filtered.size()]);
}
}

View file

@ -75,7 +75,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
*/
public IField[] getFields() throws DOMException {
// TODO Auto-generated method stub
return null;
}
@ -83,7 +82,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#findField(java.lang.String)
*/
public IField findField(String name) throws DOMException {
// TODO Auto-generated method stub
return null;
}
@ -91,7 +89,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
*/
public ICPPField[] getDeclaredFields() throws DOMException {
// TODO Auto-generated method stub
return null;
}
@ -99,7 +96,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
*/
public ICPPMethod[] getMethods() throws DOMException {
// TODO Auto-generated method stub
return null;
}
@ -107,7 +103,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
*/
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
// TODO Auto-generated method stub
return null;
}
@ -115,7 +110,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
*/
public ICPPMethod[] getDeclaredMethods() throws DOMException {
// TODO Auto-generated method stub
return null;
}
@ -133,7 +127,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
*/
public IBinding[] getFriends() throws DOMException {
// TODO Auto-generated method stub
return null;
}
@ -159,7 +152,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
*/
@Override
public Object clone() {
// TODO Auto-generated method stub
return this;
}
@ -180,7 +172,8 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
if (!ct1.isSameType(ct2))
return false;
ObjectMap m1 = getArgumentMap(), m2 = ((ICPPTemplateInstance)type).getArgumentMap();
ObjectMap m1 = getArgumentMap();
ObjectMap m2 = ((ICPPTemplateInstance) type).getArgumentMap();
if (m1 == null || m2 == null || m1.size() != m2.size())
return false;
for (int i = 0; i < m1.size(); i++) {
@ -210,6 +203,6 @@ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPP
@Override
public boolean equals(Object obj) {
return obj instanceof ICPPClassType ? isSameType((ICPPClassType)obj) : false;
return obj instanceof ICPPClassType && isSameType((ICPPClassType) obj);
}
}

View file

@ -38,7 +38,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTOperatorName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
@ -276,9 +275,10 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
i--;
continue;
}
} else if( obj instanceof ICPPConstructor )
} else if (obj instanceof ICPPConstructor) {
bs = (IBinding[]) ArrayUtil.append(ICPPConstructor.class, bs, obj);
}
}
return (ICPPConstructor[]) ArrayUtil.trim(ICPPConstructor.class, bs);
} else if (o instanceof IASTName) {
if (shouldResolve(forceResolve, (IASTName) o, forName) || ((IASTName)o).getBinding() != null) {
@ -404,7 +404,7 @@ class ImplicitsAnalysis {
IASTParameterDeclaration[] ps = dcltor.getParameters();
if (ps.length >= 1) {
if (paramHasTypeReferenceToTheAssociatedClassType(ps[0], compSpec.getName().getRawSignature())) {
// and all remaining arguments have initialisers
// and all remaining arguments have initializers
for (int j = 1; j < ps.length; j++) {
if (ps[j].getDeclarator().getInitializer() == null) {
continue outer;
@ -446,8 +446,7 @@ class ImplicitsAnalysis {
if (!(dcltor instanceof ICPPASTFunctionDeclarator) || !(spec instanceof IASTSimpleDeclSpecifier) ||
((IASTSimpleDeclSpecifier)spec).getType() != IASTSimpleDeclSpecifier.t_unspecified)
{
((IASTSimpleDeclSpecifier)spec).getType() != IASTSimpleDeclSpecifier.t_unspecified) {
continue;
}

View file

@ -40,8 +40,8 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
* @param scope
* @param argumentMap
*/
public CPPClassTemplateSpecialization(IBinding specialized,
ICPPScope scope, ObjectMap argumentMap) {
public CPPClassTemplateSpecialization(IBinding specialized, ICPPScope scope,
ObjectMap argumentMap) {
super(specialized, scope, argumentMap);
}
@ -100,8 +100,9 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
return e.getProblem();
}
if( template instanceof IProblemBinding )
if (template instanceof IProblemBinding) {
return template;
}
if (template != null && template instanceof ICPPClassTemplatePartialSpecialization) {
return ((ICPPInternalTemplateInstantiator) template).instantiate(arguments);
}
@ -110,11 +111,14 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
}
public ICPPSpecialization deferredInstance(IType[] arguments) {
// TODO Auto-generated method stub
return null;
}
public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {
//should not occur
}
public String toString() {
return getName();
}
}

View file

@ -570,7 +570,8 @@ public class CPPTemplates {
* @return
* @throws DOMException
*/
static protected Object[] deduceTemplateFunctionArguments(ICPPFunctionTemplate primaryTemplate, IASTParameterDeclaration[] ps, IASTNode[] specArgs) throws DOMException
static protected Object[] deduceTemplateFunctionArguments(ICPPFunctionTemplate primaryTemplate,
IASTParameterDeclaration[] ps, IASTNode[] specArgs) throws DOMException
{
ICPPTemplateParameter[] templateParameters = primaryTemplate.getTemplateParameters();
IType[] arguments = createTypeArray(specArgs);
@ -681,7 +682,8 @@ public class CPPTemplates {
}
} catch (DOMException e) {
}
newType = new CPPFunctionType(ret, params, ((ICPPFunctionType)type).isConst(), ((ICPPFunctionType)type).isVolatile());
newType = new CPPFunctionType(ret, params, ((ICPPFunctionType)type).isConst(),
((ICPPFunctionType)type).isVolatile());
} else if (type instanceof ITypedef) {
// Typedef requires special treatment (bug 213861).
try {
@ -984,7 +986,8 @@ public class CPPTemplates {
return result;
}
static protected IFunction[] selectTemplateFunctions(ObjectSet templates, Object[] functionArguments, IASTName name) {//IASTNode[] templateArguments) {
static protected IFunction[] selectTemplateFunctions(ObjectSet templates,
Object[] functionArguments, IASTName name) {//IASTNode[] templateArguments) {
if (templates == null || templates.size() == 0)
return null;
@ -1576,11 +1579,8 @@ public class CPPTemplates {
return (t instanceof ICPPTemplateParameter);
}
public static IBinding instantiateTemplate(ICPPTemplateDefinition template, IType[] arguments, ObjectMap specializedArgs) {
if (template == null) {
template = null;
}
public static IBinding instantiateTemplate(ICPPTemplateDefinition template, IType[] arguments,
ObjectMap specializedArgs) {
ICPPTemplateParameter[] parameters = null;
try {
parameters = template.getTemplateParameters();

View file

@ -43,7 +43,7 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
this.scopeBinding = scopeBinding;
}
/* (non-Javadoc)```
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#getUnknownScope()
*/
public ICPPScope getUnknownScope() {
@ -152,4 +152,11 @@ public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnk
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
/* (non-Javadoc)
* For debug purposes only
*/
public String toString() {
return getName();
}
}

View file

@ -27,6 +27,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
/**
* Represents a C++ class for which we don't yet have a complete declaration.
*
* @author aniefer
*/
public class CPPUnknownClass extends CPPUnknownBinding implements ICPPClassType {
@ -133,5 +135,4 @@ public class CPPUnknownClass extends CPPUnknownBinding implements ICPPClassType
public ICPPClassType[] getNestedClasses() {
return ICPPClassType.EMPTY_CLASS_ARRAY;
}
}

View file

@ -77,14 +77,12 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
* @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
public void addName(IASTName name) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
*/
public void removeBinding( IBinding binding1 ) {
public void removeBinding(IBinding binding) {
}
public final IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
@ -110,11 +108,11 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
IBinding b = new CPPUnknownClass(this, binding, name);
name.setBinding(b);
map.put(c, b);
return b;
}
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) {
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup,
IIndexFileSet fileSet) {
if (map == null)
map = new CharArrayObjectMap(2);
@ -156,8 +154,14 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
public void flushCache() {
}
public void addBinding(IBinding aBinding) {
public void addBinding(IBinding binding) {
// do nothing, this is part of template magic and not a normal scope
}
/* (non-Javadoc)
* For debug purposes only
*/
public String toString() {
return scopeName.toString();
}
}