use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList in project titan.EclipsePlug-ins by eclipse.
the class FunctionContext method process_internal.
@Override
protected void process_internal() {
final Def_Function func = getNode();
final FormalParameterList fpl = func.getFormalParameterList();
final ParameterListVisitor vis = new ParameterListVisitor();
fpl.accept(vis);
paramIds = vis.getResult();
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList in project titan.EclipsePlug-ins by eclipse.
the class T3Doc method getCommentStringBasedOnReference.
public static String getCommentStringBasedOnReference(final DeclarationCollector declarationCollector, final List<DeclarationCollectionHelper> collected, final IEditorPart targetEditor, final IRegion hoverRegion, final IReferenceParser referenceParser, final ITextViewer textViewer) {
if (!T3Doc.isT3DocEnable()) {
return null;
}
Reference ref = declarationCollector.getReference();
if (ref == null) {
return null;
}
if ((ref.getMyScope() instanceof NamedBridgeScope || ref.getMyScope() instanceof FormalParameterList) && !collected.isEmpty()) {
DeclarationCollectionHelper declaration = collected.get(0);
if (declaration.node instanceof TTCN3_Sequence_Type || declaration.node instanceof FormalParameter) {
final IFile file = (IFile) targetEditor.getEditorInput().getAdapter(IFile.class);
ProjectSourceParser projectSourceParser = GlobalParser.getProjectSourceParser(file.getProject());
final Module tempModule = projectSourceParser.containedModule(file);
Assignment ass = tempModule.getEnclosingAssignment(hoverRegion.getOffset());
if (ass != null) {
Reference reference = referenceParser.findReferenceForOpening(file, hoverRegion.getOffset(), textViewer.getDocument());
String str = reference.getDisplayName();
List<String> al = T3Doc.getCommentStrings(ass.getCommentLocation(), str);
if (!al.isEmpty()) {
final StringBuilder sb = new StringBuilder();
for (String string : al) {
sb.append(string);
}
return sb.toString();
}
}
}
}
return null;
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList in project titan.EclipsePlug-ins by eclipse.
the class Def_Template method checkModified.
/**
* Checks the correctness of the modification of this template done to
* the modified one if it has any.
*
* @param timestamp
* the timestamp of the actual semantic check cycle
*/
private void checkModified(final CompilationTimeStamp timestamp) {
if (baseTemplate == null) {
return;
}
final IType baseType = baseTemplate.getType(timestamp);
if (!type.isCompatible(timestamp, baseType, null, null, null)) {
type.getLocation().reportSemanticError(MessageFormat.format(IMCOMPATIBLEBASETYPE, baseTemplate.getFullName(), baseType.getFullName(), type.getFullName()));
}
final FormalParameterList baseParameters = baseTemplate.getFormalParameterList(timestamp);
final int nofBaseFps = (baseParameters == null) ? 0 : baseParameters.getNofParameters();
final int nofLocalFps = (formalParList == null) ? 0 : formalParList.getNofParameters();
int minFps;
if (nofLocalFps < nofBaseFps) {
location.reportSemanticError(MessageFormat.format(FEWERFORMALPARAMETERS, baseTemplate.getFullName(), nofBaseFps, nofLocalFps));
minFps = nofLocalFps;
} else {
minFps = nofBaseFps;
}
for (int i = 0; i < minFps; i++) {
final FormalParameter baseFormalpar = baseParameters.getParameterByIndex(i);
final FormalParameter localFormalpar = formalParList.getParameterByIndex(i);
if (baseFormalpar.getAssignmentType() != localFormalpar.getAssignmentType()) {
localFormalpar.getLocation().reportSemanticError(MessageFormat.format(DIFFERENTPARAMETERKINDS, baseTemplate.getFullName(), baseFormalpar.getAssignmentName(), localFormalpar.getAssignmentName()));
}
final Type baseFpType = baseFormalpar.getType(timestamp);
final Type localFpType = localFormalpar.getType(timestamp);
if (!baseFpType.isCompatible(timestamp, localFpType, null, null, null)) {
if (!localFpType.getIsErroneous(timestamp) && !baseFpType.getIsErroneous(timestamp)) {
localFpType.getLocation().reportSemanticError(MessageFormat.format(INCOMPATIBLEBASEPARAMETERTYPE, baseTemplate.getFullName(), baseFpType.getTypename(), localFpType.getTypename()));
}
}
final Identifier baseFormalparId = baseFormalpar.getIdentifier();
final Identifier localFormalparId = localFormalpar.getIdentifier();
if (!baseFormalparId.equals(localFormalparId)) {
localFormalpar.getLocation().reportSemanticError(MessageFormat.format(DIFFERENTPARAMETERNAMES, baseTemplate.getFullName(), baseFormalparId.getDisplayName(), localFormalparId.getDisplayName()));
}
}
body.setBaseTemplate(baseTemplate.getTemplate(timestamp));
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList in project titan.EclipsePlug-ins by eclipse.
the class ExecuteDereferedExpression method checkExpressionOperands.
/**
* Checks the parameters of the expression and if they are valid in
* their position in the expression or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
*/
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (value != null) {
IType type;
value.setLoweridToReference(timestamp);
final IValue last = value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_TEMPLATE, referenceChain);
if (last.getIsErroneous(timestamp)) {
type = null;
} else {
type = last.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
if (type != null) {
type = type.getTypeRefdLast(timestamp);
}
}
if (type == null || type.getIsErroneous(timestamp)) {
setIsErroneous(true);
} else if (Type_type.TYPE_TESTCASE.equals(type.getTypetype())) {
final FormalParameterList formalParameters = ((Testcase_Type) type).getFormalParameters();
actualParameters = new ActualParameterList();
final boolean isErroneous = formalParameters.checkActualParameterList(timestamp, actualParameterList, actualParameters);
if (isErroneous) {
setIsErroneous(true);
}
} else {
value.getLocation().reportSemanticError(MessageFormat.format("Reference to a value of type testcase was expected in the argument of `derefers()'' instead of `{0}''", type.getTypename()));
setIsErroneous(true);
}
}
if (timerValue != null) {
timerValue.setLoweridToReference(timestamp);
final Type_type tempType = timerValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
switch(tempType) {
case TYPE_REAL:
final IValue last = timerValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, referenceChain);
if (!last.isUnfoldable(timestamp)) {
final Real_Value real = (Real_Value) last;
final double i = real.getValue();
if (i < 0.0) {
timerValue.getLocation().reportSemanticError(MessageFormat.format(NEGATIVEDURATION, real.createStringRepresentation()));
} else if (real.isPositiveInfinity()) {
timerValue.getLocation().reportSemanticError(MessageFormat.format(FLOATEXPECTED, real.createStringRepresentation()));
}
}
return;
case TYPE_UNDEFINED:
setIsErroneous(true);
return;
default:
if (!isErroneous) {
timerValue.getLocation().reportSemanticError(OPERANDERROR);
setIsErroneous(true);
}
return;
}
}
checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, false, false);
}
Aggregations