use of org.eclipse.titan.designer.AST.TTCN3.statements.Start_Referenced_Component_Statement in project titan.EclipsePlug-ins by eclipse.
the class UnusedStartedRefFuncRetVal method process.
@Override
public void process(final IVisitableNode node, final Problems problems) {
if (node instanceof Start_Referenced_Component_Statement) {
final CompilationTimeStamp timestamp = CompilationTimeStamp.getBaseTimestamp();
final Start_Referenced_Component_Statement s = (Start_Referenced_Component_Statement) node;
final Value dereferredValue = s.getDereferredValue();
if (dereferredValue == null) {
return;
}
switch(dereferredValue.getValuetype()) {
case EXPRESSION_VALUE:
if (Operation_type.REFERS_OPERATION.equals(((Expression_Value) dereferredValue).getOperationType())) {
return;
}
break;
case TTCN3_NULL_VALUE:
case FAT_NULL_VALUE:
return;
default:
break;
}
IType type = dereferredValue.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (type != null) {
type = type.getTypeRefdLast(timestamp);
}
if (type == null || type.getIsErroneous(timestamp)) {
return;
}
if (!(type instanceof Function_Type)) {
return;
}
final Function_Type functionType = (Function_Type) type;
if (functionType.isRunsOnSelf()) {
return;
}
if (!functionType.isStartable(timestamp)) {
return;
}
final IType returnType = functionType.getReturnType();
if (returnType == null) {
return;
}
if (functionType.returnsTemplate()) {
return;
}
IType lastType = returnType;
boolean returnTypeCorrect = false;
while (!returnTypeCorrect) {
if (lastType.hasDoneAttribute()) {
returnTypeCorrect = true;
break;
}
if (lastType instanceof IReferencingType) {
final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IType refd = ((IReferencingType) lastType).getTypeRefd(timestamp, refChain);
refChain.release();
if (lastType != refd) {
lastType = refd;
} else {
break;
}
} else {
break;
}
}
if (!returnTypeCorrect) {
final String msg = MessageFormat.format(PROBLEM, functionType.getTypename(), returnType.getTypename());
problems.report(dereferredValue.getLocation(), msg);
}
}
}
Aggregations