IReference getReference(Name name)
{
if( name == null )
return null;
IReference ref = nameMap.get(name);
if( ref != null )
return ref;
switch( name.getKind() )
{
case ABCConstants.CONSTANT_Qname:
INamespaceDefinition ns = getNamespaceReferenceForNamespace(name.getSingleQualifier());
ref = ReferenceFactory.resolvedQualifierQualifiedReference(workspace, ns, name.getBaseName());
break;
case ABCConstants.CONSTANT_Multiname:
Nsset set = name.getQualifiers();
if (set.length() != 1)
{
Set<INamespaceDefinition> ns_set = new HashSet<INamespaceDefinition>(set.length());
for( Namespace n : set )
ns_set.add(getNamespaceReferenceForNamespace(n));
ref = ReferenceFactory.multinameReference(workspace, ns_set, name.getBaseName());
}
else
{
INamespaceDefinition singleNS = getNamespaceReferenceForNamespace(name.getSingleQualifier());
ref = ReferenceFactory.resolvedQualifierQualifiedReference(workspace, singleNS, name.getBaseName());
}
break;
case ABCConstants.CONSTANT_TypeName:
// If we ever support more than Vector, we'll need to harden this code against loops
// in the type name's.
assert name.getTypeNameBase().getBaseName().equals("Vector") : "Vector is currently the only supported parameterized type!";
IReference parameterizedTypeReference = getReference(name.getTypeNameBase());
IReference parameterTypeReference = getReference(name.getTypeNameParameter());
ref = ReferenceFactory.parameterizedReference(workspace, parameterizedTypeReference, parameterTypeReference);
break;
default:
assert false : "Unsupported multiname type: " + name.getKind();
}