/**
* Check that the namespace of the definition is valid
*/
public void checkNamespaceOfDefinition(IASNode iNode, IDefinition def, ICompilerProject project)
{
INamespaceReference nsRef = def.getNamespaceReference();
// If it's not a language namespace, then it is only valid if the def is declared in a class
if( !nsRef.isLanguageNamespace() && !(def.getParent() instanceof IClassDefinition) )
{
// if in function, we will already generate the error that no overrides at all are allowed
if (!SemanticUtils.isInFunction(iNode))
addProblem(new InvalidNamespaceProblem(iNode instanceof BaseDefinitionNode ?
((BaseDefinitionNode)iNode).getNamespaceNode() :
iNode));
}
if( nsRef == NamespaceDefinition.getCodeModelImplicitDefinitionNamespace()
// constructors are left in the CMImplicit namespace so that FB continues to work right
&& !isConstructor(def) )
{
// This should only happen if an invalid access namespace was specified
// e.g. private outside of a class
BaseDefinitionNode bdn = iNode instanceof BaseDefinitionNode ? (BaseDefinitionNode)iNode : null;
if( bdn != null )
{
INamespaceDecorationNode nsNode = bdn.getNamespaceNode();
if( nsNode != null )
{
String nsString = nsNode.getName();
if( nsString == IASKeywordConstants.PUBLIC )
{
addProblem(new InvalidPublicNamespaceAttrProblem(nsNode) );
}
else if( nsString == IASKeywordConstants.PROTECTED )
{
addProblem(new InvalidProtectedNamespaceAttrProblem(nsNode) );
}
else if( nsString == IASKeywordConstants.PRIVATE )
{
addProblem(new InvalidPrivateNamespaceAttrProblem(nsNode));
}
}
}
}
IASNode nsNode = iNode instanceof BaseDefinitionNode ?
((BaseDefinitionNode)iNode).getNamespaceNode() :
iNode;
INamespaceDefinition nsDef = nsRef.resolveNamespaceReference(project);
if (nsRef.resolveNamespaceReference(project) == null)
addProblem(new UnresolvedNamespaceProblem(nsNode));
checkDeprecated(nsNode, nsDef);
}