* This method performs the semantic analysis of a function declared in a class.
* @param func the FunctionNode to semantically analyze
*/
void functionSemanticChecks(FunctionNode func)
{
final FunctionDefinition func_def = func.getDefinition();
final String interfaceBaseName = interfaceNode.getShortName();
// Check for constructor and log a problem. If it is a constructor,
// don't bother doing anymore checking
if (func_def.getBaseName().equals(interfaceBaseName))
{
interfaceScope.addProblem(new ConstructorInInterfaceProblem(func));
return;
}
// check the modifiers
verifyFunctionModifiers(func);
// Make sure the function doesn't have a namespace
verifyFunctionNamespace(func, func_def);
// Warn if there is no return type
SemanticUtils.checkReturnValueHasNoTypeDeclaration(interfaceScope, func, func_def);
// Interface methods can't have a body
if( func.hasBody() )
{
interfaceScope.addProblem(new InterfaceMethodWithBodyProblem(SemanticUtils.getFunctionProblemNode(func)));
}
ICompilerProject project = interfaceScope.getProject();
// Do some semantic checking on the function
interfaceScope.getMethodBodySemanticChecker().checkFunctionDecl(func);
// Ensure the return type is defined.
IDefinition return_type = func_def.resolveReturnType(project);
if ( !SemanticUtils.isType(return_type) )
{
interfaceScope.getMethodBodySemanticChecker().addTypeProblem(func.getReturnTypeNode(), return_type, func_def.getReturnTypeAsDisplayString(), true);
}
Name funcName = func_def.getMName(project);
if (funcName != null)
{
interfaceScope.getMethodBodySemanticChecker().checkInterfaceFunctionForConflictingDefinitions(func, func_def);
}