Search in sources :

Example 1 with IParameterisedAssignment

use of org.eclipse.titan.designer.AST.TTCN3.definitions.IParameterisedAssignment in project titan.EclipsePlug-ins by eclipse.

the class Reference method getRefdAssignment.

public Assignment getRefdAssignment(final CompilationTimeStamp timestamp, final boolean checkParameterList, final IReferenceChain referenceChain) {
    if (myScope == null || getId() == null) {
        return null;
    }
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp) && !checkParameterList) {
        return referredAssignment;
    }
    lastTimeChecked = timestamp;
    final boolean newChain = null == referenceChain;
    IReferenceChain tempReferenceChain;
    if (newChain) {
        tempReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    } else {
        tempReferenceChain = referenceChain;
    }
    isErroneous = false;
    detectedModuleId = false;
    detectModid();
    referredAssignment = myScope.getAssBySRef(timestamp, this, referenceChain);
    if (referredAssignment == null) {
        isErroneous = true;
        return referredAssignment;
    }
    referredAssignment.check(timestamp, tempReferenceChain);
    referredAssignment.setUsed();
    if (referredAssignment instanceof Definition) {
        final String referingModuleName = getMyScope().getModuleScope().getName();
        if (!((Definition) referredAssignment).referingHere.contains(referingModuleName)) {
            ((Definition) referredAssignment).referingHere.add(referingModuleName);
        }
    }
    if (checkParameterList) {
        FormalParameterList formalParameterList = null;
        if (referredAssignment instanceof IParameterisedAssignment) {
            formalParameterList = ((IParameterisedAssignment) referredAssignment).getFormalParameterList();
        }
        if (formalParameterList == null) {
            if (!subReferences.isEmpty() && subReferences.get(0) instanceof ParameterisedSubReference) {
                final String message = MessageFormat.format("The referenced {0} cannot have actual parameters", referredAssignment.getDescription());
                getLocation().reportSemanticError(message);
                setIsErroneous(true);
            }
        } else if (!subReferences.isEmpty()) {
            final ISubReference firstSubReference = subReferences.get(0);
            if (firstSubReference instanceof ParameterisedSubReference) {
                formalParameterList.check(timestamp, referredAssignment.getAssignmentType());
                isErroneous = ((ParameterisedSubReference) firstSubReference).checkParameters(timestamp, formalParameterList);
            } else {
                // default values
                if (!Assignment.Assignment_type.A_TEMPLATE.semanticallyEquals(referredAssignment.getAssignmentType()) || !formalParameterList.hasOnlyDefaultValues()) {
                    final String message = MessageFormat.format("Reference to parameterized definition `{0}'' without actual parameter list", referredAssignment.getIdentifier().getDisplayName());
                    getLocation().reportSemanticError(message);
                    setIsErroneous(true);
                }
            }
        }
    }
    return referredAssignment;
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition) IParameterisedAssignment(org.eclipse.titan.designer.AST.TTCN3.definitions.IParameterisedAssignment)

Aggregations

Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)1 FormalParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList)1 IParameterisedAssignment (org.eclipse.titan.designer.AST.TTCN3.definitions.IParameterisedAssignment)1