{
// If we're a qualified name, and the qualifier resolves to a compile
// time constant, return a QName
// otherwise emit a RTQname - the CG will have to take care of generating the code to
// evaluate the qualifier and place it on the stack.
IQualifiers qual = resolveQualifier(project);
Nsset namespaceSet;
int nameKind;
if (qual != null )
{
if( qual.getNamespaceCount() == 1 )
{
// Qualifier resolved to 1 namespace, so we can emit a QName
NamespaceDefinition ns = (NamespaceDefinition)qual.getFirst();
nameKind = isAttributeIdentifier() ? CONSTANT_QnameA : CONSTANT_Qname;
if (isMemberRef())
{
ExpressionNodeBase baseExpr = getBaseExpression();
if (baseExpr instanceof LanguageIdentifierNode &&
((LanguageIdentifierNode)baseExpr).getKind() == LanguageIdentifierKind.SUPER)
{
// If we're a super expression, adjust the namespace in case it's the protected namespace
IDefinition baseType = baseExpr.resolveType(project);
Set<INamespaceDefinition> nsset = ImmutableSet.of((INamespaceDefinition)ns);
nsset = scope.adjustNamespaceSetForSuper(baseType, nsset);
// We only started with 1 namespace, so we know that's how many we have
ns = (NamespaceDefinition)nsset.iterator().next();
}
}
// If the qualifier is the any namespace, then we want a null nsset
// instead of a nsset of length 1, with a null namespace in it.
if( ns == NamespaceDefinition.getAnyNamespaceReference() )
namespaceSet = null;
else
namespaceSet = new Nsset(ns.getAETNamespace());
}
else
{
// qualifier resolve to 1+ namespaces, so emit a multiname
Set<INamespaceDefinition> nsset = qual.getNamespaceSet();
nameKind = isAttributeIdentifier() ? CONSTANT_MultinameA : CONSTANT_Multiname;
namespaceSet = SemanticUtils.convertSetINamespaceToNsset(nsset);
}
}