use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter in project titan.EclipsePlug-ins by eclipse.
the class FormalParameterParser method process.
@Override
public Scope process(IVisitableNode node) {
if (node instanceof FormalParameter) {
FormalParameter parameter = (FormalParameter) node;
name = parameter.getIdentifier().toString();
}
if (node instanceof Type) {
type = Util.getTypeName((Type) node);
}
return this;
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter in project titan.EclipsePlug-ins by eclipse.
the class Parameter_Redirect method checkVariableReference.
/**
* Check whether the reference points to a variable of the provided
* type.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param reference
* the reference to check
* @param type
* the type the parameter is expected to have.
*/
public final void checkVariableReference(final CompilationTimeStamp timestamp, final Reference reference, final IType type) {
if (reference == null) {
return;
}
final IType variableType = reference.checkVariableReference(timestamp);
if (type != null && variableType != null && !type.isIdentical(timestamp, variableType)) {
final String message = MessageFormat.format("Type mismatch in parameter redirect: A variable of type `{0}'' was expected instead of `{1}''", type.getTypename(), variableType.getTypename());
reference.getLocation().reportSemanticError(message);
return;
}
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment != null) {
switch(assignment.getAssignmentType()) {
case A_PAR_VAL:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
((FormalParameter) assignment).setWritten();
break;
case A_VAR:
((Def_Var) assignment).setWritten();
break;
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
((FormalParameter) assignment).setWritten();
break;
case A_VAR_TEMPLATE:
((Def_Var_Template) assignment).setWritten();
break;
default:
break;
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method checkPortReference.
/**
* Checks a port reference.
* Statement independent version.
*
* @param timestamp
* the timestamp of the actual build cycle.
* @param portReference
* the port reference to be checked
*
* @return the port type of the reference if it is a correct port
* reference, or null otherwise
*/
public static Port_Type checkPortReference(final CompilationTimeStamp timestamp, final Reference portReference) {
if (portReference == null) {
return null;
}
final Assignment assignment = portReference.getRefdAssignment(timestamp, true);
if (assignment == null || assignment.getIsErroneous()) {
return null;
}
IType result = null;
switch(assignment.getAssignmentType()) {
case A_PORT:
final ArrayDimensions dimensions = ((Def_Port) assignment).getDimensions();
if (dimensions != null) {
dimensions.checkIndices(timestamp, portReference, "port", false, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
} else if (portReference.getSubreferences().size() > 1) {
portReference.getLocation().reportSemanticError(MessageFormat.format("Reference to single {0} cannot have field or array sub-references", assignment.getDescription()));
}
result = ((Def_Port) assignment).getType(timestamp);
break;
case A_PAR_PORT:
if (portReference.getSubreferences().size() > 1) {
portReference.getLocation().reportSemanticError(MessageFormat.format("Reference to {0} cannot have field or array sub-references", assignment.getDescription()));
}
result = ((FormalParameter) assignment).getType(timestamp);
break;
default:
portReference.getLocation().reportSemanticError(MessageFormat.format(PORTREFERENCEEXPECTED, assignment.getAssignmentName()));
break;
}
if (result == null) {
return null;
}
result = result.getTypeRefdLast(timestamp);
if (Type_type.TYPE_PORT.equals(result.getTypetype())) {
return (Port_Type) result;
}
return null;
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method checkValueRedirect.
/**
* Calculates the type of a variable when it was to be used as a value
* redirect target.
*
* @param timestamp
* the timestamp of the actual build cycle.
* @param redirectValue
* the reference to which the redirection is targeted
* @param type
* the expected type of the value redirection.
*
* @return the the type of a variable referenced when it was to be used
* as a value redirection target.
*/
public static IType checkValueRedirect(final CompilationTimeStamp timestamp, final Reference redirectValue, final IType type) {
if (redirectValue == null) {
return null;
}
final IType variableType = redirectValue.checkVariableReference(timestamp);
if (type != null && variableType != null && !type.isCompatible(timestamp, variableType, null, null, null)) {
redirectValue.getLocation().reportSemanticError(MessageFormat.format(VALUEREDIRECTTYPEMISSMATCH, type.getTypename(), variableType.getTypename()));
}
final Assignment assignment = redirectValue.getRefdAssignment(timestamp, true);
if (assignment != null) {
switch(assignment.getAssignmentType()) {
case A_PAR_VAL:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
((FormalParameter) assignment).setWritten();
break;
case A_VAR:
((Def_Var) assignment).setWritten();
break;
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
((FormalParameter) assignment).setWritten();
break;
case A_VAR_TEMPLATE:
((Def_Var_Template) assignment).setWritten();
break;
default:
break;
}
}
return variableType;
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter in project titan.EclipsePlug-ins by eclipse.
the class ChangeCreator method calculateEditLocations.
private WorkspaceJob calculateEditLocations(final List<FormalParameter> fparamlist, final IFile file, final List<Location> locations_out) throws CoreException {
final WorkspaceJob job = new WorkspaceJob("LazyficationRefactoring: calculate edit locations") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
for (FormalParameter fparam : fparamlist) {
System.out.println("reading: " + file.getName());
Location typeloc = fparam.getType(CompilationTimeStamp.getBaseTimestamp()).getLocation();
locations_out.add(0, new Location(fparam.getLocation().getFile(), fparam.getLocation().getLine(), typeloc.getOffset(), typeloc.getOffset()));
}
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
return job;
}
Aggregations